大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
直接执行OS命令shutdown -h now ,后来发现启动OS之后很多服务都是UNKNOW状态,想想自己那样关闭数据库太过于"暴力",决定还是按照"温和"的方式去关闭集群数据库比较好。
创新互联建站主营柳北网站建设的网络公司,主营网站建设方案,成都app软件开发公司,柳北h5小程序开发搭建,柳北网站营销推广欢迎柳北等地区企业咨询
一名学生最近在公司搭建RAC集群,但对其启动与关闭的顺序和原理不是特别清晰,我在教学工作中也发现了很多学员对RAC知识了解甚少,因此我在这里就把RAC里面涉及到的最常用的启动与关闭顺序和命令逐一列举出来,由于RAC的后台资源较多,因此涉及到的命令也很多,最后附上帮助手册让在工作中临时使用时也可以迅速查到,如果这篇文章能够帮到大家就是我今后继续努力撰写的动力,感谢大家对我文章的浏览多提宝贵意见。
关闭过程(CRS集群关闭-关闭数据库)
1.关闭数据库:
用oracl用户执行srvctl命令
语法:srvctl stop database -d dbname [-o immediate]
作用:可以一次性关闭dbname的所有实例
[oracle@rac1 ~]$ srvctl stop database -d racdb -停止所有节点上的实例
然后查看状态:
[oracle@rac1 ~]$ srvctl status database -d racdb
Instance rac1 is not running on node rac1
Instance rac2 is not running on node race
2.停止HAS(High Availability Services),必须以root用户操作
[root@rac1 oracle]# cd /u01/grid/11.2.0/grid/bin
[root@rac1 bin]# ./crsctl stop has -f
[root@rac1 bin]# ./crsctl stop crs -f
本命令只能关闭当前节点的CRS服务,因此需要在RAC的所有节点上执行,启动也一样。has与crs等同
3.停止节点集群服务,必须以root用户:
[root@rac1 oracle]# cd /u01/grid/11.2.0/grid/bin
[root@rac1 bin]# ./crsctl stop cluster ----停止本节点集群服务
[root@rac1 bin]# ./crsctl stop cluster -all ---停止所有节点服务
也可以如下控制所停节点:
[root@rac1 bin]# crsctl stop cluster -n rac1 rac2
CRS-2677: Stop of 'ora.cssd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.cssd' on 'rac2' succeeded
。。。。。。。。。。。省略日志输出。。。。。。。。。。。。。。
你如果想一条命令把所有的进程全部停止可以使用上述命令。如果不指定参数的话对当前节点有效,如果指定参数的话对相关参数节点有效。
4.检查集群进程状态
[root@rac1 bin]# crsctl check cluster
详细输出
[root@rac1 bin]# crs_stat -t -v
只检查本节点的集群状态
[root@rac1 bin]# crsctl check crs
启动过程(CRS集群启动-启动数据库)
1.启动HAS
单一节点启动
[root@rac2 ~]# crsctl start has
[root@rac2 ~]# crsctl start crs
[root@rac2 ~]# 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
所有节点启动
[root@rac1 bin]# crsctl start cluster -n rac1 rac2
CRS-4123: Oracle High Availability Services has been started.
[root@rac1 bin]# crsctl start cluster -all
[root@rac2 ~]# crsctl check cluster
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
此命令会在后台启动所有RAC CRS相关进程
[root@rac2 ~]# crs_stat -t -v
CRS-0184: Cannot communicate with the CRS daemon.
因为start has启动的crs进程比较多因此会启动的比较慢,我的机器等待了5分钟,在没有完全启动成功之前会报上述错误,需要耐心等待一段时间后执行下面命令即可查看到所有CRS相关进程服务已经启动。
[root@rac2 ~]# 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 rac2
ora....N2.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac1
ora....N3.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE rac1
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE rac1
ora.cvu ora.cvu.type 0/5 0/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.oc4j ora.oc4j.type 0/1 0/2 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 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....ry.acfs ora....fs.type 0/5 0/ ONLINE ONLINE rac1
ora.scan1.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac2
ora.scan2.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac1
ora.scan3.vip ora....ip.type 0/0 0/0 ONLINE ONLINE rac1
说明:
英文解释
ora.gsd is OFFLINE by default ifthere is no 9i database in the cluster.
ora.oc4j is OFFLINE in 11.2.0.1 as DatabaseWorkload Management(DBWLM) is unavailable. these can be ignored in11gR2 RAC.
中文解释
ora.gsd是集群服务中用于与9i数据库进行通信的一个进程,在当前版本中为了向后兼容才保存下来,状态为OFFLINE不影响CRS的正常运行与性能,我们忽略即可
ora.oc4j是在11.2.0.2以上版本中有效的服务进程,用于DBWLM的资源管理,因此在11.2.0.1以下版本并没有使用
2.启动数据库:
oracl用户执行srvctl命令:
语法:srvctl start|stop|status database -d dbname [-o immediate]
作用:可以一次性启动dbname的所有实例
[oracle@rac1 ~]$ srvctl start database -d racdb -启动所有节点上的实例
然后查看状态:
[oracle@rac1 ~]$ srvctl status database -d racdb
3.详细输出资源全名称并检查状态
crsctl status resource -t
crsctl status resource
4.常用srvctl命令
指定dbname上某个实例
srvctl start|stop|status instance -d -i instance_name
5.显示RAC下所有实例配置与状态
srvctl status|config database -d
6.显示所有节点的应用服务(VIP,GSD,listener,ONS)
srvctl start|stop|status nodeapps -nnode_name
7.ASM进程服务管理
srvctl start|stop|status|config asm -n [-i asm_inst_name] [-ooracle_home]
srvctl config asm -a
srvctl status asm -a
6.可以获取所有的环境信息:
srvctl getenv database -d [-iinstance_name]
7.设置全局环境和变量:
srvctl setenv database -d -t LANG=en
8.在OCR中删除已有的数据库信息
srvctl remove database -d
9.向OCR中添加一个数据库的实例:
srvctl add instance -d -iinstance_name -n
srvctl add instance -d -iinstance_name -n
10.检查监听的状态
srvctl status listener
srvctl config listener -a
SCAN配置信息
srvctl config scan
SCAN listener状态信息
srvctl status scan
小结:crsctl命令是一个集群级别命令,可以对所有集群资源进行统一启动、停止等管理操作
srvctl命令是一个服务级别命令,可以对单一服务资源进行统一启动、停止等管理操作
附:srvctl命令启动与停止的详细帮助
[root@rac2 ~]# srvctl start -h
The SRVCTL start command starts, Oracle Clusterware enabled, non-running objects.
Usage: srvctl start database -d db_unique_name[-o start_options] [-n ]
Usage: srvctl start instance -d db_unique_name{-n node_name[-i inst_name] | -i inst_name_list} [-o start_options]
Usage: srvctl start service -d db_unique_name[-s "service_name_list" [-n node_name| -i inst_name] ] [-o start_options]
Usage: srvctl start nodeapps [-n node_name] [-g] [-v]
Usage: srvctl start vip { -n node_name| -i vip_name} [-v]
Usage: srvctl start asm [-n node_name] [-o start_options]
Usage: srvctl start listener [-l lsnr_name] [-n node_name]
Usage: srvctl start scan [-i ordinal_number] [-n node_name]
Usage: srvctl start scan_listener [-n node_name] [-i ordinal_number]
Usage: srvctl start oc4j [-v]
Usage: srvctl start home -o oracle_home-s state_file-n node_name
Usage: srvctl start filesystem -d volume_device[-n node_name]
Usage: srvctl start diskgroup -g dg_name[-n "node_list"]
Usage: srvctl start gns [-l log_level] [-n node_name] [-v]
Usage: srvctl start cvu [-n node_name]
For detailed help on each command and object and its options use:
srvctl -h
[root@rac2 ~]# srvctl stop -h
The SRVCTL stop command stops, Oracle Clusterware enabled, starting or running objects.
Usage: srvctl stop database -d db_unique_name[-o stop_options] [-f]
Usage: srvctl stop instance -d db_unique_name{-n node_name| -i inst_name_list} [-o stop_options] [-f]
Usage: srvctl stop service -d db_unique_name[-s "service_name_list" [-n node_name| -i inst_name] ] [-f]
Usage: srvctl stop nodeapps [-n node_name] [-g] [-f] [-r] [-v]
Usage: srvctl stop vip { -n node_name | -i vip_name} [-f] [-r] [-v]
Usage: srvctl stop asm [-n node_name] [-o stop_options] [-f]
Usage: srvctl stop listener [-l lsnr_name] [-n node_name] [-f]
Usage: srvctl stop scan [-i ordinal_number] [-f]
Usage: srvctl stop scan_listener [-i ordinal_number] [-f]
Usage: srvctl stop oc4j [-f] [-v]
Usage: srvctl stop home -o oracle_home-s state_file-n node_name[-t stop_options] [-f]
Usage: srvctl stop filesystem -d volume_device[-n node_name] [-f]
Usage: srvctl stop diskgroup -g dg_name[-n "node_list"] [-f]
Usage: srvctl stop gns [-n node_name] [-f] [-v]
Usage: srvctl stop cvu [-f]
For detailed help on each command and object and its options use:
srvctl -h
在windows里启动Oracle有两个步骤,一是先启动服务,二是再启动实例、数据库,这两个都可以设置成自动或者手动
针对数据库开机自动启动问题,解决方法有两个
方法一:在服务把oracleservice%SID%这个服务改成手动启动
方法二:修改注册表HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\HOME0\ORA_%SID%_AUTOSTART的值为false,这个是控制启动服务时是否自动启动数据库(实例,占内存),默认是true
注册表还有个ORA_%SID%_shutdown它是控制你关机时是否自动关数据库的
启动服务可以用net start oracleservice%SID% 命令
停止服务可以用net start oracleservice%SID% 命令
手动启动数据库要先开始服务,不然sqlplus不能进行操作系统验证了
进入sqlplus “/as sysdba"
启动数据库是在sqlplus里输入startup
关闭数据库是在sqlplus里输入shutdown immediate
Deleting a Cluster Node on Linux and UNIX Systems
1.确定要删除的节点,是否active,pinned
$ olsnodes -s -t
如果 pinned ,则crsctl unpin css -n nodename unpinned 相应的节点
2、禁用相应集群节点的应用资源,进程
先停掉 em:
emctl stop dbconsole
以root 用户运行 在要删除节点的 $Grid_home/crs/install 路径下运行rootcrs.pl 脚本
# ./rootcrs.pl -deconfig -force
如果要删除所有节点:
# ./rootcrs.pl -deconfig -force -lastnode
有时vip 资源不一定会被删除,这是需要手动来删除:
# srvctl stop vip -i vip_name-f
# srvctl remove vip -i vip_name-f
3、在其他节点执行以下命令:
crsctl delete node -n node_to_be_deleted
4、在要删除的节点上执行以下命令:
脚本在 :$Grid_home/oui/bin
$ ./runInstaller -updateNodeList Oracle_HOME=Grid_home"CLUSTER_NODES={node_to_be_deleted}" CRS=TRUE -silent -local
5、清理要删除节点的Clusterware home 安装文件:
$ Grid_home/deinstall/deinstall –local
注意一定要添加 -local 选项 ,否者会删除 所有节点的Clusterware home 安装目录.
6、在其他节点执行以下命令,更新节点信息:
脚本在 $Grid_home/oui/bin
$./runInstaller -updateNodeList ORACLE_HOME=Grid_home"CLUSTER_NODES={remaining_nodes_list}" CRS=TRUE -silent
7、验证要删除的节点是否已经成功删除:
$ cluvfy stage -post nodedel -n node_list[-verbose]
/etc/init.d/oracle #!/bin/sh
#
# oraShell -- user start|stop script for oracle
#
LOG_EMERG=0 # system is unusable
LOG_ALERT=1 # action must be taken immediately
LOG_CRIT=2 # critical conditions
LOG_ERR=3 # error conditions
LOG_WARNING=4 # warning conditions
LOG_NOTICE=5 # normal but significant condition
LOG_INFO=6 # informational
LOG_DEBUG=7 # debug-level messages
script_name=`basename $0`
clulog()
{
log_level=$1
log_info=$2
/opt/cluster/bin/clulog -p $$ -n $script_name -s $log_level "$log_info"
}
case $1 in
start)
# start listener
su - oracle -c "lsnrctl start"
retval=$?
if [ $retval -eq 0 ]; then
clulog $LOG_INFO "oraShell: lsnrctl start succeeded."
else
clulog $LOG_ERR "oraShell: lsnrctl start failed, ret=$retval."
exit 1
fi
# start oracle
su - oracle -c "sqlplus /nolog" EOF
connect / as sysdba
startup
quit
EOF
ps -wwwef | grep ora_pmon | grep -v grep /dev/null 21
retval=$?
if [ $retval -eq 0 ]; then
clulog $LOG_INFO "oraShell: oracle database start succeeded."
else
clulog $LOG_ERR "oraShell: oracle database start failed."
exit 1
fi
;;
stop)
# stop listener
su - oracle -c "lsnrctl stop"
retval=$?
if [ $retval -eq 0 ]; then
clulog $LOG_INFO "oraShell: lsnrctl stop succeeded."
else
clulog $LOG_ERR "oraShell: lsnrctl stop failed, ret=$retval."
exit 1
fi
# stop oracle
su - oracle -c "sqlplus /nolog" EOF
connect / as sysdba
shutdown immediate
quit
EOF
ps -wwwef | grep ora_pmon | grep -v grep /dev/null 21
retval=$?
if [ $retval -ne 0 ]; then
clulog $LOG_INFO "oraShell: oracle database stop succeeded."
else
clulog $LOG_ERR "oraShell: oracle database stop failed."
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
# succeed
exit 0