#ORACLE 12C ADG 之一 (DB 安裝)
#步驟1 检查并卸载OpenJDK & 安裝JDK 1.8
#第一步检查系统是否自带了OpenJDK以及相关安装包,如果有的话则应先将其卸载。
#检查命令:
[root@localhost ~]# java -version
[root@localhost ~]# rpm -qa | grep java
#如果发现有安装好的OpenJDK以及安装包的话那么首先依次执行卸载。
#卸载命令:
[root@localhost ~]# rpm -e --nodeps tzdata-java-2012c-1.el6.noarch
[root@localhost ~]# rpm –e --nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
[root@localhost ~]# mkdir /u01
[root@localhost ~]# mkdir /u01/java
#将文件 jdk-8u161-linux-x64.tar.gz上传至/usr/java目录下
[root@localhost ~]# cd /u01/java
[root@localhost java]# tar -zxvf jdk-8u181-linux-x64.tar.gz
[root@localhost java]# rm jdk-8u181-linux-x64.tar.gz
#设置环境变量
[root@localhost java]# vim /etc/profile
在profile中添加如下内容:
#set java environment
JAVA_HOME=/u01/java/jdk1.8.0_181
JRE_HOME=/u01/java/jdk1.8.0_181/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
#让修改生效:
[root@localhost java]# source /etc/profile
#输入java -version查看一下jdk版本信息:
[root@localhost java]# java -version
#步驟2 配置/etc/hosts
[root@DB196 ~]$ cat /etc/hosts
#add
192.168.1.196 DB196 DB196.COM
192.168.1.197 DB197 DB197.COM
192.168.1.229 DB229 DB229.COM
[root@DB196 ~]$ cat /etc/hostname
DB196.COM
[root@DB196 ~]$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=DB196
#步驟3 添加oracle 用戶
[root@DB196 ~]# groupadd oinstall
[root@DB196 ~]# groupadd dba
[root@DB196 ~]# groupadd oper
[root@DB196 ~]# useradd -g oinstall -G dba,oper oracle
[root@DB196 ~]# echo "123456" | passwd --stdin oracle #oracle用户的登录密码,后续登录要用,记着。
[root@DB196 ~]# cat /etc/sysconfig/iptables
#步驟4 配置防火墻
#add
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
[root@DB196 ~]# service iptables restart
#步驟5 安裝資源包
[root@DB196 ~]# yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*.i686 elfutils-libelf-devel gcc gcc-c++ glibc*.i686 glibc glibc-devel glibc-devel*.i686 ksh libgcc*.i686 libgcc libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.i686 libaio libaio*.i686 libaio-devel libaio-devel*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686 libXp
[root@DB196 ~]# yum install binutils gcc gcc-c++ compat-libstdc++-33 glibc glibc.i686 glibc-devel ksh libgcc.i686 libstdc++-devel libaio libaio.i686 libaio-devel libaio-devel.i686 libXtst libXtst.i686 libX11 libX11.i686 libXau libXau.i686 libxcb libxcb.i686 libXi libXi.i686 make sysstat compat-libcap1 –y
[root@DB196 ~]# yum -y install smartmontools
[root@DB196 ~]# yum -y install libXrender
#步驟6 修改系統參數
[root@DB196 ~]# vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft memlock 3145728
oracle hard memlock 3145728
[root@DB196 ~]# vim /etc/sysctl.conf
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 1610612736 #物理内存一半
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
[root@DB196 ~]# sysctl -p
vi /etc/pam.d/login,添加:
#add
#这是对应64位的
session required /lib64/security/pam_limits.so
#这是对应32位的
#session required /lib/security/pam_limits.so
修改ulimit:
vi /etc/profile,添加:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#步驟7 创建安装目录
[root@DB196 ~]# mkdir -p /u01/app/oracle/
[root@DB196 ~]# mkdir -p /u01/tmp/
[root@DB196 ~]# chown -R oracle:oinstall /u01/app/
[root@DB196 ~]# chown -R oracle:oinstall /u01/tmp/
[root@DB196 ~]# chmod -R 775 /u01/app/
[root@DB196 ~]# chmod -R 775 /u01/tmp/
#步驟8 配置oracle用戶环境变量
[oracle@DB196 ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export DISPLAY=10.0.0.85:0.0
ORACLE_SID=MPCDB;export ORACLE_SID
ORACLE_UNQNAME=MPCDB;export ORACLE_UNQNAME
JAVA_HOME=/u01/java/jdk1.8.0_181; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="YYYY:MM:DD HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.UTF8; export NLS_LANG
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/u01/tmp
export TMPDIR=/u01/tmp
umask 022
[oracle@DB196 ~]$
[oracle@DB196 ~]$ source .bash_profile
[oracle@DB196 setup]$ unzip linuxx64_12201_database.zip
[oracle@DB196 database]$ pwd
/u01/setup/database
[oracle@DB196 database]$ ./runInstaller
=================================================================
#步驟9 安裝后梳理
UNDO梳理
ALTER DATABASE DATAFILE '/u02/oradata/MPCDB/undotbs01.dbf' RESIZE 1G;
ALTER DATABASE DATAFILE '/u02/oradata/MPCDB/undotbs01.dbf' AUTOEXTEND ON NEXT 256M;
TEMP 梳理
---------------------------------------------------------------------------
CREATE SMALLFILE TEMPORARY TABLESPACE TEMP1
TEMPFILE
'/u02/oradata/MPCDB/TEMP1_1.dbf' SIZE 8G,
'/u02/oradata/MPCDB/TEMP1_2.dbf' SIZE 8G
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
or
CREATE TEMPORARY TABLESPACE TEMP1 TEMPFILE
'/u02/oradata/MPCDB/TEMP1_1.dbf' SIZE 2G REUSE AUTOEXTEND ON NEXT 512M MAXSIZE 32767M,
'/u02/oradata/MPCDB/TEMP1_2.dbf' SIZE 2G REUSE AUTOEXTEND ON NEXT 512M MAXSIZE 32767M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
-------------------------------------------------------------------------
ALTER TABLESPACE TEMP1 TABLESPACE GROUP TEMPGROUP01;
drop tablespace TEMP including contents and datafiles;