Oracle12C R2已經(jīng)出來有一段時(shí)間了,一直想搞搞RAC可是由于安裝Oracle12C R2 RAC對(duì)系統(tǒng)資源的高要求,使得每次在自己的虛擬機(jī)上安裝都失敗(失敗的原因主要是由于內(nèi)存太小所致),前幾天在工作不忙的時(shí)候打開計(jì)算機(jī)啥也不做,就開幾個(gè)虛擬機(jī)做RAC實(shí)驗(yàn),最后也算成功了;---我自己的筆記本內(nèi)存16G I7的內(nèi)核
我們提供的服務(wù)有:成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、寧強(qiáng)ssl等。為千余家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的寧強(qiáng)網(wǎng)站制作公司
1、環(huán)境準(zhǔn)備:
操作系統(tǒng):Linux7.2-64
軟件:linuxx64_12201_database
linuxx64_12201_grid_home
ASM磁盤組:使用裸設(shè)備
Oracle12C R2+RAC
安裝介質(zhì):
軟件包 | 名稱 |
Linux7.1(64) | 操作系統(tǒng) |
linuxx64_12201_database | 數(shù)據(jù)庫軟件包 |
linuxx64_12201_grid_home | 數(shù)據(jù)庫集群軟件 |
ASM磁盤 | 共享存儲(chǔ) |
IP分配:
主機(jī)名 | 主機(jī)IP | PRIV | VIP |
rac1 | 192.168.2.100 | 10.0.0.1 | 192.168.2.101 |
rac2 | 192.168.2.200 | 10.0.0.2 | 192.168.2.201 |
sacnIP | 192.168.2.210 | ||
ISCSI服務(wù)器IP | 192.168.2.88 | ||
兩個(gè)節(jié)點(diǎn)只需配置公網(wǎng)和私有IP即可,虛擬IP與scanIP在hosts文件指定 |
安裝目錄:
Oracle軟件 | /opt/oracle/product/12/db |
grid 軟件 | /opt/12/grid |
CRS 軟件 | +DATT/testa/ |
---注明下:我做實(shí)驗(yàn)使用的共享存儲(chǔ)盤 是采用ISCSI,單獨(dú)開了一臺(tái)服務(wù)器做的,本次做測(cè)試一共開了3臺(tái)虛擬機(jī)(兩臺(tái)數(shù)據(jù)庫主機(jī)各6G內(nèi)存,ISCSI服務(wù)器500M)
ISCSI服務(wù)器共享存儲(chǔ)配置步驟省略,需要用到的命令如下:
客戶端發(fā)現(xiàn)目標(biāo)服務(wù)器共享磁盤:
[root@rac2 Server]# iscsiadm -m discovery -t sendtargets -p192.168.2.88
掛載目標(biāo)服務(wù)器共享磁盤
[root@rac2 ~]# iscsiadm -m node --loginall=all
2、開始部署RAC
[root@rac1~]# vim /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost
::1 localhost6.localdomain6 localhost6
192.168.2.100 rac121
192.168.2.101 rac121-vip
10.0.0.1 rac121-priv
192.168.2.200 rac122
192.168.2.201 rac122-vip
10.0.0.2 rac122-priv
192.168.2.210 scan-rac
[root@rac2 ~]# vim /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost
::1 localhost6.localdomain6 localhost6
192.168.2.100 rac121
192.168.2.101 rac121-vip
10.0.0.1 rac121-priv
192.168.2.200 rac122
192.168.2.201 rac122-vip
10.0.0.2 rac122-priv
192.168.2.210 scan-rac
[root@121 Packages]# yum -y install binutils*glibc* libstdc* libaio* libX* make* sysstat* compat-* glibc-* unix*
[root@121~]# vi/etc/sysctl.conf (要根據(jù)自己服務(wù)器的內(nèi)存合理配置)
----------------------------------------------
添加以下內(nèi)容:--具體的大小值 由自己的內(nèi)存決定,自行調(diào)整
fs.aio-max-nr =1048576
fs.file-max =6815744
kernel.shmall =2097152
kernel.shmmax = 2147483648
kernel.shmmni =4096
kernel.sem = 25032000 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
[root@121~]# sysctl -p --使設(shè)置生效
[root@121 ~]# vim /etc/pam.d/login
session required pam_limits.so
[root@122 ~]# vim /etc/pam.d/login
session required pam_limits.so
創(chuàng)建oracle用戶與grid用戶
[root@121 ~]# groupadd -g400 oinstall
[root@121 ~]# groupadd -g 401 dba
[root@121 ~]# groupadd -g 402 asmadmin
[root@121 ~]# groupadd -g 403 asmdba
[root@121 ~]# groupadd -g 404 asmoper
[root@121 ~]# groupadd -g 405 oper
[root@121 ~]# useradd -u 400 -g oinstall -Gasmadmin,asmdba,asmoper,dba grid
[root@121 ~]# useradd -u 401 -g oinstall -Gdba,asmdba,asmadmin,oper oracle
# passwd oracle
# passwd grid
[root@121 ~]# vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536做
grid soft nproc 2047
grid hard nproc 32768
grid soft nofile 1024
grid hard nofile 65536
[root@rac121 ~]# mkdir -p /opt/grid
[root@rac121 ~]# mkdir -p /opt/12/grid
[root@rac121 ~]# mkdir -p /opt/oracle/product/12/db
[root@rac121 ~]# mkdir -p /opt/oracle/oradata
[root@rac121 ~]# chown -R grid.oinstall /opt/grid
[root@rac121 ~]# chown -R grid.oinstall /opt/12
[root@rac121 ~]# chown -R oracle.oinstall /opt/oracle/
[root@rac121 ~]# chmod -R 775 /opt/
第一個(gè)節(jié)點(diǎn):Oracle環(huán)境變量
export PATH
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/12/db
export ORACLE_SID=testdb
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
第一個(gè)節(jié)點(diǎn):grid環(huán)境變量
export ORACLE_BASE=/opt/grid
export ORACLE_HOME=/opt/12/grid
export ORACLE_SID=+ASM1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
第二個(gè)節(jié)點(diǎn):Oracle環(huán)境變量
export PATH
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/12/db
export ORACLE_SID=testdb
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
第二個(gè)節(jié)點(diǎn):grid環(huán)境變量
export ORACLE_BASE=/opt/grid
export ORACLE_HOME=/opt/12/grid
export ORACLE_SID=+ASM2
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
配置兩個(gè)節(jié)點(diǎn)SSH信任:
[root@rac121 ~]# su - oracle
[oracle@rac121 ~]$ mkdir ~/.ssh
[oracle@rac121 ~]$ chmod 700 ~/.ssh/
[oracle@rac121 ~]$ cd ~/.ssh/
[oracle@rac121 .ssh]$ ssh-keygen -t rsa
[oracle@rac121 .ssh]$ ssh-keygen -t dsa
[oracle@rac121 .ssh]$ cat id_rsa.pub >> authorized_keys
[oracle@rac121 .ssh]$ cat id_dsa.pub >> authorized_keys
[root@rac121 ~]# su – grid
[grid@rac121 ~]$ mkdir ~/.ssh
[grid@rac121 ~]$ cd ~/.ssh/
[grid@rac121 .ssh]$ cd ..
[grid@rac121 ~]$ chmod 700 ~/.ssh/
[grid@rac121 ~]$ cd ~/.ssh/
[grid@rac121 .ssh]$ ssh-keygen -t rsa
[grid@rac121 .ssh]$ ssh-keygen -t dsa
[grid@rac121 .ssh]$ cat id_rsa.pub >> authorized_keys
[grid@rac121 .ssh]$ cat id_dsa.pub >> authorized_keys
(節(jié)點(diǎn)二也要執(zhí)行上述操作,然后將兩個(gè)節(jié)點(diǎn)的公鑰與私鑰進(jìn)行整合,分別拷貝到兩個(gè)節(jié)點(diǎn)中)
完成后進(jìn)行測(cè)試,是否成功
在兩個(gè)節(jié)點(diǎn)切換到oracle與grid用戶執(zhí)行下屬操作,(不輸入密碼就成功驗(yàn)證)
[root@rac121 ~]# su - oracle
[oracle@rac1 ~]$ ssh rac1 date
Thu Nov 27 04:56:46 EST 2014
[oracle@rac121 ~]$ ssh rac2 date
Thu Nov 27 04:56:48 EST 2014
[oracle@rac121 ~]$ ssh rac1-priv date
Thu Nov 27 04:56:54 EST 2014
[oracle@rac121 ~]$ ssh rac2-priv date
Thu Nov 27 04:56:57 EST 2014
3、掛載共享磁盤(在兩個(gè)節(jié)點(diǎn)依次執(zhí)行)
客戶端發(fā)現(xiàn)目標(biāo)服務(wù)器共享磁盤:
[root@121 Server]# iscsiadm -m discovery -t sendtargets -p192.168.2.88
掛載目標(biāo)服務(wù)器共享磁盤
[root@122 ~]# iscsiadm -m node --loginall=all
3.1、設(shè)置可用的ASM磁盤
[root@121~]# vim hao.sh ---編輯腳本
for i in c d e f g j h i j
do
echo "KERNEL==\"sd?\",SUBSYSTEM==\"block\", PROGRAM==\"/usr/lib/udev/scsi_id--whitelisted --replace-whitespace --device=/dev/\$name\",RESULT==\"`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/sd$i`\", SYMLINK+=\"asm-disk$i\",OWNER=\"grid\", GROUP=\"asmadmin\",MODE=\"0660\""
done
[root@121~]# sh hao.sh ----執(zhí)行腳本
運(yùn)行腳本得到如下內(nèi)容:
KERNEL=="sd?", SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name",RESULT=="14945540000000000ef376caea6d46a84b299aa2af675ec33",SYMLINK+="asm-diskc", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name",RESULT=="1494554000000000046b356d577df32a8ebb1bc37aa63263b",SYMLINK+="asm-diskd", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name",RESULT=="149455400000000000dbef13af1d00493893edc4ce2ba0109",SYMLINK+="asm-diske", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name",RESULT=="14945540000000000fa5fccd4e81b51abc3795d66e58fb835",SYMLINK+="asm-diskf", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name",RESULT=="14945540000000000545ef7c7a91cd370b7287e7498981e57",SYMLINK+="asm-diskg", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name",RESULT=="1494554000000000078e745363d1683b432ae66cb39a2171d",SYMLINK+="asm-diskj", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/$name",RESULT=="1494554000000000024c7e5803c9b66544cbc6e847bc36dcd",SYMLINK+="asm-diskh", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id--whitelisted --replace-whitespace --device=/dev/$name",RESULT=="14945540000000000a633b36c46b565abe1bf9735cc854e85",SYMLINK+="asm-diski", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id--whitelisted --replace-whitespace --device=/dev/$name",RESULT=="1494554000000000078e745363d1683b432ae66cb39a2171d",SYMLINK+="asm-diskj", OWNER="grid",GROUP="asmadmin", MODE="0660”
然后將上面的內(nèi)容添加到系統(tǒng)文件:
[root@rac2~]# vim /etc/udev/rules.d/70-persistent-ipoib.rules
運(yùn)行系統(tǒng)命令重新掃描磁盤:
[root@rac2 ~]# partprobe
然后查看裸設(shè)備是否創(chuàng)建成功
[root@rac121 ~]# ls -l /dev/sd*
4、安裝grid軟件:
注意:grid軟件要解壓到 grid用戶的家目錄,我們本次環(huán)境的home目錄:
export ORACLE_HOME=/opt/12/grid
所以,把軟件放到/opt/12/grid目錄下,然后解壓就可以了:
[grid@rac121 ~]$ cd /opt/12/grid/
[grid@rac121 grid]$ unzip linuxx64_12201_grid_home
4.1、開始安裝grid軟件,如下所示:
出現(xiàn)上述圖后,需要在兩個(gè)節(jié)點(diǎn)執(zhí)行腳本;
每個(gè)腳本依次在節(jié)點(diǎn)1和節(jié)點(diǎn)2上執(zhí)行:
執(zhí)行第二個(gè)腳本最后出現(xiàn)下圖結(jié)構(gòu)就說明執(zhí)行成功了:
執(zhí)行完腳本以后,這些往下執(zhí)行就可以:
當(dāng)我們執(zhí)行完成后,如上圖所示可能會(huì)報(bào)錯(cuò),不過經(jīng)過查看日志我們發(fā)現(xiàn)這個(gè)錯(cuò)沒關(guān)系,可以忽略;
檢查grid狀態(tài):---從下面的信息可以看到 我們安裝的沒有問題
[grid@rac121 ~]$crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....SM.lsnrora....er.type ONLINE ONLINE rac121
ora.DATA.dg ora....up.type ONLINE ONLINE rac121
ora....ER.lsnrora....er.type ONLINE ONLINE rac121
ora....AF.lsnrora....er.type OFFLINE OFFLINE
ora....N1.lsnrora....er.type ONLINE ONLINE rac121
ora.MGMTLSNR ora....nr.type ONLINE ONLINE rac121
ora.asm ora.asm.type ONLINE ONLINE rac121
ora.chad ora.chad.type ONLINE ONLINE rac121
ora.cvu ora.cvu.type ONLINE ONLINE rac121
ora.mgmtdb ora....db.type ONLINE ONLINE rac121
ora....networkora....rk.type ONLINE ONLINE rac121
ora.ons ora.ons.type ONLINE ONLINE rac121
ora.proxy_advmora....vm.type OFFLINE OFFLINE
ora.qosmserverora....er.type ONLINE ONLINE rac121
ora....21.lsnrapplication ONLINE ONLINE rac121
ora.rac121.onsapplication ONLINE ONLINE rac121
ora.rac121.vipora....t1.type ONLINE ONLINE rac121
ora....22.lsnrapplication ONLINE ONLINE rac122
ora.rac122.onsapplication ONLINE ONLINE rac122
ora.rac122.vipora....t1.type ONLINE ONLINE rac122
ora.scan1.vip ora....ip.type ONLINE ONLINE rac121
[grid@rac121 ~]$
4.3、使用grid用戶創(chuàng)建ASM磁盤組:
[grid@rac121 ~]$ /opt/12/grid/bin/asmca ---執(zhí)行命令
從上面的圖我們可以看到,我們需要的ASM磁盤組已經(jīng)創(chuàng)建好了,接著安裝Oracle軟件即可:
5、使用Oracle用戶開始,首先安裝Oracle軟件:
解壓軟件后開始安裝,如下圖所示:
安裝上圖的提示,執(zhí)行root.sh腳本即可,然后會(huì)看到下圖安裝成功的提示:
5.2、使用DBCA創(chuàng)建數(shù)據(jù)庫:
至此安裝步驟已經(jīng)完整了,就等著安裝完成就可以了,