删除节点步骤:删除实例、删除 DB 软件、删除 GI 软件
删除节点发生的场景
1、被删除节点一切保留,需要从RAC中剔除,例如因为要更换服务器。
2、被删除节点关于RAC的部分文件丢失,如GI、库软件误删除,需要重新安装GI或oracle库软件。
环境和需求说明
数据库版本: 11.2.0.4 RAC 3节点
虚拟环境系统: Centos 7.9
需求:删除第三个节点
删除前准备
当前数据库的节点信息查询
查看活动的实例
--查看活动的实例
SQL> set linesize 999
SQL> select thread#,status,instance from v$thread;
THREAD# STATUS INSTANCE
---------- ------------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------
1 OPEN racdb1
2 OPEN racdb2
3 OPEN racdb3
查看实例的配置
--查看库的配置
[oracle@racdb01:/home/oracle]$srvctl config database -d racdb
Database unique name: racdb
Database name: racdb
Oracle home: /oracle/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: +DATA/racdb/spfileracdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: racdb
Database instances: racdb1,racdb2,racdb3
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Database is administrator managed
查看集群状态
--查看集群状态
[grid@racdb01 ~]# crsctl check cluster -all
**************************************************************
racdb01:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
racdb02:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
racdb03:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
[grid@racdb01 ~]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ONLINE ONLINE racdb03
ora.LISTENER.lsnr
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ONLINE ONLINE racdb03
ora.OCR.dg
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ONLINE ONLINE racdb03
ora.asm
ONLINE ONLINE racdb01 Started
ONLINE ONLINE racdb02 Started
ONLINE ONLINE racdb03 Started
ora.gsd
OFFLINE OFFLINE racdb01
OFFLINE OFFLINE racdb02
OFFLINE OFFLINE racdb03
ora.net1.network
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ONLINE ONLINE racdb03
ora.ons
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ONLINE ONLINE racdb03
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE racdb02
ora.cvu
1 ONLINE ONLINE racdb03
ora.oc4j
1 ONLINE ONLINE racdb03
ora.racdb.db
1 ONLINE ONLINE racdb01 Open
2 ONLINE ONLINE racdb02 Open
3 ONLINE ONLINE racdb03 Open
ora.racdb01.vip
1 ONLINE ONLINE racdb01
ora.racdb02.vip
1 ONLINE ONLINE racdb02
ora.racdb03.vip
1 ONLINE ONLINE racdb03
ora.scan1.vip
1 ONLINE ONLINE racdb02
[root@racdb01 ~]#
备份OCR信息
一般对 CRS 层面数据结构做重要操作之前一定要先备份 OCR 。
检查ocr 是否正常
--检查ocr 是否正常
[grid@racdb01 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 3052
Available space (kbytes) : 259068
ID : 1659693221
Device/File Name : +OCR
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
备份 OCR
--备份前检测ocr文件
[grid@racdb01 ~]# ocrconfig -showbackup
--备份ocr文件 1个节点操作
[grid@racdb01:/home/grid]$ocrdump /home/grid/ocrdump_ocr.bak_20240524
[grid@racdb01:/home/grid]$ls -l ocrdump_ocr.bak_20240524
-rw------- 1 grid oinstall 53046 May 24 11:42 ocrdump_ocr.bak_20240524
--手动备份ocr文件
[root@racdb01 ~]# ocrconfig -manualbackup
racdb01 2024/05/24 10:28:04 /oracle/app/11.2.0/grid/cdata/racdb01/backup_20240524_102804.olr
racdb01 2024/05/22 16:00:59 /oracle/app/11.2.0/grid/cdata/racdb01/backup_20240522_160059.olr
查看备份的OCR
--查看备份的ocr文件 3个节点分别操作
[grid@racdb01 ~]# ocrconfig -local -showbackup
[grid@racdb02 ~]# ocrconfig -local -showbackup
[grid@racdb03 ~]# ocrconfig -local -showbackup
--查看ocr帮助信息
[grid@racdb01 ~]# ocrconfig -h
Name:
ocrconfig - Configuration tool for Oracle Cluster/Local Registry.
Synopsis:
ocrconfig [option]
option:
[-local] -export <filename>
- Export OCR/OLR contents to a file
[-local] -import <filename> - Import OCR/OLR contents from a file
[-local] -upgrade [<user> [<group>]]
- Upgrade OCR from previous version
-downgrade [-version <version string>]
- Downgrade OCR to the specified version
[-local] -backuploc <dirname> - Configure OCR/OLR backup location
[-local] -showbackup [auto|manual] - Show OCR/OLR backup information
[-local] -manualbackup - Perform OCR/OLR backup
[-local] -restore <filename> - Restore OCR/OLR from physical backup
-replace <current filename> -replacement <new filename>
- Replace an OCR device or file <current filename> with <new filename>
-add <filename> - Add a new OCR device/file
-delete <filename> - Remove a OCR device/file
-overwrite - Overwrite OCR configuration on disk
-repair -add <filename> | -delete <filename> | -replace <current filename> -replacement <new filename>
- Repair OCR configuration on the local node
-help - Print out this help information
Note:
* A log file will be created in
$ORACLE_HOME/log/<hostname>/client/ocrconfig_<pid>.log. Please ensure
you have file creation privileges in the above directory before
running this tool.
* Only -local -showbackup [manual] is supported.
* Use option '-local' to indicate that the operation is to be performed on the Oracle Local Registry.
删除步骤
删除实例
禁用要删除的线程
如果是正常删除节点,那么在要删除的节点上执行操作
--查看
[oracle@racdb03:/home/oracle]$srvctl status database -d racdb
Instance racdb1 is running on node racdb01
Instance racdb2 is running on node racdb02
Instance racdb3 is running on node racdb03
--关闭要删除节点,在正常删除节点上操作
sqlplus / as sysdba
shutdown immediate
或
srvctl stop instance -d PROD -n racdb03
--查看
[oracle@racdb03:/home/oracle]$srvctl status database -d racdb
Instance racdb1 is running on node racdb01
Instance racdb2 is running on node racdb02
Instance racdb3 is not running on node racdb03
或
[root@racdb01 install]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
......
ora.racdb.db
1 ONLINE ONLINE racdb01 Open
2 ONLINE ONLINE racdb02 Open
3 ONLINE ONLINE racdb03 Instance Shutdown
......
如果是节点损坏,则没有必要进行该操作
在保留节点上执行:
SQL> alter database disable thread 3;
Database altered.
注意:未关库时不能disable
SQL> alter database disable thread 3;
alter database disable thread 3
*
ERROR at line 1:
ORA-01615: instance racdb3 (thread 3) is mounted - cannot disable
删除要删除的实例
在保留节点上执行instance删除
场景1:支持图形化界面
如果有图形界面支持,则可以运行dbca进行删除
场景2:不支持图形化界面
如果没有则采取静默删除
[oracle@racdb01:/home/oracle]$dbca -silent -deleteInstance -nodeList racdb03 -gdbName racdb -instanceName racdb3 -sysDBAUserName sys -sysDBAPassword oracle
Deleting instance
1% complete
2% complete
6% complete
13% complete
20% complete
26% complete
33% complete
40% complete
46% complete
53% complete
60% complete
66% complete
Completing instance management.
100% complete
Look at the log file "/oracle/app/oracle/cfgtoollogs/dbca/racdb.log" for further details.
查看删除后的实例状态
[oracle@racdb03:/home/oracle]$srvctl status database -d racdb
Instance racdb1 is running on node racdb01
Instance racdb2 is running on node racdb02
查看实例的配置
查看实例的配置,确认实例删除完成
[grid@racdb01:/home/grid]$srvctl config database -d racdb
Database unique name: racdb
Database name: racdb
Oracle home: /oracle/app/oracle/product/11.2.0/db_1
Oracle user: oracle
Spfile: +DATA/racdb/spfileracdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: racdb
Database instances: racdb1,racdb2
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Database is administrator managed
删除DB软件
停止要删除节点的监听
任一保留节点上执行
--停止要删除节点的监听 保留节点上执行
su - grid
srvctl status listener
srvctl disable listener -n racdb03
srvctl stop listener -n racdb03
在要删除的节点更新 inventory
如果是正常删除节点,需要在被删除节点上执行一下操作,如果是损坏则不需要
su - oracle
cd $ORACLE_HOME/oui/bin
./runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={racdb03(代表要删除的节点)}" -local
详细过程如下:
[oracle@racdb03:/home/oracle]$cd $ORACLE_HOME/oui/bin
[oracle@racdb03:/oracle/app/oracle/product/11.2.0/db_1/oui/bin]$./runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={racdb03}" -local
Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB. Actual 4092 MB Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /oracle/app/oraInventory
'UpdateNodeList' was successful.
卸载 DB 软件
需要在被删除节点上执行一下操作,卸载oracle db,删除oracle home
$ORACLE_HOME/deinstall/deinstall -local
在任一保留的节点上停止racdb03节点NodeApps
[oracle@racdb03 bin]$ srvctl stop nodeapps -n racdb03 -f
发现停了racdb03节点的ons和VIP
所有保留节点上更新 inventory
su - oracle
cd $ORACLE_HOME/oui/bin
./runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={racdb01,racdb02(代表要保留节点)}"
如果卸载不干净,需要人为手工执行下面命令
[oracle@racdb03 bin]$ rm -rf $ORACLE_HOME/*
删除GI软件
检查被删除节点状态
[grid@racdb01:/home/grid]$olsnodes -s -t
racdb01 Active Unpinned
racdb02 Active Unpinned
racdb03 Active Unpinned
翻译
Unpinned :未固定
节点如果被 PIN 住,需要 UNPIN
crsctl unpin css -n racdb03
停止被删节点 HAS 服务
被删除节点上执行。
--在被删除节点上操作禁用clusterware的application and daemons
su - root
cd $ORACLE_HOME/crs/install
./rootcrs.pl -deconfig -force
详细过程如下:
[root@racdb03 ~]# cd /oracle/app/11.2.0/grid/crs/install/
[root@racdb03 install]# ./rootcrs.pl -deconfig -force
Using configuration parameter file: ./crsconfig_params
Network exists: 1/192.168.40.0/255.255.255.0/ens32, type static
VIP exists: /racdb01_vitureip/192.168.40.16/192.168.40.0/255.255.255.0/ens32, hosting node racdb01
VIP exists: /racdb02_vitureip/192.168.40.17/192.168.40.0/255.255.255.0/ens32, hosting node racdb02
VIP exists: /racdb03_vitureip/192.168.40.18/192.168.40.0/255.255.255.0/ens32, hosting node racdb03
GSD exists
ONS exists: Local port 6100, remote port 6200, EM port 2016
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'racdb03'
CRS-2673: Attempting to stop 'ora.crsd' on 'racdb03'
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'racdb03'
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'racdb03'
CRS-2673: Attempting to stop 'ora.OCR.dg' on 'racdb03'
CRS-2677: Stop of 'ora.DATA.dg' on 'racdb03' succeeded
CRS-2677: Stop of 'ora.OCR.dg' on 'racdb03' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'racdb03'
CRS-2677: Stop of 'ora.asm' on 'racdb03' succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'racdb03' has completed
CRS-2677: Stop of 'ora.crsd' on 'racdb03' succeeded
CRS-2673: Attempting to stop 'ora.crf' on 'racdb03'
CRS-2673: Attempting to stop 'ora.ctssd' on 'racdb03'
CRS-2673: Attempting to stop 'ora.evmd' on 'racdb03'
CRS-2673: Attempting to stop 'ora.asm' on 'racdb03'
CRS-2673: Attempting to stop 'ora.mdnsd' on 'racdb03'
CRS-2677: Stop of 'ora.mdnsd' on 'racdb03' succeeded
CRS-2677: Stop of 'ora.crf' on 'racdb03' succeeded
CRS-2677: Stop of 'ora.evmd' on 'racdb03' succeeded
CRS-2677: Stop of 'ora.ctssd' on 'racdb03' succeeded
CRS-2677: Stop of 'ora.asm' on 'racdb03' succeeded
CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on 'racdb03'
CRS-2677: Stop of 'ora.cluster_interconnect.haip' on 'racdb03' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'racdb03'
CRS-2677: Stop of 'ora.cssd' on 'racdb03' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'racdb03'
CRS-2677: Stop of 'ora.gipcd' on 'racdb03' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'racdb03'
CRS-2677: Stop of 'ora.gpnpd' on 'racdb03' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'racdb03' has completed
CRS-4133: Oracle High Availability Services has been stopped.
Successfully deconfigured Oracle clusterware stack on this node
问题处理
Can't locate Env.pm
--问题描述
[root@racdb01 install]# ./rootcrs.pl -deconfig -force
Can't locate Env.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . .) at crsconfig_lib.pm line 703.
BEGIN failed--compilation aborted at crsconfig_lib.pm line 703.
Compilation failed in require at ./rootcrs.pl line 305.
BEGIN failed--compilation aborted at ./rootcrs.pl line 305.
--问题原因
缺少依赖包
--解决办法
yum install perl-Env
检测集群资源状态
[root@racdb01 install]# crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ora.LISTENER.lsnr
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ora.OCR.dg
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ora.asm
ONLINE ONLINE racdb01 Started
ONLINE ONLINE racdb02 Started
ora.gsd
OFFLINE OFFLINE racdb01
OFFLINE OFFLINE racdb02
ora.net1.network
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
ora.ons
ONLINE ONLINE racdb01
ONLINE ONLINE racdb02
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE racdb01
ora.cvu
1 ONLINE ONLINE racdb01
ora.oc4j
1 ONLINE ONLINE racdb02
ora.racdb.db
1 ONLINE ONLINE racdb01 Open
2 ONLINE ONLINE racdb02 Open
ora.racdb01.vip
1 ONLINE ONLINE racdb01
ora.racdb02.vip
1 ONLINE ONLINE racdb02
ora.scan1.vip
1 ONLINE ONLINE racdb01
检测集群下所有节点状态
[root@racdb01 install]# olsnodes -t -s
racdb01 Active Unpinned
racdb02 Active Unpinned
从集群中删除节点
--从集群中删除节点
su - root
crsctl delete node -n racdb03
--检测集群下所有节点的状态
[root@racdb01 install]# olsnodes -t -s
racdb01 Active Unpinned
racdb02 Active Unpinned
删除racdb03节点的VIP
如果上一步执行顺利的,racdb03节点的VIP此时已被删除,在任一保留节点执行crs_stat -t验证一下:
crs_stat -t
如果仍然有racdb03节点的VIP服务存在,执行如下:
[root@racdb01 ~]# srvctl stop vip -i ora.racdb03.vip -f
[root@racdb02 ~]# srvctl remove vip -i ora.racdb03.vip -f
[root@racdb03 ~]# crsctl delete resource ora.racdb03.vip -f
更新 inventory
su - grid
cd $ORACLE_HOME/oui/bin
./runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={racdb03(代表要删除节点)}" CRS=TRUE -silent -local
被删除节点上卸载GI软件
在racdb03节点上执行:
su - grid
cd $ORACLE_HOME/deinstall
./deinstall -local #一路选择"是"
新开一个终端,以root 用户运行提示的脚本,如下:
[root@racdb03 install]# /tmp/deinstall2024-05-24_02-34-41PM/perl/bin/perl -I/tmp/deinstall2024-05-24_02-34-41PM/perl/lib -I/tmp/deinstall2024-05-24_02-34-41PM/crs/install /tmp/deinstall2024-05-24_02-34-41PM/crs/install/rootcrs.pl -force -deconfig -paramfile "/tmp/deinstall2024-05-24_02-34-41PM/response/deinstall_Ora11g_gridinfrahome1.rsp"
运行完后,返回原终端按回车,继续运行暂停的脚本。
当会话结束时在节点 ‘rac3′ 上以 root 用户身份运行 ‘rm -rf /etc/oraInst.loc’。
当会话结束时在节点 ‘rac3′ 上以 root 身份运行 ‘rm -rf /opt/ORCLfmap’。
[root@racdb03 ~]# rm -rf /etc/oraInst.loc
[root@racdb03 ~]# rm -rf /opt/ORCLfmap
在保留节点上更新 inventory
在所有保留的节点上执行
su - grid
cd $ORACLE_HOME/oui/bin
./runInstaller -updateNodeList ORACLE_HOME=$ORACLE_HOME "CLUSTER_NODES={racdb01,racdb02(代表保留节点)}" CRS=TRUE -silent
在保留节点上确认节点是否删除
这步非常重要,关系以后是否可以顺利增加节点到集群中。
su - grid
cluvfy stage -post nodedel -n racdb03 -verbose
crsctl status resource -t
--查看活动的实例
sqlplus / as sysdba
select thread#,status,instance from v$thread;
备份 OCR
[root@racdb01 install]# ocrconfig -manualbackup
racdb01 2024/05/24 16:39:32 /oracle/app/11.2.0/grid/cdata/racdb/backup_20240524_163932.ocr
racdb03 2024/05/24 10:27:36 /oracle/app/11.2.0/grid/cdata/racdb/backup_20240524_102736.ocr
原文链接:oracle 11gR2 rac删除节点和增加节点_oracle11gr2 rac加减节点-CSDN博客
参考链接:Oracle 11G RAC 删除节点-CSDN博客