red hat 7.4
oracle數(shù)據(jù)庫(kù)版本
11.2.0.4
oracle grid版本
11.2.0.4
對(duì)應(yīng)的文件
p13390677_112040_Linux-x86-64_1of7.zip - database software
p13390677_112040_Linux-x86-64_2of7.zip - database software
p13390677_112040_Linux-x86-64_3of7.zip - grid software
創(chuàng)新互聯(lián)建站為客戶提供專(zhuān)業(yè)的網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、程序、域名、空間一條龍服務(wù),提供基于WEB的系統(tǒng)開(kāi)發(fā). 服務(wù)項(xiàng)目涵蓋了網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站程序開(kāi)發(fā)、WEB系統(tǒng)開(kāi)發(fā)、微信二次開(kāi)發(fā)、成都手機(jī)網(wǎng)站制作等網(wǎng)站方面業(yè)務(wù)。
IP地址規(guī)劃:
DNS server:192.168.1.168
db node1:192.168.1.212 public
192.168.1.213 VIP
10.0.1.2 private
db node2:192.168.1.214 public
192.168.1.215 VIP
10.0.1.3 private
scan: 192.168.1.216
1、修改主機(jī)名稱(chēng):
vi /etc/hostname配置文件
或
hostnamectl set-hostname <計(jì)算機(jī)名>
A: redhat-212
B: redhat-214
2、動(dòng)態(tài)IP修改為靜態(tài)IP
cd /etc/sysconfig/network-scripts/
BOOTPROTO="static" #dhcp改為static
3、修改兩個(gè)rac節(jié)點(diǎn)網(wǎng)卡配置:
節(jié)點(diǎn)1:
cat /etc/sysconfig/network-scripts/ifcfg-ens192
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=2a2b7809-26ac-4fc6-95d0-124c7348171a
DEVICE=ens192
ONBOOT=yes
IPADDR=192.168.1.212
PREFIX=24
cat /etc/sysconfig/network-scripts/ifcfg-ens224
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens224
UUID=6da67cdc-933c-4bfe-a3b1-2896175be86b
DEVICE=ens224
ONBOOT=yes
IPADDR=10.0.1.2
PREFIX=24
節(jié)點(diǎn)2:
cat /etc/sysconfig/network-scripts/ifcfg-ens192
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=aeead365-1e33-41c3-b0e9-b147c4a2e688
DEVICE=ens192
ONBOOT=yes
IPADDR=10.0.1.3
PREFIX=24
cat /etc/sysconfig/network-scripts/ifcfg-ens224
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens224
UUID=e4fe8fed-6e97-43b4-aec6-80ce42588ead
DEVICE=ens224
ONBOOT=yes
IPADDR=192.168.1.214
PREFIX=24
#vim /etc/resolv.conf
nameserver 218.2.2.2
分別重啟一下網(wǎng)卡:
systemctl restart network.service
禁用該可預(yù)測(cè)命名規(guī)則。對(duì)于這一點(diǎn),你可以在啟動(dòng)時(shí)傳遞“net.ifnames=0 biosdevname=0 ”的內(nèi)核參數(shù)。這是通過(guò)編輯/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX變量來(lái)實(shí)現(xiàn)的。
cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap net.ifnames=0 biosdevname=0 rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
3、直接關(guān)閉防火墻
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開(kāi)機(jī)啟動(dòng)
4、關(guān)閉selinux
#vim /etc/selinux/config
修改文件
SELINUX=disabled
臨時(shí)關(guān)閉
#setenforce 0
5、內(nèi)部DNS解析兩個(gè)rac節(jié)點(diǎn):
NODE1:
vim /etc/hosts 127.0.0.1這一行修改一下名字racdb1,末尾添加如下:
127.0.0.1 racdb1 localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.216 cluster clusterscan
192.168.1.212 redhat-212
192.168.1.214 redhat-214
192.168.1.213 redhat-212-vip
192.168.1.215 redhat-214-vip
10.0.1.2 raca-priv
10.0.1.3 racb-priv
NODE2:
vim /etc/hosts 127.0.0.1這一行修改一下名字racdb2,末尾添加如下
127.0.0.1 racdb2 localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.216 cluster clusterscan
192.168.1.212 redhat-212
192.168.1.214 redhat-214
192.168.1.213 redhat-212-vip
192.168.1.215 redhat-214-vip
10.0.1.2 raca-priv
10.0.1.3 racb-priv
這個(gè)軟件挺好用的,在vmware環(huán)境下安裝,其實(shí)就是個(gè)linux系統(tǒng),我們創(chuàng)建vmdisk就行了。配置登陸一個(gè)網(wǎng)頁(yè)https://ip:446
在網(wǎng)絡(luò)存儲(chǔ)服務(wù)器 (openfiler1) 上執(zhí)行以下安裝。
在兩個(gè) Oracle RAC 節(jié)點(diǎn)上進(jìn)行網(wǎng)絡(luò)配置之后,下一步是將 Openfiler 軟件安裝到網(wǎng)絡(luò)存儲(chǔ)服務(wù)器 (openfiler1)。稍后會(huì)將網(wǎng)絡(luò)存儲(chǔ)服務(wù)器配置為 iSCSI 存儲(chǔ)設(shè)備,以滿足 Oracle Clusterware 和 Oracle RAC 的所有共享存儲(chǔ)需求。
安裝 Openfiler步驟可參考o(jì)racle官網(wǎng):
http://www.oracle.com/technetwork/cn/articles/hunter-rac11gr2-iscsi-083834-zhs.html
1、使用 Openfiler 配置 iSCSI 卷
OpenFiler設(shè)置 iSCSI / 邏輯卷卷名卷描述
racdb-crs1 racdb-ASM CRS Volume 1
racdb-crs2 racdb-ASM CRS Volume 2
racdb-crs3 racdb-ASM CRS Volume 3
racdb-data1 racdb-ASM Data Volume 1
racdb-data2 racdb-ASM Data Volume 2
racdb-data3 racdb-ASM Data Volume 3
racdb-fra1 racdb-ASM FRA Volume 1
racdb-fra2 racdb-ASM FRA Volume 2
racdb-fra3 racdb-ASM FRA Volume 3
2、ISCSI路徑名稱(chēng)命名
iqn.2006-01.com.openfiler:racdb.crs1
iqn.2006-01.com.openfiler:racdb.crs2
iqn.2006-01.com.openfiler:racdb.crs3
iqn.2006-01.com.openfiler:racdb.data1
iqn.2006-01.com.openfiler:racdb.data2
iqn.2006-01.com.openfiler:racdb.data3
iqn.2006-01.com.openfiler:racdb.fra1
iqn.2006-01.com.openfiler:racdb.fra2
iqn.2006-01.com.openfiler:racdb.fra3
3、兩個(gè)節(jié)點(diǎn)安裝iscsi客戶端
#yum install -y iscsi-initiator-utils
#systemctl start iscsid.service
#service iscsid start
4、設(shè)置iscsi客戶端開(kāi)機(jī)啟動(dòng)
systemctl enable iscsid.service
systemctl enable iscsi.service
5、查看服務(wù)狀態(tài)
#systemctl list-unit-files |grep iscsi*
iscsi-shutdown.service static
iscsi.service enabled
iscsid.service enabled
iscsiuio.service disabled
iscsid.socket enabled
iscsiuio.socket enabled
6、發(fā)現(xiàn)ISCSI服務(wù)端磁盤(pán)路徑
#iscsiadm -m discovery -t sendtargets -p openfiler1-priv 為你的openfiler的IP地址,我這里地址是10.0.1.100
#iscsiadm -m discovery -t sendtargets -p 10.0.1.100
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.fra3
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.fra2
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.fra1
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.data3
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.data2
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.data1
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.crs3
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.crs2
10.0.1.100:3260,1 iqn.2006-01.com.openfiler:racdb.crs1
7、每個(gè) Oracle RAC 節(jié)點(diǎn)都能夠從網(wǎng)絡(luò)存儲(chǔ)服務(wù)器中發(fā)現(xiàn)可用目標(biāo)。下一步是手動(dòng)登錄每個(gè)可用目標(biāo),這可以使用 iscsiadm 命令行接口完成。這需要在兩個(gè) Oracle RAC 節(jié)點(diǎn)上運(yùn)行。注意,我必須指定網(wǎng)絡(luò)存儲(chǔ)服務(wù)器的 IP 地址而非其主機(jī)名 (openfiler1-priv) — 我認(rèn)為必須這么做,因?yàn)樯鲜霭l(fā)現(xiàn)使用 IP 地址顯示目標(biāo)。
登陸ISCSI遠(yuǎn)程磁盤(pán)
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.crs1 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.crs2 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.crs3 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.data1 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.data2 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.data3 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.fra1 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.fra2 -p 10.0.1.100 -l
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.fra3 -p 10.0.1.100 -l
8、設(shè)置開(kāi)機(jī)啟動(dòng)自動(dòng)連接磁盤(pán)
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.crs1 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.crs2 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.crs3 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.data1 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.data2 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.data3 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.fra1 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.fra2 -p 10.0.1.100 --op update -n node.startup -v automatic
iscsiadm -m node -T iqn.2006-01.com.openfiler:racdb.fra3 -p 10.0.1.100 --op update -n node.startup -v automatic
9、查看遠(yuǎn)程磁盤(pán)路徑和關(guān)聯(lián)的磁盤(pán)路徑
#(cd /dev/disk/by-path; ls -l *openfiler* | awk '{FS=" "; print $9 " " $10 " " $11}')
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.crs1-lun-0 -> ../../sdc
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.crs2-lun-0 -> ../../sdd
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.crs3-lun-0 -> ../../sde
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.data1-lun-0 -> ../../sdf
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.data2-lun-0 -> ../../sdg
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.data3-lun-0 -> ../../sdh
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.fra1-lun-0 -> ../../sdi
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.fra2-lun-0 -> ../../sdj
ip-10.0.1.100:3260-iscsi-iqn.2006-01.com.openfiler:racdb.fra3-lun-0 -> ../../sdk
10、安裝udev設(shè)備管理器(rac_udev建立磁盤(pán)方式安裝grid)
#yum install -y udev
查看磁盤(pán)串號(hào)
-----------------------------------------------------------------------------------------------------------------
for disk in `ls /dev/sd*`
do
echo $disk
/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=$disk
done \\回車(chē)
-----------------------------------------------------------------------------------------------------------------
/dev/sda
/dev/sda1
/dev/sda2
/dev/sdb
/dev/sdb1
/dev/sdc
14f504e46494c45527763443337452d557347312d514f3049
/dev/sdd
14f504e46494c4552715837527a472d78444f522d6e6b5774
/dev/sde
14f504e46494c45523045727559352d706674422d43666c59
/dev/sdf
14f504e46494c455262664b78684c2d51796e512d30464179
/dev/sdg
14f504e46494c45526c36533367792d6a6265712d45705648
/dev/sdh
14f504e46494c45524159783651312d4a4554742d4f74776f
在兩個(gè) Oracle RAC 節(jié)點(diǎn):
映射關(guān)聯(lián)磁盤(pán)
#vim /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd?", ENV{ID_SERIAL}=="14f504e46494c45527763443337452d557347312d514f3049", SYMLINK+="asm_ocr_1_1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", ENV{ID_SERIAL}=="14f504e46494c4552715837527a472d78444f522d6e6b5774", SYMLINK+="asm_ocr_1_2", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", ENV{ID_SERIAL}=="14f504e46494c45523045727559352d706674422d43666c59", SYMLINK+="asm_data_1_1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", ENV{ID_SERIAL}=="14f504e46494c455262664b78684c2d51796e512d30464179", SYMLINK+="asm_data_1_2", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", ENV{ID_SERIAL}=="14f504e46494c45526c36533367792d6a6265712d45705648", SYMLINK+="asm_fra_1_1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?", ENV{ID_SERIAL}=="14f504e46494c45524159783651312d4a4554742d4f74776f", SYMLINK+="asm_fra_1_2", OWNER="grid", GROUP="asmadmin", MODE="0660"
加載rules文件(rac_udev建立磁盤(pán)方式安裝grid)
#udevadm control --reload-rules
#udevadm trigger
11、查看關(guān)聯(lián)路徑情況
#ls -l /dev/asm*
lrwxrwxrwx. 1 root root 3 12月 26 17:30 /dev/asm_data_1_1 -> sdf
lrwxrwxrwx. 1 root root 3 12月 26 17:30 /dev/asm_data_1_2 -> sdg
lrwxrwxrwx. 1 root root 3 12月 26 17:30 /dev/asm_fra_1_1 -> sdh
lrwxrwxrwx. 1 root root 3 12月 26 17:30 /dev/asm_fra_1_2 -> sdi
lrwxrwxrwx. 1 root root 3 12月 26 17:30 /dev/asm_ocr_1_1 -> sdc
lrwxrwxrwx. 1 root root 3 12月 26 17:30 /dev/asm_ocr_1_2 -> sdd
lrwxrwxrwx. 1 root root 3 1月 8 14:00 /dev/asm_ocr_1_3 -> sde
1、創(chuàng)建用戶:
groupadd -g 1000 oinstall
groupadd -g 1200 asmadmin
groupadd -g 1201 asmdba
groupadd -g 1202 asmoper
groupadd -g 1300 dba
groupadd -g 1301 oper
2、創(chuàng)建組:
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper grid
useradd -u 1101 -g oinstall -G dba,oper,asmdba oracle
3、創(chuàng)建密碼:
passwd grid
passwd oracle
4、設(shè)置互信關(guān)系,這里記住oracle和grid用戶都要設(shè)置互信
#su - grid
$ mkdir ~/.ssh(有則不創(chuàng)建)
兩個(gè)節(jié)點(diǎn)執(zhí)行以下操作
ssh-keygen -t rsa
ssh-keygen -t dsa
這里一步一步直接回車(chē)的
以下操作在一個(gè)節(jié)點(diǎn)上執(zhí)行即可(id_rsa是密鑰,id_rsa.pub是公鑰)
cat ~/.ssh/id_rsa.pub >> ./.ssh/authorized_keys --公鑰存在authorized_keys文件中,寫(xiě)到本機(jī)
cat ~/.ssh/id_dsa.pub >> ./.ssh/authorized_keys
ssh redhat-214 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys --第二個(gè)節(jié)點(diǎn)的公鑰寫(xiě)到本機(jī)
ssh redhat-214 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys secdb2:~/.ssh/authorized_keys
兩個(gè)節(jié)點(diǎn)上分別驗(yàn)證
ssh redhat-212 date
ssh redhat-214 date
ssh raca-priv date
ssh racb-priv date
#su - oracle
兩個(gè)節(jié)點(diǎn)執(zhí)行以下操作:
ssh-keygen -t rsa
ssh-keygen -t dsa
以下操作在一個(gè)節(jié)點(diǎn)上執(zhí)行即可
cat ~/.ssh/id_rsa.pub >> ./.ssh/authorized_keys --公鑰存在authorized_keys文件中,寫(xiě)到本機(jī)
cat ~/.ssh/id_dsa.pub >> ./.ssh/authorized_keys
ssh redhat-214 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys --第二個(gè)節(jié)點(diǎn)的公鑰寫(xiě)到本機(jī)
ssh redhat-214 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys redhat-214:~/.ssh/authorized_keys --上傳本機(jī)公鑰到第二個(gè)節(jié)點(diǎn)管理
兩個(gè)節(jié)點(diǎn)上分別驗(yàn)證
ssh redhat-212 date
ssh redhat-214 date
ssh raca-priv date
ssh racb-priv date
5、為grid用戶設(shè)置環(huán)境變量
如下操作也需要在兩個(gè)節(jié)點(diǎn)上同樣進(jìn)行,這里需要注意的是grid用戶的SID和oracle用戶的SID,是不一樣的,這里大家明白原理的話就不會(huì)出錯(cuò)。
以 grid 用戶帳戶分別登錄到兩個(gè) Oracle RAC 節(jié)點(diǎn)并創(chuàng)建以下登錄腳本 (.bash_profile):
注: 在為每個(gè) Oracle RAC 節(jié)點(diǎn)設(shè)置 Oracle 環(huán)境變量時(shí),確保為每個(gè) RAC 節(jié)點(diǎn)指定唯一的 Oracle SID。對(duì)于此示例,我使用:
racnode1:ORACLE_SID=+ASM1
racnode2:ORACLE_SID=+ASM2
Node1:
[root@racnode1 ~]# su - grid
vi .bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/grid
export ORACLE_HOME=/u01/app/grid/11.2.0
export NLS_DATE_FORMAT='yyyy/mm/dd hh34:mi:ss'
export TNS_ADMIN=$ORACLE_HOME/network/admin
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
export LANG=en_US
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
umask 022
Node2:
#su - grid
vi .bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM2
export ORACLE_BASE=/u01/grid
export ORACLE_HOME=/u01/app/grid/11.2.0
export NLS_DATE_FORMAT='yyyy/mm/dd hh34:mi:ss'
export TNS_ADMIN=$ORACLE_HOME/network/admin
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
export LANG=en_US
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
umask 022
6、為 oracle 用戶設(shè)置環(huán)境變量
以 oracle 用戶帳戶分別登錄到兩個(gè) Oracle RAC 節(jié)點(diǎn)并創(chuàng)建以下登錄腳本 (.bash_profile):
注: 在為每個(gè) Oracle RAC 節(jié)點(diǎn)設(shè)置 Oracle 環(huán)境變量時(shí),確保為每個(gè) RAC 節(jié)點(diǎn)指定唯一的 Oracle SID。對(duì)于此示例,我使用:
racnode1:ORACLE_SID=orcl1
racnode2:ORACLE_SID=orcl2
#su - oracle
vi .bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=rac1
export ORACLE_SID=orcl1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_UNQNAME=orcl
export TNS_ADMIN=$ORACLE_HOME/network/admin
#export ORACLE_TERM=xterm
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
export LANG=en_US
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_DATE_FORMAT='yyyy/mm/dd hh34:mi:ss'
umask 022
Node2:
#su - oracle
vi .bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=rac2
export ORACLE_SID=orcl2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_UNQNAME=orcl
export TNS_ADMIN=$ORACLE_HOME/network/admin
#export ORACLE_TERM=xterm
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
export LANG=en_US
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_DATE_FORMAT='yyyy/mm/dd hh34:mi:ss'
umask 022
7、創(chuàng)建 Oracle 基目錄路徑
最后一步是配置 Oracle 基路徑,要遵循最佳靈活體系結(jié)構(gòu) (OFA) 的結(jié)構(gòu)及正確的權(quán)限。需要以 root 用戶身份在集群的兩個(gè) Oracle RAC 節(jié)點(diǎn)上完成此任務(wù)。
本指南假設(shè)在根文件系統(tǒng)中創(chuàng)建 /u01 目錄。請(qǐng)注意,這樣做是為了簡(jiǎn)便起見(jiàn),不建議將其作為通用做法。通常會(huì)將 /u01 目錄作為配置了硬件或軟件鏡像功能的單獨(dú)文件系統(tǒng)供應(yīng)。
#mkdir -p /u01/grid
#mkdir -p /u01/app/grid/11.2.0
#chown -R grid:oinstall /u01
#mkdir -p /u01/app/oracle
#chown oracle:oinstall /u01/app/oracle
#chmod -R 775 /u01
8、為 Oracle 軟件安裝用戶設(shè)置資源限制:
8.1 在每個(gè) Oracle RAC 節(jié)點(diǎn)上,在 /etc/security/limits.conf 文件中添加以下幾行代碼(下面的示例顯示軟件帳戶所有者 oracle 和 grid):
#vi /etc/security/limits.conf
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
或下面加了stack最大棧大小,一般我使用都是上面多些
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
8.2 在每個(gè) Oracle RAC 節(jié)點(diǎn)上,在 /etc/pam.d/login 文件中添加或編輯下面一行內(nèi)容(如果不存在此行):
#vi /etc/pam.d/login
session required pam_limits.so
8.3 修改內(nèi)核參數(shù)
#vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
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 = 1048576
使sysctl生效
#sysctl -p
8.3 安裝相關(guān)的開(kāi)發(fā)工具包
#yum -y install glibc \
glibc-devel \
glibc-headers \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
sysstat \
unixODBC \
unixODBC-devel \
pdksh \
compat-libcap1 \
compat-libstdc++-33 \
elfutils-libelf-devel \
gcc \
gcc-c++ \
smartmontools \
pdksh \
compat-libstdc \
cvuqdisk
9、RHEL 7 安裝oracle rac 11.2.0.4執(zhí)行root.sh報(bào)錯(cuò)ohasd failed to start
報(bào)錯(cuò)原因:
因?yàn)镽HEL 7使用systemd而不是initd運(yùn)行進(jìn)程和重啟進(jìn)程,而root.sh通過(guò)傳統(tǒng)的initd運(yùn)行ohasd進(jìn)程。
9.1、 解決方法:
在RHEL 7中ohasd需要被設(shè)置為一個(gè)服務(wù),在運(yùn)行腳本root.sh之前。
以root用戶創(chuàng)建服務(wù)文件
#touch /usr/lib/systemd/system/ohas.service
#chmod 777 /usr/lib/systemd/system/ohas.service
9.2、 將以下內(nèi)容添加到新創(chuàng)建的ohas.service文件中
#vim /usr/lib/systemd/system/ohas.service
[Unit]
Description=Oracle High Availability Services
After=syslog.target
[Service]
ExecStart=/etc/init.d/init.ohasd run >/dev/null 2>&1 Type=simple
Restart=always
[Install]
WantedBy=multi-user.target
9.3、以root用戶運(yùn)行下面的命令
#systemctl daemon-reload
#systemctl enable ohas.service
#systemctl start ohas.service
9.4、查看運(yùn)行狀態(tài)
#systemctl status ohas.service
1、連接操作中的 Xmanager
#su - grid
$ cd /home/grid/
$ unzip p13390677_112040_Linux-x86-64_3of7.zip
#yum install xhost + -y
#su - grid
$ export DISPLAY=ip:0.0 //ip為你本機(jī)ip
$ xhost +
$ export LANG=en_US
$ ./runInstaller
若需要添加中文語(yǔ)言包
#mkdir -p /usr/share/fonts/zh_CN/TrueType
將zysong.ttf文件放至/usr/share/fonts/zh_CN/TrueType目錄中
2、安裝截圖
出來(lái)下面安裝界面,選擇最下面的Skip software updates,然后選next
選擇第一個(gè)安裝和配置集群環(huán)境,next
選擇第二個(gè)高級(jí)安裝,next
選上添加簡(jiǎn)體中文,next
此處集群名自己取,SCAN名需要和/etc/hosts中的scan ip別名一致,端口默認(rèn),不選GNS,next
添加busrac2節(jié)點(diǎn)
點(diǎn)next(上面設(shè)置互信關(guān)系一定執(zhí)行過(guò),不然這一步如果next會(huì)出錯(cuò)的)
或如果沒(méi)有設(shè)置互信關(guān)系的話可以點(diǎn)SSH Connectivity,輸入grid用戶的密碼(注兩點(diǎn)節(jié)點(diǎn)grid用戶與密碼要一致),在點(diǎn)setup,最后next
這里只需要確認(rèn)一下網(wǎng)絡(luò)接口,安裝向?qū)б呀?jīng)把我們填寫(xiě),next(這里是自動(dòng)識(shí)別到你服務(wù)器上IP是哪段的)
存儲(chǔ)選擇:選擇ASM,next
這里讓我們創(chuàng)建asm disk group,給一個(gè)名字“ORC",建立OCR盤(pán),選擇3塊盤(pán) next(這里要求至少3塊盤(pán)的,這里圖片只是參考的;有時(shí)候會(huì)找不到盤(pán),可以試重新執(zhí)行加載rules文件(rac_udev建立磁盤(pán)方式安裝grid))
設(shè)置密碼:next
這里選擇第二項(xiàng)不使用IPMI
給ASM指定不同的組,next
這里安裝向?qū)?huì)幫你填寫(xiě)集群軟件的安裝路徑,我們繼續(xù)next,這里我們需要注意的是oracle_Home不能是oracle_base的子目錄
以root身份執(zhí)行腳本:root用戶執(zhí)行兩個(gè)腳本,一個(gè)節(jié)點(diǎn)執(zhí)行完后再執(zhí)行第二個(gè)節(jié)點(diǎn)(root.sh執(zhí)行可能會(huì)長(zhǎng)一點(diǎn))
我們會(huì)看到這個(gè)報(bào)錯(cuò),其實(shí)這個(gè)問(wèn)題我查看了mos知識(shí)庫(kù),說(shuō)的比較含糊,可以忽略這個(gè)錯(cuò)誤,不影響我們的安裝和未來(lái)的使用
直接finish了,這里我們集群軟件安裝完成。
#su - oracle
$ export DISPLAY=ip:0.0 //ip為你本機(jī)ip
$ xhost +
$ export LANG=en_US
$ cd database
$ ./runInstaller
在解壓database運(yùn)行安裝腳本,這里和安裝grid一樣,啟動(dòng)安裝向?qū)?br/>我們不填寫(xiě)mos賬號(hào),又不聯(lián)網(wǎng)沒(méi)意義,點(diǎn)擊next,這里我們還是在rac1節(jié)點(diǎn)上安裝
我們這里只安裝數(shù)據(jù)庫(kù)軟件,點(diǎn)擊next
這里選擇集群安裝方式,有以下3種選項(xiàng)之一:
Single instance database installation(單實(shí)例數(shù)據(jù)庫(kù)安裝) 這一選項(xiàng)允許僅在本地節(jié)點(diǎn)上安裝單實(shí)例數(shù)據(jù)庫(kù)軟件。
Oracle Real Application Cluster database installation(Oracle RAC數(shù)據(jù)庫(kù)安裝) 這一選項(xiàng)允許在集群中的選定節(jié)點(diǎn)上選擇和安裝Oracle RAC二進(jìn)制文件。
Oracle RAC One Node database installation 這個(gè)選項(xiàng)在選定節(jié)點(diǎn)上安裝Oracle RAC One Node數(shù)據(jù)庫(kù)二進(jìn)制文件。
在這個(gè)界面上,選擇Oracle Real Application Cluster database installation選項(xiàng)。
選擇“select All”,點(diǎn)擊next
還是選擇語(yǔ)言為”English/Simplified Chinese“,點(diǎn)擊next
選擇”Enterprise Edition“ 點(diǎn)擊”next“
這里是oracle_base和oracle_home,點(diǎn)擊next
這個(gè)對(duì)應(yīng)到組就可以了,繼續(xù)next
這一步會(huì)check你的安裝環(huán)境,我們只要配置參數(shù)正確就沒(méi)問(wèn)題,這里基本上都是succeeded,點(diǎn)擊next(導(dǎo)致這個(gè)錯(cuò)誤的原因是在/etc/hosts中配置了SCAN的地址,嘗試ping這個(gè)地址信息,如果可以成功,則這個(gè)錯(cuò)誤可以忽略。我嘗試ping scan ip可以ping通,所以暫時(shí)也就忽略了這個(gè)錯(cuò)誤。)
summary一下,我們就可以'install'了
這里安裝會(huì)比較快
出現(xiàn)如下錯(cuò)誤
查看日志報(bào)錯(cuò)如下:
#vi /u01/oraInventory/logs/installActions2018-01-10_02-56-55PM.log
INFO: collect2: error: ld returned 1 exit status
INFO: make[1]: *** [/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/emdctl] Error 1
INFO: make[1]: Leaving directory `/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib'
INFO: make: *** [emdctl] Error 2
INFO: End output from spawned process.
INFO: ----------------------------------
INFO: Exception thrown from action: make
Exception Name: MakefileException
Exception String: Error in invoking target 'agent nmhs' of makefile '/u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk'. See '/u01/oraInventory/logs/installActions2018-01-10_02-56-55PM.log' for details.
Exception Severity: 1
解決方法:
vi $ORACLE_HOME/sysman/lib/ins_emagent.mk
$vi /u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk
搜索以下行:
$(MK_EMAGENT_NMECTL)
改變?yōu)椋?$(MK_EMAGENT_NMECTL) -lnnz11
然后點(diǎn)擊:retry,可以。
完成后同樣也要執(zhí)行一個(gè)腳本,也是要在root用戶下去執(zhí)行,分別兩個(gè)節(jié)點(diǎn)上
至此數(shù)據(jù)庫(kù)軟件已安裝完成。
1、在安裝GI集群軟件的時(shí)候我們就配置過(guò)asm磁盤(pán),現(xiàn)在我們還有一個(gè)disk分區(qū)沒(méi)有加入到asm磁盤(pán)組中,我們通過(guò)asmca來(lái)實(shí)現(xiàn)
$ su - grid
$ export DISPLAY=ip:0.0
運(yùn)行命令asmca,我們看到下面配置向?qū)А_@里可以看到我們之前配置過(guò)的disk group,我們點(diǎn)擊create后
來(lái)到這里,我們給disk group起個(gè)名字,選擇redundancy Normal,勾選data_1_1和data_1_2,我們ok一下
會(huì)有一個(gè)10秒的等待創(chuàng)建磁盤(pán)組,完成后提示成功
選擇redundancy Normal,勾選fra_1_1和fra_1_2,我們ok一下
這里我們就能看到有三個(gè)disk group了!??!退出即可。。
我們直接su - oracle,運(yùn)行dbca命令來(lái)配置數(shù)據(jù)庫(kù)
$ export DISPLAY=IP:0.0
$ export LANG=en_US
$ dbca
來(lái)到如下界面后,我們選擇第一項(xiàng)集群模式,然后next
這個(gè)就不用考慮了,直接選擇create a database,繼續(xù)next
這個(gè)也是選擇general purpose,繼續(xù)next
配置類(lèi)型選擇admin-managed,Global database name和sid相同為test,最下面我們選擇”select all“,然后next
這里我們還是選擇默認(rèn)推薦的配置,EM和amt都選擇配置,繼續(xù)next
把sys、system、dbsnmp都給一個(gè)相同的密碼,這里你自己給吧!!然后next
這里我們選擇用存儲(chǔ)類(lèi)型為asm,使用omf管理數(shù)據(jù)文件(這里的名字是存放數(shù)據(jù)數(shù)據(jù)文件路徑名字,自定義)。
我安裝數(shù)據(jù)庫(kù)勾選OEM的時(shí)候,這個(gè)地方就要輸入ASMSNMP密碼的,設(shè)置好后點(diǎn)ok
這里選擇閃回恢復(fù)區(qū),看個(gè)人情況
或是我們這里不選擇閃回恢復(fù)區(qū),我這里就不配置了,以后手動(dòng)改spfile吧??!
不選擇裝sample schemas
或是裝上sample schemas,以后就有數(shù)據(jù)可以測(cè)試玩一把了??! 繼續(xù)next
這里我們字符集會(huì)有所設(shè)置,ZHS16GBK-GBK,國(guó)際字符集默認(rèn)的就行。其它的選項(xiàng)卡沒(méi)有特殊配置,在以后都可以去改spfile,我們繼續(xù)next
這個(gè)是數(shù)據(jù)庫(kù)的存儲(chǔ)配置頁(yè)面,我們看一下控制文件等等都要開(kāi)始安裝了,next
繼續(xù)finish
等待吧,這個(gè)也是比較久的,如果SSD和cpu比較給力,速度基本上10分鐘吧!!
安裝完后,點(diǎn)擊exit
我們就退出安裝配置向?qū)Я耍。。?/p>
1、檢查crs資源狀態(tài)
[grid@redhat212 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATADB.dg ora....up.type ONLINE ONLINE redhat212
ora.FRA.dg ora....up.type ONLINE ONLINE redhat212
ora....ER.lsnr ora....er.type ONLINE ONLINE redhat212
ora....N1.lsnr ora....er.type ONLINE ONLINE redhat212
ora.ORC.dg ora....up.type ONLINE ONLINE redhat212
ora.asm ora.asm.type ONLINE ONLINE redhat212
ora.cvu ora.cvu.type ONLINE ONLINE redhat212
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE redhat212
ora.oc4j ora.oc4j.type ONLINE ONLINE redhat212
ora.ons ora.ons.type ONLINE ONLINE redhat212
ora.orcl.db ora....se.type ONLINE ONLINE redhat212
ora....SM1.asm application ONLINE ONLINE redhat212
ora....12.lsnr application ONLINE ONLINE redhat212
ora....212.gsd application OFFLINE OFFLINE
ora....212.ons application ONLINE ONLINE redhat212
ora....212.vip ora....t1.type ONLINE ONLINE redhat212
ora....SM2.asm application ONLINE ONLINE redhat214
ora....14.lsnr application ONLINE ONLINE redhat214
ora....214.gsd application OFFLINE OFFLINE
ora....214.ons application ONLINE ONLINE redhat214
ora....214.vip ora....t1.type ONLINE ONLINE redhat214
ora.scan1.vip ora....ip.type ONLINE ONLINE redhat212
我們看到ora.gsd、ora.214(RAC2).gsd是offline狀態(tài),其實(shí)兩個(gè)進(jìn)程對(duì)我們的數(shù)據(jù)庫(kù)是沒(méi)有任何影響的,我們把他們打開(kāi)就行了
2、查看節(jié)點(diǎn)的狀態(tài)
[grid@redhat212 ~]$ srvctl status nodeapps -n redhat212
VIP redhat212-vip is enabled
VIP redhat212-vip is running on node: redhat212
Network is enabled
Network is running on node: redhat212
GSD is disabled
GSD is not running on node: redhat212
ONS is enabled
ONS daemon is running on node: redhat212
3、開(kāi)啟節(jié)點(diǎn)
[grid@redhat212 ~]$ srvctl enable nodeapps
PRKO-2415 : VIP is already enabled on node(s): redhat212,redhat214
PRKO-2416 : Network resource is already enabled.
PRKO-2417 : ONS is already enabled on node(s): redhat212,redhat214
開(kāi)節(jié)點(diǎn)后在查看節(jié)點(diǎn)應(yīng)用程序狀態(tài)
[grid@redhat212 ~]$ srvctl status nodeapps
VIP redhat212-vip is enabled
VIP redhat212-vip is running on node: redhat212
VIP redhat214-vip is enabled
VIP redhat214-vip is running on node: redhat214
Network is enabled
Network is running on node: redhat212
Network is running on node: redhat214
GSD is enabled
GSD is not running on node: redhat212
GSD is not running on node: redhat214
ONS is enabled
ONS daemon is running on node: redhat212
ONS daemon is running on node: redhat214
4、啟動(dòng)節(jié)點(diǎn)
$ srvctl start nodeapps
PRKO-2421 : Network resource is already started on node(s): redhat212,redhat214
PRKO-2420 : VIP is already started on node(s): redhat212
PRKO-2420 : VIP is already started on node(s): redhat214
PRKO-2422 : ONS is already started on node(s): redhat212,redhat214
5、我們?cè)趤?lái)查看一下所有的組件是否online
$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATADB.dg ora....up.type ONLINE ONLINE redhat212
ora.FRA.dg ora....up.type ONLINE ONLINE redhat212
ora....ER.lsnr ora....er.type ONLINE ONLINE redhat212
ora....N1.lsnr ora....er.type ONLINE ONLINE redhat212
ora.ORC.dg ora....up.type ONLINE ONLINE redhat212
ora.asm ora.asm.type ONLINE ONLINE redhat212
ora.cvu ora.cvu.type ONLINE ONLINE redhat212
ora.gsd ora.gsd.type ONLINE ONLINE redhat212
ora....network ora....rk.type ONLINE ONLINE redhat212
ora.oc4j ora.oc4j.type ONLINE ONLINE redhat212
ora.ons ora.ons.type ONLINE ONLINE redhat212
ora.orcl.db ora....se.type ONLINE ONLINE redhat212
ora....SM1.asm application ONLINE ONLINE redhat212
ora....12.lsnr application ONLINE ONLINE redhat212
ora....212.gsd application ONLINE ONLINE redhat212
ora....212.ons application ONLINE ONLINE redhat212
ora....212.vip ora....t1.type ONLINE ONLINE redhat212
ora....SM2.asm application ONLINE ONLINE redhat214
ora....14.lsnr application ONLINE ONLINE redhat214
ora....214.gsd application ONLINE ONLINE redhat214
ora....214.ons application ONLINE ONLINE redhat214
ora....214.vip ora....t1.type ONLINE ONLINE redhat214
ora.scan1.vip ora....ip.type ONLINE ONLINE redhat212
我們這里安裝完畢!??!
grid和oracle用戶都可以執(zhí)行,在其中一個(gè)節(jié)點(diǎn)執(zhí)行即可:
1、RAC監(jiān)聽(tīng)啟停:
$ srvctl status listener #檢查T(mén)NS listener的狀態(tài)
$ srvctl config listener -a #檢查T(mén)NS listener的配置
$ srvctl start listener #開(kāi)啟監(jiān)聽(tīng)
$ srvctl stop listener #停掉監(jiān)聽(tīng)
$ srvctl stop listener -n redhat212 #停掉指定節(jié)點(diǎn)監(jiān)聽(tīng)
$ srvctl start listener -n redhat212 #啟動(dòng)指定節(jié)點(diǎn)監(jiān)聽(tīng)
例子:
RAC啟動(dòng)數(shù)據(jù)庫(kù)監(jiān)聽(tīng),進(jìn)入grid用戶來(lái)啟停端口
#su - grid
$ srvctl start|stop|status listener
2、RAC啟停數(shù)據(jù)庫(kù):
srvctl status database -d RAC # 檢查數(shù)據(jù)庫(kù)的狀態(tài)
srvctl status instance -d RAC -i rac1 #檢查指定實(shí)例的狀態(tài)
srvctl start database -d orcl # 啟動(dòng)數(shù)據(jù)庫(kù)
srvctl stop database -d orcl # 關(guān)閉數(shù)據(jù)庫(kù)
srvctl start instance -d orcl -i orcl1 # 啟動(dòng)指定的實(shí)例
srvctl stop instance -d orcl -i orcl2 # 關(guān)閉指定實(shí)例
例子:在nodes1上關(guān)閉一個(gè)實(shí)例,分別查看兩個(gè)節(jié)點(diǎn)狀態(tài)
或下面方式
RAC啟動(dòng)數(shù)據(jù)庫(kù),進(jìn)入oracle用戶
#su - oracle
$ sqlplus sys/**** as sysdba
SQL> select status from v$instance; //查看數(shù)據(jù)庫(kù)狀態(tài)
SQL>startup; //啟動(dòng)數(shù)據(jù)庫(kù)
SQL>shutdown immediate; //停數(shù)據(jù)庫(kù)
ssh root 進(jìn)入 192.168.1.212
su - oracle
source .bash_profile
sqlplus /nolog
connect /as sysdba
創(chuàng)建表空間:
SQL>CREATE SMALLFILE TABLESPACE "TEST" DATAFILE '+DATADB/ORCL/DATAFILE/test001.dbf' SIZE 1024M AUTOEXTEND ON NEXT 500M MAXSIZE UNLIMITED LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
添加TEST表空間中的存儲(chǔ)test001.dbf文件在ASM的+DATADB/ORCL/DATAFILE/目錄下,初始大小為1G,自動(dòng)500MB擴(kuò)展不做限制。
增加表空間:
alter tablespace CP_TM add datafile '+DATADB/orcl/datafile/cp_tm_08.dbf' size 20480M; RAC方式給CP_TM表空間增加cp_tm_08.dbf數(shù)據(jù)文件大小為20G。
alter tablespace CP_TM add datafile +DATADB/orcl/datafile/cp_tm_09.dbf' size 10240M autoextend on next 50m maxsize 20480;
RAC增加表空間cp_tm_-09.dbf初始為10G,按50M增加最大到20G。
集群信息grid和oracle用戶都可以執(zhí)行
10.1、數(shù)據(jù)庫(kù)與實(shí)例:
列出所有的配置數(shù)據(jù)庫(kù)
$ srvctl config database
檢查數(shù)據(jù)庫(kù)相關(guān)的信息 (-d參數(shù)后面是您server_name)
$ srvctl config database -d orcl -a
或
$ srvctl config database -d orcl -t
srvctl status database -d RAC # 檢查數(shù)據(jù)庫(kù)的狀態(tài)
srvctl status instance -d RAC -i rac1 #檢查指定實(shí)例的狀態(tài)
srvctl start database -d rac # 啟動(dòng)數(shù)據(jù)庫(kù)
srvctl stop database -d rac # 關(guān)閉數(shù)據(jù)庫(kù)
srvctl start instance -d rac -i rac1 # 啟動(dòng)指定的實(shí)例
srvctl stop instance -d rac -i rac2 # 關(guān)閉指定實(shí)例
ASM狀態(tài)
$ srvctl status asm
ASM配置
$ srvctl status asm -a
10.2、網(wǎng)絡(luò)相關(guān)的命令
TNS監(jiān)聽(tīng)器狀態(tài)以及配置
$ srvctl status listener #檢查T(mén)NS listener的狀態(tài)
$ srvctl config listener -a #檢查T(mén)NS listener的配置
$ srvctl start listener #開(kāi)啟監(jiān)聽(tīng)
$ srvctl stop listener #停掉監(jiān)聽(tīng)
$ srvctl stop listener -n redhat212 #停掉指定節(jié)點(diǎn)監(jiān)聽(tīng)
$ srvctl start listener -n redhat212 #啟動(dòng)指定節(jié)點(diǎn)監(jiān)聽(tīng)
SRVCTL的參數(shù)-n 實(shí)例節(jié)點(diǎn)名,不是實(shí)例sid
查看某個(gè)節(jié)點(diǎn)ASM信息
srvctl config listener -n node2
SCAN狀態(tài)以及配置
$ srvctl status scan
$ srvctl config scan
VIP各個(gè)節(jié)點(diǎn)的狀態(tài)以及配置
$ srvctl status vip -n rac1
$ srvctl status vip -n rac2
$ srvctl config vip -n rac1
$ srvctl config vip -n rac2
節(jié)點(diǎn)應(yīng)用程序配置(VIP、GSD、ONS、監(jiān)聽(tīng)器)
$ srvctl config nodeapps -a -g-s -l
10.3、查看集群狀態(tài)(nodeapps節(jié)點(diǎn)應(yīng)用程序,ASM實(shí)例,數(shù)據(jù)庫(kù)等)
$ crs_stat -t
狀態(tài)檢查也可以使用如下命令:
crsctl stat resource –t 或者 crsctl stat resource
這里還要強(qiáng)調(diào)一下11.2.0.1版本的一個(gè)bug,就是客戶端無(wú)法通過(guò)scan連接到數(shù)據(jù)庫(kù)解決方法如下:
[oracle@redhat212 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 19 11:29:58 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> show parameter local_listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=redhat212
-vip)(PORT=1521))))
SQL> show parameter remot_listener;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_dependencies_mode string TIMESTAMP
remote_listener string clusterscan:1521
remote_login_passwordfile string EXCLUSIVE
remote_os_authent boolean FALSE
remote_os_roles boolean FALSE
result_cache_remote_expiration integer 0
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.216)(PORT = 1521))))' sid='orcl1';
System altered.
SQL> alter system set remote_listener='clusterscan:1521';
System altered.
SQL> alter system register;
System altered.
最后配置客戶端tnsname.ora文件指向scan listener
#tnsnames.ora.rac1 Network Configuration File: /u01/app/11.2.0/grid/network/admin/tnsnames.ora.rac1
#Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.216)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)