ORACLE 12C R2 RAC搭建
目錄
1、ORACLE 12.2軟硬體要求
1.1 硬體最低配置要求
序號 |
元件 |
記憶體需求 |
1 |
Oracle Grid Infrastructure installations |
4GB以上 |
2 |
Oracle Database installations |
最小1GB,建議2GB以上 |
1.2 ORACLE 12.2認證的OS軟體版本
序號 |
元件 |
1 |
Oracle Linux 7 with the Unbreakable Enterprise kernel: 3.8.13-35.3.1.el7uek.x86_64 or later |
2 |
Oracle Linux 7 with the Red Hat Compatible kernel: 3.10.0-123.el7.x86_64 or later |
3 |
Oracle Linux 6.4 with the Unbreakable Enterprise kernel 2: 2.6.39-200.24.1.el6uek.x86_64 or later |
4 |
Oracle Linux 6 with the Red Hat Compatible kernel: 2.6.32-358.el6.x86_64 or later |
5 |
Red Hat Enterprise Linux 7: 3.10.0-123.el7.x86_64 or later |
6 |
Red Hat Enterprise Linux 6: 2.6.32-358.el6.x86_64 or later |
7 |
SUSE Linux Enterprise Server 12: 3.12.28-4-default or later |
8 |
SUSE Linux Enterprise Server 11 SP2: 3.0.13-0.27 or later |
2、整體規劃部分
2.1 IP地址規劃
序號 |
所屬 |
主機名稱 |
用途 |
IP地址 |
1 |
GNS |
GNS |
192.168.1.190 |
|
2 |
Node1 |
rac1 |
public |
192.168.1.191 |
3 |
Node1 |
vip |
192.168.1.192 |
|
4 |
Node1 |
Private1 |
10.1.1.191 |
|
5 |
Node1 |
Private2 |
10.1.1.192 |
|
7 |
Node2 |
rac2 |
public |
192.168.1.193 |
8 |
Node2 |
vip |
192.168.1.194 |
|
9 |
Node2 |
Private1 |
10.1.1.193 |
|
10 |
Node2 |
Private2 |
10.1.1.194 |
|
11 |
scan |
scan1 |
192.168.1.195 |
|
12 |
scan |
scan2 |
192.168.1.196 |
|
13 |
scan |
scan3 |
192.168.1.197 |
2.2 作業系統本地磁碟分割槽規劃
序號 |
分割槽名稱 |
大小 |
用途說明 |
1 |
/boot |
200MB |
引導分割槽 |
2 |
/ |
12288MB(12G) |
根分割槽 |
3 |
swap |
6144MB |
最少4.7303GB以上 |
4 |
/dba |
44850MB |
oracle安裝目錄 |
2.3 共享儲存與ASM磁碟組規劃
序號 |
磁碟名稱 |
Asm磁碟名稱 |
磁碟組名稱 |
大小 |
用途 |
1 |
sdb1 |
asm-diskb |
OCR_VOT |
10G |
OCR+VOTINGDISK |
2 |
sdc1 |
asm_diskc |
DATA01 |
30G |
data |
3、作業系統配置部分
3.1 配置hosts檔案
Vi /etc/hosts
192.168.1.189 GNS 192.168.1.191 rac1.li.com rac1 192.168.1.192 rac1-vip.li.com rac1-vip 10.1.1.191 rac1-pri1.li.com rac1-pri1 10.1.1.192 rac1-pri2.li.com rac1-pri2 192.168.1.193 rac2.li.com rac2 192.168.1.194 rac2-vip.li.com rac2-vip 10.1.1.193 rac2-pri1.li.com rac2-pri1 10.1.1.194 rac2-pri2.li.com rac2-pri2 192.168.1.195 rac-scan.li.com rac-scan 192.168.1.196 rac-scan.li.com rac-scan 192.168.1.197 rac-scan.li.com rac-scan |
3.2 安裝RPM包
binutils-2.20.51.0.2-5.11.el6 (x86_64) compat-libcap1-1.10-1 (x86_64) compat-libstdc++-33-3.2.3-69.el6 (x86_64) compat-libstdc++-33-3.2.3-69.el6 (i686) gcc-4.4.4-13.el6 (x86_64) gcc-c++-4.4.4-13.el6 (x86_64) glibc-2.12-1.7.el6 (i686) glibc-2.12-1.7.el6 (x86_64) glibc-devel-2.12-1.7.el6 (x86_64) glibc-devel-2.12-1.7.el6 (i686) ksh libgcc-4.4.4-13.el6 (i686) libgcc-4.4.4-13.el6 (x86_64) libstdc++-4.4.4-13.el6 (x86_64) libstdc++-4.4.4-13.el6 (i686) libstdc++-devel-4.4.4-13.el6 (x86_64) libstdc++-devel-4.4.4-13.el6 (i686) libaio-0.3.107-10.el6 (x86_64) libaio-0.3.107-10.el6 (i686) libaio-devel-0.3.107-10.el6 (x86_64) libaio-devel-0.3.107-10.el6 (i686) libXext-1.1 (x86_64) libXext-1.1 (i686) libXtst-1.0.99.2 (x86_64) libXtst-1.0.99.2 (i686) libX11-1.3 (x86_64) libX11-1.3 (i686) libXau-1.0.5 (x86_64) libXau-1.0.5 (i686) libxcb-1.5 (x86_64) libxcb-1.5 (i686) libXi-1.3 (x86_64) libXi-1.3 (i686) make-3.81-19.el6 sysstat-9.0.4-11.el6 (x86_64) unixODBC.x86_64 0:2.2.14-12.el6_3 nscd |
3.3建立使用者組
#/usr/sbin/groupadd –g 501 oinstall
#/usr/sbin/groupadd –g 502dba
#/usr/sbin/groupadd –g 503oper
#/usr/sbin/groupadd –g 504asmadmin
#/usr/sbin/groupadd –g 505asmdba
#/usr/sbin/groupadd –g 506 asmoper
#/usr/sbin/useradd –u 501 –g oinstall –G asmadmin,asmdba,asmoper grid
#/usr/sbin/useradd –u 502 –goinstall –G dba,asmdba oracle
passwd oracle
passwd grid
3.4 建立檔案目錄及許可權配置
#mkdir -p /dba/app/grid
--this is the GI ORACLE_BASE
#mkdir -p /dba/app/12.2.0/grid
--this is the ORACLE_HOME FOR GI
#mkdir -p /dba/app/oracle
--this is the RDBMS ORACLE_BASE
#mkdir -p /dba/app/oracle/product/12.2.0/db_1
--this is the RDBMSORACLE_HOME
#mkdir -p /dba/app/oraInventory
--this is oraInventory location
#chown -R grid:oinstall/dba/app
#chown -Roracle:oinstall /dba/app/oracle
#chmod -R 775 /dba/app
3.5 配置環境變數
#su – grid
$vi .bash_profile
export TMP=/tmp export TMPDIR=$TMP export ORACLE_BASE=/dba/app/grid export ORACLE_HOME=/dba/app/12.2.0/grid export ORACLE_SID=+ASM1 export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib alias sqlplus="rlwrap sqlplus" |
$source .bash_profile
#su – oracle
$vi .bash_profile
export PATH export TMP=/tmp export TMPDIR=$TMP export ORACLE_BASE=/dba/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1 export ORACLE_SID=naridb export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib alias sqlplus="rlwrap sqlplus" alias rman="rlwrap rman" |
3.6 安裝cvuqdisk
cvuqdisk存於oracle GI安裝介質的cv/rpm目錄下
export CVUQDISK_GRP=asmadmin
rpm –ivh cvuqdisk-1.0.10-1.rpm
4、修改作業系統配置
4.1 開啟nscd
#chkconfig nscd on
chkconfig --level 35 nscd on
service nscd start
4.2 關閉防火牆
#chkconfig iptables off
#chkconfig ip6tables off
#service iptables stop
#service ip6tables stop
4.3 禁用selinux
修改/etc/selinux/config
編輯文字中的SELINUX=enforcing為SELINUX=disabled
4.4 關閉TransparentHugePages
(1)檢視驗證transparent_hugepage的狀態
cat/sys/kernel/mm/redhat_transparent_hugepage/enabled
always madvise [never] 結果為never表示關閉
(2)關閉transparent_hugepage的配置
#vi /etc/rc.local #註釋:編輯rc.local檔案,增加以下內容 if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled fi |
4.5 配置/etc/security/limits.conf
grid soft nproc 2047 grid hard nproc 16384 grid soft nofile 1024 grid hard nofile 65536 grid soft stack 10240 grid hard stack 32768 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 oracle hard stack 32768 |
4.6 配置/etc/sysctl.conf
增加以下內容
fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 67108864 kernel.shmmax = 274877906944 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 net.ipv4.conf.eth2.rp_filter = 2 net.ipv4.conf.eth1.rp_filter = 2 net.ipv4.conf.eth0.rp_filter = 1 |
針對rp_filter部分,如果沒有多張私有網絡卡,則不需要配置,文件 ID1286796.1有描述。
4.7 配置/etc/pam.d/login
增加以下內容:
session required pam_limits.so |
4.8 配置DNS
#vi /etc/resolv.conf
nameserver192.168.1.190 |
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=192.168.1.190 |
配置了/etc/resolv.conf還要在/etc/sysconfig/network-scripts/ifcfg-eth0中增加 DNS1=192.168.1.190的原因是,如果不配置後者,在OS重啟後,resolv.conf中配置的nameserver資訊會自動丟失
4.9 修改時間同步方式
(1)vi/etc/ntp.conf
#增加下面內容 Server 192.168.1.190 |
(2)Vi /etc/sysconfig/ntpd
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g" 修改成 OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g" |
#chkconfig ntpd on
#service ntpd restart
4.10 修改nsswitch.conf
nsswitch.conf儲存的是域名檢索順序。在一些系統配置中,NIS(Network Information System)可能會引起SCAN域名解析異常。為了避免這種問題的發生,對nsswitch.conf做如下調整。
#vi /etc/nsswitch.conf
修改行 hosts: files dns 為 hosts: files dns nis |
4.10 配置NOZEROCONF
vi /etc/sysconfig/network增加以下內容
NOZEROCONF=yes |
4.11 配置互信
方法:使用sshUserSetup.sh快速建立互信
sshUserSetup.sh在GI安裝介質解壓縮後的oui/prov/resources/scripts目錄下。
下面兩條命令在一個節點上執行即可(可以在root使用者下執行):
#./sshUserSetup.sh -user grid -hosts "rac2 rac1" -advanced -exverify –confirm #./sshUserSetup.sh -user oracle -hosts "rac2 rac1" -advanced -exverify -confirm |
5、ASM磁碟配置部分
5.1 UDEV配置asm磁碟(兩個節點都執行)
(1)查出兩個磁碟的UUID
[[email protected] ~]# /sbin/scsi_id -g -u -d /dev/sdb
36000c29a206f9c0ff78ea1f8b17f4c68
[[email protected] ~]# /sbin/scsi_id-g -u -d /dev/sdc
36000c293dee9cf6e31fe7eeaf2f5bba7
(2)vi/etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sdb", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29a206f9c0ff78ea1f8b17f4c68", NAME="asm-diskb", OWNER="grid", GROUP="asmadmin", MODE="0660" KERNEL=="sdc", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c293dee9cf6e31fe7eeaf2f5bba7", NAME="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660" |
(3)重啟UDEV
# /sbin/udevadm control --reload-rules
#/sbin/start_udev
5.2 驗證asm disk生成
查詢asm磁碟是否生成
#cd /dev
#ls –l asm*
[[email protected] dev]# ls -l asm*
brw-rw---- 1 grid asmadmin 8,17 Feb 22 06:35 asm-disk1
brw-rw---- 1 grid asmadmin 8,33 Feb 22 06:35 asm-disk2
5.2 修改磁碟屬性
(1)修改磁碟屬性
#echo deadline >/sys/block/sdb/queue/scheduler
#echo deadline > /sys/block/sdc/queue/scheduler
(2)驗證屬性修改結果:
[[email protected] dev]# more /sys/block/sdb/queue/scheduler
noop anticipatory [deadline]cfq
[[email protected] dev]# more /sys/block/sdc/queue/scheduler
noop anticipatory [deadline]cfq
6、grid軟體安裝
6.1 檢測安裝環境
--全面檢查:
./runcluvfy.sh stage -precrsinst -n rac1,rac2 -verbose
--檢查網路和等效性
./runcluvfy.sh comp nodecon -nrac1,rac2 -verbose
[[email protected] grid]$ ./runcluvfy.sh comp nodecon -n rac1,rac2 -verbose Verifying Node Connectivity ... Verifying Hosts File ... Node Name Status ------------------------------------ ------------------------ rac1 passed rac2 passed Verifying Hosts File ...PASSED Interface information for node "rac1" Name IP Address Subnet Gateway Def. Gateway HW Address MTU ------ --------------- --------------- --------------- --------------- ----------------- ------ eth0 192.168.2.191 192.168.2.0 0.0.0.0 192.168.2.2 00:0C:29:7E:7E:8E 1500 eth1 10.1.1.191 10.1.1.0 0.0.0.0 192.168.2.2 00:0C:29:7E:7E:98 1500 eth2 10.1.1.192 10.1.1.0 0.0.0.0 192.168.2.2 00:0C:29:7E:7E:A2 1500 Interface information for node "rac2" Name IP Address Subnet Gateway Def. Gateway HW Address MTU ------ --------------- --------------- --------------- --------------- ----------------- ------ eth0 192.168.2.193 192.168.2.0 0.0.0.0 192.168.2.2 00:0C:29:4D:85:CF 1500 eth1 10.1.1.193 10.1.1.0 0.0.0.0 192.168.2.2 00:0C:29:4D:85:D9 1500 eth2 10.1.1.194 10.1.1.0 0.0.0.0 192.168.2.2 00:0C:29:4D:85:E3 1500 Node Name IP Address Subnet MTU -------- ------- ------------ ------------ ------------- rac1 eth0 192.168.2.191 192.168.2.0 1500 rac2 eth0 192.168.2.193 192.168.2.0 1500 Node Name IP Address Subnet MTU -------- -------- ------------ ------------ ------------ rac1 eth1 10.1.1.191 10.1.1.0 1500 rac1 eth2 10.1.1.192 10.1.1.0 1500 rac2 eth1 10.1.1.193 10.1.1.0 1500 rac2 eth2 10.1.1.194 10.1.1.0 1500 Verifying Check that maximum (MTU) size packet goes through subnet ...PASSED Verifying Node Connectivity ...PASSED Verifying Multicast check ...PASSED Verification of node connectivity was successful. CVU operation performed: node connectivity Date: Feb 22, 2016 8:17:50 PM CVU home: /dba/soft/grid/ User: grid |
6.2 安裝GI(Grid Infrastructure)
./gridSetup.sh
Scan name需要和/etc/hosts中的scan名稱一致,否則會報下面錯誤:
ins-40718 single client accessname(scan):XXclustername could not be resolved
如果選擇flex,必須3塊磁碟,以及剩餘空間36352MB以上,如下圖所示:
[[email protected] tmp]$ crs_stat -t Name Type Target State Host ------------------------------------------------------------ ora....SM.lsnr ora....er.type ONLINE ONLINE rac1 ora....ER.lsnr ora....er.type ONLINE ONLINE rac1 ora....AF.lsnr ora....er.type OFFLINE OFFLINE ora....N1.lsnr ora....er.type ONLINE ONLINE rac2 ora....N2.lsnr ora....er.type ONLINE ONLINE rac1 ora....N3.lsnr ora....er.type ONLINE ONLINE rac1 ora.MGMTLSNR ora....nr.type ONLINE ONLINE rac1 ora.OCR_VOT.dg ora....up.type ONLINE ONLINE rac1 ora.asm ora.asm.type ONLINE ONLINE rac1 ora.cvu ora.cvu.type ONLINE ONLINE rac1 ora.gns ora.gns.type ONLINE ONLINE rac1 ora.gns.vip ora....ip.type ONLINE ONLINE rac1 ora.ioserver ora....er.type OFFLINE OFFLINE ora.mgmtdb ora....db.type ONLINE ONLINE rac1 ora....network ora....rk.type ONLINE ONLINE rac1 ora.ons ora.ons.type ONLINE ONLINE rac1 ora.proxy_advm ora....vm.type OFFLINE OFFLINE ora.qosmserver ora....er.type ONLINE ONLINE rac1 ora....C1.lsnr application ONLINE ONLINE rac1 ora.rac1.ons application ONLINE ONLINE rac1 ora.rac1.vip ora....t1.type ONLINE ONLINE rac1 ora....C2.lsnr application ONLINE ONLINE rac2 ora.rac2.ons application ONLINE ONLINE rac2 ora.rac2.vip ora....t1.type ONLINE ONLINE rac2 ora.scan1.vip ora....ip.type ONLINE ONLINE rac2 ora.scan2.vip ora....ip.type ONLINE ONLINE rac1 ora.scan3.vip ora....ip.type ONLINE ONLINE rac1 |
7 、asmca建立其它asmdiskgroup
8、database軟體安裝
#su – oracle
$./runInstaller
按照上圖提示,在兩個節點上分別執行:
./dba/app/oracle/product/12.2.0/db_1/root.sh
9、建立CDB
#su - oracle
$dbca
檢視建立的容器資料庫:
SQL> select name,cdb from v$database;
NAME CDB
--------- ---
LITESTDB YES
檢視存在的插撥資料庫:
SQL> col pdb_name for a30
SQL> selectpdb_id,pdb_name,dbid,status,creation_scn from dba_pdbs;
PDB_ID PDB_NAME DBID STATUS CREATION_SCN
------ --------------------------- ---------- -----------
2 PDB$SEED 33618433 NORMAL 2717802
10、建立PDB
10.1 以命令方式建立PDB
$sqlplus “/as sysdba”
SQL> CREATE PLUGGABLEDATABASE lipdb
ADMIN USER lipdbdba IDENTIFIED BY lipdbdba
STORAGE (MAXSIZE 5G MAX_SHARED_TEMP_SIZE100M)
DEFAULT TABLESPACE tbs_pdb2 DATAFILE'+DATA01' SIZE 100M AUTOEXTEND ON;
Pluggable database created.
10.2 檢視建立成功的PDB
SQL> col pdb_name for a30
SQL> selectpdb_id,pdb_name,dbid,status,creation_scn from dba_pdbs;
PDB_ID PDB_NAME DBID STATUS CREATION_SCN
------ --------- ------------------ ------------
3 LIPDB 182063881 NEW 3294239
2 PDB$SEED 33618433 NORMAL 2717802