###################################监听##################################
# RAC 的监听由 CRS 来控制,
ORACLE 推荐使用 srvctl 管理,动态注册监听已经在 CRS 那节配置完毕
# VIP 漂浮测试
#强制漂浮 VIP
su - grid -c "srvctl relocate vip -i rac
1-f"
su - grid -c "srvctl status listener"
#强制漂浮 SCAN-VIP 至
su - grid -c "srvctl relocate scan -i 1 -n rac
2"
su - grid -c "srvctl status scan"
#监听测试(
RAC 有两套监听,一套是每节点的 LISTENER,另外是 LISTENER_SCAN1,仅允许单点运行)
su - grid -c "srvctl status listener"
su - grid -c "srvctl status scan_listener"
su - grid -c "crsctl stat res -t
"
#下面是 ORACLE 实例的监听配置,适用于非 RAC 情况
#
图形
配置监听
#xhost + &&su - oracle -c "exportDISPLAY=
192.168.1.88:0.0 &&netca"
#图形
管理监听
#xhost + &&su - oracle -c "exportDISPLAY=
192.168.1.88:0.0 &&netmgr"
#
静默配置非 RAC 的静态监听(RAC 情况下,配置静态就会覆盖动态的监听)
cat >/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora << EOF
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
EOF
# 监听的检测su -oracle-c "lsnrctl start | stop | status | reload"
su - oracle -c "lsnrctl status listener"
#su - oracle -c "lsnrctl status listener_scan1"
#watch "ps -ef | grep tnslsnr| grep -v grep"
#watch "lsof -i:1521"
#watch "netstat -tlnp | grep 1521"
#
DBCA先决条件检查
su - oracle -c "cluvfystage-predbcfg-nrac1,rac2-d \$ORACLE_HOME"
xhost + &&su - oracle -c "exportDISPLAY=
192.168.1.88:0.0 &&dbca"
#静默DBCA 建库
su - oracle -c "dbca -silent -createDatabase
-
templateName General_Purpose.dbc
-
gdbNameorcl-sidrac-
sysPasswordsys-
systemPasswordsys
-
storageType ASM -asmsnmpPassword sys -
diskGroupName DATA -
recoveryGroupName FRA -nodelist rac1,rac2 -
characterSet AL32UTF8 -
nationalCharacterSet UTF8 -
sampleSchema true
"
#
-totalMemory1584
-emConfiguration CENTRAL -dbsnmpPassword sys
-sysmanPassword sys
"
#su - oracle -c "dbca -silent -deleteDatabase -sourceDB orcl -sysDBAUsername sys -sysDBAPassword sys"
#验证 数据库
/u01/app/11.2.0/grid/bin/srvctl config database -dorcl
#ps -ef | grep ora_ | grep -v grep | wc -l
#ps -ef | grep ora_ | grep -v grep | wc -l
#watch "ps -ef | grep ora_ | grep -v grep"
su - oracle -c "emca-configdbcontrol db -reposcreate"
su - oracle -c "emca-deconfigdbcontroldb-reposdrop"
su - oracle -c "emctl start | stop dbconsole"
ps -ef | grep emagent| grep -vemagent
https://scan-VIP:1158/em
###################################Node###################################
#修改IP
mv /etc/HOSTNAME /etc/HOSTNAME.bak
hostnamerac3
hostname > /etc/HOSTNAME
sysctl kernel.hostname=rac3
mv /etc/hosts /etc/hosts.bak
cat > /etc/hosts <<EOF
127.0.0.1 localhost
# Public IP(eth0)
192.168.1.91 rac1
192.168.1.92 rac2
192.168.1.96 rac3
# Public Virtual IP(eth0:1)
192.168.1.93 rac1-vip
192.168.1.94 rac2-vip
192.168.1.97 rac3-vip
# Private IP(eth1)
192.168.99.1 rac1-priv
192.168.99.2 rac2-priv
192.168.99.3 rac3-priv
192.168.99.3 rac3-priv
# Single Client Access Name Virtua IP(eth0:2)
192.168.1.95 rac-cluster-scan
EOF
#用户环境变量
echo '
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_TERM=xterm
export THREADS_FLAG=native
export ORACLE_SID=rac3
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=/usr/sbin:$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
#export DISPLAY=:0.0
export LANG=zh_CN.UTF-8
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
alias rrman="rlwrap rman target /"
' > /home/oracle/.bash_profile
echo '
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_TERM=xterm
export THREADS_FLAG=native
export ORACLE_SID=+ASM3
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export ORA_CRS_HOME=$ORACLE_HOME
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS11=$ORACLE_HOME/nls/data
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:$ORACLE_HOME/network/jlib
#export DISPLAY=:0.0
export LANG=zh_CN.UTF-8
export CVUQDISK GRP=oinstall
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
alias rasmcmd="rlwrap asmcmd"
alias rsqlplus="rlwrap sqlplus / as sysasm"
alias crs="watch crs_stat -t"
alias rsqlplus="rlwrap sqlplus / as sysasm"
alias crs="watch crs_stat -t"
' > /home/grid/.bash_profile
#磁盘管理(新增的 RAC 磁盘组必须和之前的节点共享,参看磁盘管理一节)
/grid/sshsetup/sshUserSetup.sh -user
grid-hosts "
rac1 rac2 rac3" -advanced -exverify -confirm -noPromptPassphrase
/grid/sshsetup/sshUserSetup.sh -user oracle -hosts "rac1 rac2 rac3" -advanced -exverify -confirm -noPromptPassphrase
# 传送
CRS
先决条件检查
su - grid -c 'cluvfy stage -pre nodeadd -n rac3 -verbose'
#传送GridInfrastructure 至 rac3(+CRS 磁盘组必须和之前节点是共享磁盘)
su - grid -c 'export IGNORE_PREADDNODE_CHECKS=Y && /u01/app/11.2.0/grid/oui/bin/addNode.sh "CLUSTER_NEW_NODES={rac3}
" "
CLUSTER_NEW_VIRTUAL_HOSTNAMES={rac3-vip}"'
#按照要求执行以下脚本
/u01/app/oraInventory/orainstRoot.sh #On nodes rac3
/u01/app/11.2.0/grid/root.sh #On nodes rac3
#验证 GI 安装状态
su - grid -c 'cluvfy comp clumgr -n all -verbose'
# GI 安装失败处理(参看 CRS 一节)
#传送ORACLE 数据库软件 至 rac3
su - oracle -c 'export IGNORE_PREADDNODE_CHECKS=Y && /u01/app/oracle/product/11.2.0/db_1/oui/bin/addNode.sh "CLUSTER_NEW_NODES={
rac3
}"'
#按照要求执行以下脚本
/u01/app/oracle/product/11.2.0/db_1/root.sh
# DBCA增加实例
su - oracle -c "dbca -silent -addInstance -nodeList rac3 -gdbName orcl -instanceName rac3 -sysDBAUserName sys -sysDBAPassword sys"
#
删除RAC 节点
#解除销钉 (任意节点运行)
/u01/app/11.2.0/grid/bin/crsctl unpin css -n rac3
#su - oracle -c "dbca -silent -deleteInstance -nodeList rac3 -gdbName orcl -instanceName rac3 -sysDBAUserName sys -sysDBAPassword sys"
#关闭 监听 和 节点联系(任意节点运行)
/u01/app/11.2.0/grid/bin/srvctl config listener -a
/u01/app/11.2.0/grid/bin/srvctl disable listener -n rac3
/u01/app/11.2.0/grid/bin/srvctl stop listener -n rac3
/u01/app/11.2.0/grid/bin/srvctl config nodeapps
/u01/app/11.2.0/grid/bin/srvctl disable nodeapps -n rac3
/u01/app/11.2.0/grid/bin/srvctl stop nodeapps -n rac3 -f
#在所需要删除的节点上更新集群列表
su - oracle -c '$ORACLE_HOME/oui/bin/runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={rac3}" -local'
su - grid -c '$ORACLE_HOME/oui/bin/runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={rac3}" CRS=true -local'
#删除所需要的节点信息
/u01/app/11.2.0/grid/bin/olsnodes -n -t -s
/u01/app/11.2.0/grid/bin/crsctl delete node -n rac3
#在主节点上运行更新集群列表
su - oracle -c '$ORACLE_HOME/oui/bin/runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={rac1,rac2}"'
su - grid -c '$ORACLE_HOME/oui/bin/runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={rac1,rac2}" CRS=true'
#删除节点 验证
/u01/app/11.2.0/grid/bin/srvctl config database -d orcl
su - grid -c "cluvfy stage -post nodedel -n rac3 -verbose"