一開始我是選擇CentOS7安裝Oracle11g R2群集的,因為在安裝途中經(jīng)常出些莫名其妙的問題,后來查閱資料獲知Oracle11g真的是很老的版本了,對于最新操作系統(tǒng)的支持不怎么好,所以就選用CentOS6.5安裝群集。
文章參考了:https://blog.51cto.com/12926024/2153332
https://www.cnblogs.com/yuky/p/9304212.html
#Public IP
#公有IP是數(shù)據(jù)庫服務器真實IP,一般DBA用此IP登錄服務器做管理工作
192.168.247.21 RAC1
192.168.247.31 RAC2
#Private IP
# 私用IP群集內(nèi)部使用,用于心跳檢測,數(shù)據(jù)傳輸?shù)鹊?/p>
192.168.68.11 RAC1-priv
192.168.68.21 RAC2-priv
#Virtual IP
#虛擬IP是群集負載均衡IP,當用戶登錄數(shù)據(jù)庫,群集會根據(jù)負載隨機分配一個IP讓你登錄
192.168.68.32 RAC1-vip
192.168.68.42 RAC2-vip
#Scan IP
#監(jiān)聽IP是客戶使用的IP,也是我們平常登錄數(shù)據(jù)庫應填的IP,群集會隨機分配一個真實的節(jié)點讓你登錄
192.168.247.51 RAC-scan
# Virtual IP和Scan IP都是不存在的IP,是群集軟件(Grid)虛擬出來的IP,方便用戶操作數(shù)據(jù)庫
使用VMware安裝CentOS6.5系統(tǒng),注意選擇:自定安裝-->稍后安裝操作系統(tǒng),在安裝操作系統(tǒng)前先添加一張網(wǎng)卡再安裝操作系統(tǒng),這樣安裝完系統(tǒng)之后網(wǎng)卡2就會自動配有UUID(設備編號),不然自己找UUID,你會懷疑人生的。
因為使用的是VMware虛擬機,虛擬機默認IP都是DHCP浮動的,先把虛擬機IP設置為靜態(tài).
進入cmd---->ipconfig
可以看到VMware給我們分配的虛擬網(wǎng)卡是VMnet1和VMnet8
將虛擬網(wǎng)卡IP改為靜態(tài)IP ↑
編輯VMware網(wǎng)絡設置 ↓
NAT網(wǎng)絡用于Public IP
主機網(wǎng)絡用于Private IP,主機網(wǎng)絡跟NAT類似,模式選擇僅主機模式就行了
至此網(wǎng)絡配置完畢,注意RAC1節(jié)點與RAC2節(jié)點兩個節(jié)點都應配置網(wǎng)絡。且我RAC1節(jié)點的主機名為RAC1,RAC2節(jié)點的主機名為RAC2,我是安裝系統(tǒng)的時候就指定了主機名,沒設置主機名的同學設置一下主機名。
setenforce 0 #立即生效,臨時關閉,重啟恢復
vim /etc/selinux/config
設置SELINUX=disabled #永久關閉,重啟生效
CentOS6關閉防火墻
service iptables stop
chkconfig ip6tables off
chkconfig iptables off
CentOS7關閉防火墻
systemctl stop firewalld
systemctl disable firewalld
Grid軟件自帶時鐘同步服務,我們停用系統(tǒng)時鐘同步,使用群集自帶的時鐘同步服務
service ntpd status
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.bak
# for oracle 11g
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2147483648
kernel.shmmax = 68719476736
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
立即生效: /sbin/sysctl –p
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
session required pam_limits.so
#set oracle rac env
if [ $USER = "ORACLE" ] || [ $USER = "GRID" ];then
if [ $SHELL = "/bin/ksh" ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
groupadd -g 601 oinstall
groupadd -g 602 dba
groupadd -g 603 oper
groupadd -g 604 asmadmin
groupadd -g 605 asmoper
groupadd -g 606 asmdba
useradd -g oinstall -G dba,asmdba,oper oracle
useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
設置密碼
passwd grid
passwd oracle
su - grid
vim .bash_profile
export ORACLE_SID=+ASM1 #注意RAC2設置為 +ASM2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export PATH=$ORACLE_HOME/bin:$PATH
export LANG=en_US
umask 022
su - oracle
vim ~/.bash_profile
export ORACLE_SID=rac1 # 注意RAC2節(jié)點設置為 rac2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export TMP=/tmp
export TMPDIR=$TMP
export PATH=$PATH:$ORACLE_HOME/bin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
mkdir -p /u01/app/oracle
mkdir -p /u01/app/grid
mkdir -p /u01/app/11.2.0/grid
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/11.2.0
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
在安裝群集時,只需要在一個節(jié)點安裝軟件即可,節(jié)點互信會自動把安裝的軟件復制到其他節(jié)點
首先配置RAC1,RAC2 Oracle用戶的節(jié)點互信
su - oracle
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa (全回車,默認即可)
ssh-keygen -t dsa (全回車,默認即可)
(以上節(jié)點互信命令,RAC1,RAC2均要執(zhí)行)
返回RAC1,執(zhí)行(下面互信命令 RAC2不執(zhí)行)
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys oracle@RAC2:~/.ssh/authorized_keys
再配置RAC1,RAC2 grid用戶的節(jié)點互信
su - grid
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa (全回車,默認即可)
ssh-keygen -t dsa (全回車,默認即可)
(以上節(jié)點互信命令,RAC1,RAC2均要執(zhí)行)
返回RAC1,執(zhí)行(下面互信命令 RAC2不執(zhí)行)
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh RAC2 cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys grid@RAC2:~/.ssh/authorized_keys
yum install -y binutils* compat-libstdc* elfutils-libelf* gcc* glibc* ksh* libaio* libgcc* libstdc* make* sysstat* unixODBC* libaio-devel* glibc-devel.i686 libaio.i686 libaio-devel.i686 libstdc++-devel.i686 unixODBC-devel.i686 compat-libcap1* compat-libcap1.i686 expat*
確認一下兩個節(jié)點RPM包cvuqdisk-1.0.9-1.rpm是否安裝。
su - root
cd /home/grid/grid/rpm/
rpm -ivh cvuqdisk-1.0.9-1.rpm
scp /home/grid/grid/rpm/cvuqdisk-1.0.9-1.rpm root@rac-2:/root
rpm -ivh cvuqdisk-1.0.9-1.rpm
(確保RAC1,RAC2都安裝)
虛擬機編輯設置,添加三塊盤,分別叫:
ocr_vote.vmdk data.vmdk fra.vmdk(注意磁盤的大小)
這樣在RAC1依次建立三塊盤,分別名為ocr_vote.vmdk data.vmdk fra.vmdk
再看編輯這里就會多3塊盤
雙擊編輯硬盤
硬盤添加好后,編輯虛擬機vmx文件
添加
disk.EnableUUID="TRUE"
disk.locking = "false"
scsi1.shared="TRUE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
scsi1:1.deviceType = "disk"
scsi1:2.deviceType = "disk"
scsi1:3.deviceType = "disk"
scsi1:4.deviceType = "disk"
scsi1:5.deviceType = "disk"
scsi1:1.shared = "true"
scsi1:2.shared = "true"
scsi1:3.shared = "true"
scsi1:4.shared = "true"
scsi1:5.shared = "true"
然后在RAC2添加共享硬盤,因為RAC1已經(jīng)創(chuàng)建了硬盤,RAC2只需使用已創(chuàng)建硬盤即可
依次添加ocr_vote.vmdk data.vmdk fra.vmdk
然后設置為永久硬盤,注意選區(qū)應與RAC1一致 ocr_vote 1:1 data 1:2 fra 1:3
開啟虛擬機,查看磁盤時候掛載
因為我已經(jīng)裝了群集,使用了盤符,所以這里只顯示/dev/sdb,正常應該顯示3塊盤
/dev/sdb ,/dev/sdc,/dev/sdd 分別對應ocr_vite,data,fra
如果uuid查詢不到,檢查添加的虛擬機文件是否正確
虛擬機的vmx文件增加了disk.enableUUID = "TRUE"
正常情況下,RAC1與RAC2的UUID應該是一致的,如果不一致,檢查一下盤區(qū)(ocr_vote1:1,data1:2,fra1:3)是不是設置錯了?
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c2970a7c751fb10b2b412f57d5f1", NAME="asm-OCR", OWNER="grid", GROUP="asmdba", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29307291b23a98996cd0ec62022", NAME="asm-DATA", OWNER="grid", GROUP="asmdba", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29991d458a7f089fe668a4a492f", NAME="asm-FRA", OWNER="grid", GROUP="asmdba", MODE="0660"
注意,每條命令一行,不能換行.
su - grid
cd grid軟件解壓目錄
./runcluvfy.sh stage -pre crsinst -n rac-1,rac-2 -fixup -verbose
我檢查有這些不成功
i386是32位軟件,因為Oracle11g是非常老的數(shù)據(jù)庫了,它風靡全球的時候,主流計算機都是32位的,我們yum安裝的時候已經(jīng)裝了64位的對應軟件,就算你單獨下載這些軟件也是安裝不上的,會提示與64位的沖突。這些i386錯誤安裝時忽略掉即可。
pdksh在oracle11g已經(jīng)被ksh取代,提示這個是oracle11g的一個BUG
可以使用:wget http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm 下載pdksh-5.2.14
不用試了,裝不上的,提示與KSH沖突.
NTPD檢查不成功是因為我關閉了NTPD服務,但配置文件沒刪除,被檢測到了,刪除配置文件即可。
su - root
xhost +
su - grid
export DISPLAY=192.168.247.31:0.0
export LANG=en_US
cd /home/grid/grid
./runInstaller
出來的盤,選擇/dev/asm-OCR
執(zhí)行第二個腳本的時候會遇到錯誤:
oracle官網(wǎng)說是bug;
回退腳本執(zhí)行
/u01/app/11.2.0/grid/crs/install/roothas.pl -deconfig -force -verbose
然后再執(zhí)行第二個腳本
/u01/app/11.2.0/grid/root.sh
當執(zhí)行到 Adding daemon to inittab 這句話出來的時候
新開一個終端執(zhí)行:
/bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1
一直執(zhí)行直到不出現(xiàn)/bin/dd: opening`/var/tmp/.oracle/npohasd': No such file or directory
然后等待即可
導致這個錯誤的原因是在/etc/hosts中配置了SCAN的地址,嘗試ping這個地址信息,如果可以成功,則這個錯誤可以忽略。
我嘗試ping scan ip可以ping通,所以也就忽略了這個錯誤。
crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
crs_stat -t -v
注:
oc4j、gsd默認服務是禁用的
olsnodes -n
ps -ef|grep lsnr|grep -v 'grep'
ps -ef|grep lsnr|grep -v 'grep'|awk '{print $9}'
[grid@RAC1 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2568
Available space (kbytes) : 259552
ID : 1748729178
Device/File Name : +ocr_vote
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check bypassed due to non-privileged user
[grid@RAC1 ~]$ crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 6c1c6ab59d554ff9bfb24e7a9e2e3d86 (/dev/asm-OCR) [OCR_VOTE]
Located 1 voting disk(s).
[grid@RAC1 ~]$
至此,安裝全部完成。
---RAC1
su - oracle
sqlplus / as sysdba
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
---RAC2
su - oracle
sqlplus / as sysdba
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
---RAC1
cd /u01/app/11.2.0/grid/bin/
./crsctl stop cluster -all
[grid@rac1 ~]$ crs_stat -t
CRS-0184: Cannot communicate with the CRS daemon.
cd /u01/app/11.2.0/grid/bin/
./crsctl start cluster -n RAC1 RAC2
可能會遇到:
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Start failed, or completed with errors.
[root@RAC1 bin]# ps -ef|grep has
root 2632 1 0 20:10 ? 00:00:00 /u01/app/11.2.0/grid/bin/ohasd.bin reboot
root 65805 1 0 22:25 ? 00:00:00 /u01/app/11.2.0/grid/bin/ohasd.bin reboot
root 102710 5956 0 22:29 pts/0 00:00:00 grep has
[root@RAC1 bin]# kill -9 2632 65805
執(zhí)行:
[root@b1 grid]# cd /u01/app/11.2.0/grid/crs/install
[root@b1 install]# ./roothas.pl -deconfig -force -verbose
[root@b1 install]# cd /u01/app/11.2.0/grid/
[root@b1 grid]# ./root.sh
當執(zhí)行到 Adding daemon to inittab 這句話出來的時候
新開一個終端執(zhí)行:
/bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1
一直執(zhí)行直到不出現(xiàn)/bin/dd: opening`/var/tmp/.oracle/npohasd': No such file or directory
然后等待即可(記住,RAC1可執(zhí)行的時候,需到RAC2執(zhí)行同樣的語句.)
[grid@b1 ~]$ crs_stat -t
[root@host1 ~]# cd /u01/app/11.2.0/grid/bin/crsctl enable crs
[root@host1 ~]# cd /u01/app/11.2.0/grid/bin/crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
聯(lián)系客服