通过之前的三篇文章的所有步骤,集群就搭建成功了。
查看listener状态, lsnrctl status
[oracle@rac1 database]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-JUL-2018 13:25:12
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 19-JUL-2018 13:13:21
Uptime 0 days 0 hr. 11 min. 51 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid_home/network/admin/listener.ora
Listener Log File /u01/app/grid_base/diag/tnslsnr/rac1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.101)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.103)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "OAODZ" has 1 instance(s).
Instance "oaodz11", status READY, has 1 handler(s) for this service...
Service "oaodz1XDB" has 1 instance(s).
Instance "oaodz11", status READY, has 1 handler(s) for this service...
The command completed successfully
查看集群状态,里面有一些服务是offline,后面的步骤会把他们起来,最后一行可以看到限制scan-ip是绑定到rac1上面的
[grid@rac1 bin]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora.DATA.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
ora....ER.lsnr ora....er.type 0/5 0/ ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac1
ora.OCR.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE rac1
ora.eons ora.eons.type 0/3 0/ ONLINE ONLINE rac1
ora.gsd ora.gsd.type 0/5 0/ OFFLINE OFFLINE
ora....network ora....rk.type 0/5 0/ ONLINE ONLINE rac1
ora.oaodz.db ora....se.type 0/2 0/1 ONLINE ONLINE rac1
ora.oc4j ora.oc4j.type 0/5 0/0 OFFLINE OFFLINE
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE rac1
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.gsd application 0/5 0/0 OFFLINE OFFLINE
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.gsd application 0/5 0/0 OFFLINE OFFLINE
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac2
ora.scan1.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac1
启动停止的服务
#启动oc4j服务
[grid@rac1 bin]$ srvctl enable oc4j
[grid@rac1 bin]$ srvctl start oc4j
#启动gsd服务
[grid@rac1 bin]$ srvctl enable nodeapps
[grid@rac1 bin]$ srvctl start nodeapps
#所有服务都起来了
[grid@rac1 bin]$ crs_stat -v -t
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora.DATA.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
ora....ER.lsnr ora....er.type 0/5 0/ ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac1
ora.OCR.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE rac1
ora.eons ora.eons.type 0/3 0/ ONLINE ONLINE rac1
ora.gsd ora.gsd.type 0/5 0/ ONLINE ONLINE rac1
ora....network ora....rk.type 0/5 0/ ONLINE ONLINE rac1
ora.oaodz.db ora....se.type 0/2 0/1 ONLINE ONLINE rac1
ora.oc4j ora.oc4j.type 0/5 0/0 ONLINE ONLINE rac2
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE rac1
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac2
ora.scan1.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac1
通过scan-ip连接数据库
[oracle@rac1 database]$ ping scan-ip
PING scan-ip (10.10.10.105) 56(84) bytes of data.
64 bytes from scan-ip (10.10.10.105): icmp_seq=1 ttl=64 time=0.017 ms
64 bytes from scan-ip (10.10.10.105): icmp_seq=2 ttl=64 time=0.040 ms
64 bytes from scan-ip (10.10.10.105): icmp_seq=3 ttl=64 time=0.032 ms
[oracle@rac1 database]$ sqlplus sys/Capgemini123@scan-ip/OAODZ as sysdba;
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 19 13:38:33 2018
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> select sysdate from dual;
SYSDATE
-------------------
2018-07-19 13:38:58
SQL>
集群起停
###集群起停
##停止集群,下面的命令有些服务停步掉是正常的,通过crsctl 停止
[grid@rac1 bin]$ crs_stop -all
Attempting to stop `ora.ons` on member `rac2`
Attempting to stop `ora.LISTENER.lsnr` on member `rac2`
Attempting to stop `ora.LISTENER.lsnr` on member `rac1`
Attempting to stop `ora.oc4j` on member `rac2`
Attempting to stop `ora.gsd` on member `rac2`
Attempting to stop `ora.eons` on member `rac1`
Attempting to stop `ora.DATA.dg` on member `rac1`
Attempting to stop `ora.OCR.dg` on member `rac1`
Attempting to stop `ora.oaodz.db` on member `rac1`
Attempting to stop `ora.gsd` on member `rac1`
Attempting to stop `ora.eons` on member `rac2`
Attempting to stop `ora.DATA.dg` on member `rac2`
Attempting to stop `ora.OCR.dg` on member `rac2`
Attempting to stop `ora.oaodz.db` on member `rac2`
Stop of `ora.LISTENER.lsnr` on member `rac1` succeeded.
Attempting to stop `ora.ons` on member `rac1`
Attempting to stop `ora.rac1.vip` on member `rac1`
Attempting to stop `ora.LISTENER_SCAN1.lsnr` on member `rac1`
Stop of `ora.gsd` on member `rac1` succeeded.
CRS-2789: Cannot stop resource 'ora.gsd' as it is not running on server 'rac1'
Stop of `ora.LISTENER.lsnr` on member `rac2` succeeded.
CRS-2789: Cannot stop resource 'ora.LISTENER.lsnr' as it is not running on server 'rac2'
Attempting to stop `ora.rac2.vip` on member `rac2`
Stop of `ora.gsd` on member `rac2` succeeded.
CRS-2789: Cannot stop resource 'ora.gsd' as it is not running on server 'rac2'
Stop of `ora.rac2.vip` on member `rac2` succeeded.
Stop of `ora.LISTENER_SCAN1.lsnr` on member `rac1` succeeded.
Attempting to stop `ora.scan1.vip` on member `rac1`
Stop of `ora.ons` on member `rac1` succeeded.
CRS-2789: Cannot stop resource 'ora.ons' as it is not running on server 'rac1'
Stop of `ora.ons` on member `rac2` succeeded.
CRS-2789: Cannot stop resource 'ora.ons' as it is not running on server 'rac2'
Attempting to stop `ora.net1.network` on member `rac2`
Stop of `ora.net1.network` on member `rac2` succeeded.
Stop of `ora.rac1.vip` on member `rac1` succeeded.
Stop of `ora.scan1.vip` on member `rac1` succeeded.
Attempting to stop `ora.net1.network` on member `rac1`
Stop of `ora.net1.network` on member `rac1` succeeded.
Stop of `ora.eons` on member `rac1` succeeded.
Stop of `ora.eons` on member `rac2` succeeded.
在root用户下执行:crsctl stop crs
##crs是运行在所有节点上的,所以如果你要停止crs需要到每一个节点上都执行
[root@rac1 oracle]# /u01/app/grid_home/bin/crsctl stop crs
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'rac1'
CRS-2673: Attempting to stop 'ora.crsd' on 'rac1'
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'rac1'
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'rac1'
CRS-2677: Stop of 'ora.DATA.dg' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stop of 'ora.asm' on 'rac1' succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'rac1' has completed
CRS-2677: Stop of 'ora.crsd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.mdnsd' on 'rac1'
CRS-2673: Attempting to stop 'ora.gpnpd' on 'rac1'
CRS-2673: Attempting to stop 'ora.cssdmonitor' on 'rac1'
CRS-2673: Attempting to stop 'ora.ctssd' on 'rac1'
CRS-2673: Attempting to stop 'ora.evmd' on 'rac1'
CRS-2673: Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stop of 'ora.cssdmonitor' on 'rac1' succeeded
CRS-2677: Stop of 'ora.gpnpd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.evmd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.mdnsd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.ctssd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.asm' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'rac1'
CRS-2677: Stop of 'ora.cssd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.diskmon' on 'rac1'
CRS-2673: Attempting to stop 'ora.gipcd' on 'rac1'
CRS-2677: Stop of 'ora.gipcd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.diskmon' on 'rac1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'rac1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
###启动集群
#先启动crs,启动的时候一定要开另外一个窗口执行下面的命令
/bin/dd if=/var/tmp/.oracle/npohasd of=/dev/null bs=1024 count=1
#用root运行
[root@rac1 oracle]# /u01/app/grid_home/bin/crsctl start crs
CRS-4123: Oracle High Availability Services has been started.
#CRS启动需要一点时间,如果你启动了CRS马上去起服务,会提示连接不到CRS,所以要等一会
CRS-0184: Cannot communicate with the CRS daemon.
#启动集群服务
#grid用户,报了一些错,但是服务全部都起来了
[grid@rac1 ~]$ crs_start -all
CRS-5702: Resource 'ora.asm' is already running on 'rac1'
CRS-5702: Resource 'ora.asm' is already running on 'rac1'
CRS-5702: Resource 'ora.gsd' is already running on 'rac1'
CRS-5702: Resource 'ora.ons' is already running on 'rac1'
Attempting to start `ora.oc4j` on member `rac1`
Attempting to start `ora.OCR.dg` on member `rac2`
Attempting to start `ora.gsd` on member `rac2`
Attempting to start `ora.eons` on member `rac2`
Attempting to start `ora.DATA.dg` on member `rac1`
Attempting to start `ora.rac1.vip` on member `rac1`
Attempting to start `ora.scan1.vip` on member `rac1`
Attempting to start `ora.net1.network` on member `rac2`
Start of `ora.OCR.dg` on member `rac2` succeeded.
Start of `ora.gsd` on member `rac2` succeeded.
CRS-5702: Resource 'ora.gsd' is already running on 'rac2'
Start of `ora.net1.network` on member `rac2` succeeded.
Start of `ora.DATA.dg` on member `rac1` succeeded.
Start of `ora.scan1.vip` on member `rac1` succeeded.
Attempting to start `ora.LISTENER_SCAN1.lsnr` on member `rac1`
Start of `ora.rac1.vip` on member `rac1` succeeded.
Attempting to start `ora.LISTENER.lsnr` on member `rac1`
Start of `ora.LISTENER_SCAN1.lsnr` on member `rac1` succeeded.
Start of `ora.LISTENER.lsnr` on member `rac1` succeeded.
Attempting to start `ora.ons` on member `rac2`
Start of `ora.eons` on member `rac2` succeeded.
Start of `ora.ons` on member `rac2` succeeded.
CRS-5702: Resource 'ora.ons' is already running on 'rac2'
Attempting to start `ora.oaodz.db` on member `rac1`
Start of `ora.oc4j` on member `rac1` succeeded.
Start of `ora.oaodz.db` on member `rac1` succeeded.
Attempting to start `ora.rac2.vip` on member `rac2`
Start of `ora.rac2.vip` on member `rac2` succeeded.
Attempting to start `ora.LISTENER.lsnr` on member `rac2`
Start of `ora.LISTENER.lsnr` on member `rac2` succeeded.
CRS-5702: Resource 'ora.LISTENER.lsnr' is already running on 'rac2'
Attempting to start `ora.oaodz.db` on member `rac2`
Start of `ora.oaodz.db` on member `rac2` succeeded.
CRS-0223: Resource 'ora.LISTENER.lsnr rac2 1' has placement error.
CRS-0223: Resource 'ora.asm' has placement error.
CRS-0223: Resource 'ora.ons rac2 1' has placement error.
CRS-0223: Resource 'ora.rac1.ASM1.asm' has placement error.
CRS-0223: Resource 'ora.rac1.gsd' has placement error.
CRS-0223: Resource 'ora.rac1.ons' has placement error.
[grid@rac1 ~]$ crs_stat -v -t
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora.DATA.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
ora....ER.lsnr ora....er.type 0/5 0/ ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac1
ora.OCR.dg ora....up.type 0/5 0/ ONLINE ONLINE rac1
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE rac1
ora.eons ora.eons.type 0/3 0/ ONLINE ONLINE rac1
ora.gsd ora.gsd.type 0/5 0/ ONLINE ONLINE rac1
ora....network ora....rk.type 0/5 0/ ONLINE ONLINE rac1
ora.oaodz.db ora....se.type 0/2 0/1 ONLINE ONLINE rac1
ora.oc4j ora.oc4j.type 0/5 0/0 ONLINE ONLINE rac1
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE rac1
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip ora....t1.type 0/0 0/0 ONLINE ONLINE rac2
ora.scan1.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac1
[grid@rac1 ~]$
其它命令:
srvctl stop listener
crs_stat -t -v
srvctl stop database -d OAODZ
crs_stat -t -v
srvctl stop asm -n rac1
srvctl stop asm -n rac2
crs_stat -t -v
srvctl start nodeapps -n rac1
srvctl start nodeapps -n rac2
srvctl start asm -n rac1
srvctl start asm -n rac2
srvctl start database -d OAODZ
srvctl start listener