首页  :: 新随笔  :: 管理

DB2 pureScale之实例管理

Posted on 2022-09-19 13:01  高&玉  阅读(180)  评论(0编辑  收藏  举报

查看状态

查看主机状态

[db2inst1@member1 ~]$ db2 "select varchar(hostname, 10) as host, varchar(state,8) as state,varchar(instance_stopped, 7) as stopped, alert from sysibmadm.db2_cluster_host_state"

HOST       STATE    STOPPED ALERT   
---------- -------- ------- --------
cf2        ACTIVE   NO      NO      
cf1        ACTIVE   NO      NO      
member2    ACTIVE   NO      NO      
member1    ACTIVE   NO      NO 

或者

[db2inst1@member1 ~]$ db2cluster -cm -list -host -state
HOSTNAME                	STATE
------------------------	-----------
cf2                     	ONLINE
member2                 	ONLINE
member1                 	ONLINE
cf1                     	ONLINE

或者

[db2inst1@member1 ~]$ db2cluster -cfs -list -host -state
HOSTNAME                	STATE
------------------------	-----------
cf1                     	STARTED
member1                 	STARTED
member2                 	STARTED
cf2                     	STARTED

查看CF和MEMBER信息

实例(db2inst1)用户查看MEMBER信息

[db2inst1@member1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

root用户查看MEMBER信息(查询结果同上)

[root@member1 ~]# db2instance -instance db2inst1 -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

SQL方式查看CF信息

[db2inst1@member1 ~]$ db2 "SELECT ID,varchar(CURRENT_HOST,10) AS CUR_HOST,varchar(STATE,17) AS STATE,ALERT FROM SYSIBMADM.DB2_CF"

ID     CUR_HOST   STATE             ALERT   
------ ---------- ----------------- --------
   128 cf1        PRIMARY           NO      
   129 cf2        PEER              NO 

或者

[db2inst1@member1 ~]$ db2 "select id, varchar(state, 17) as state, varchar(home_host, 10) as home_host, varchar(current_host, 10) as cur_host, alert from TABLE(db2_get_instance_info(NULL,'','','CF',NULL)) "

ID     STATE             HOME_HOST  CUR_HOST   ALERT   
------ ----------------- ---------- ---------- --------
   128 PRIMARY           cf1        cf1        NO      
   129 PEER              cf2        cf2        NO  

SQL方式查看MEMBER信息

[db2inst1@member1 ~]$ db2 "select id,varchar(HOME_HOST,10) as home_host,varchar(current_host, 10) as cur_host,varchar(state, 21) as state,alert from sysibmadm.db2_member "

ID     HOME_HOST  CUR_HOST   STATE                 ALERT   
------ ---------- ---------- --------------------- --------
     0 member1    member1    STARTED               NO      
     1 member2    member2    STARTED               NO  

查看CF全局缓冲池

[db2inst1@member1 ~]$ db2 "select substr(host_name, 1, 7) as host, id as hostid, current_cf_gbp_size, configured_cf_gbp_size, target_cf_gbp_size from table(mon_get_cf(NULL))"

HOST    HOSTID CURRENT_CF_GBP_SIZE CONFIGURED_CF_GBP_SIZE TARGET_CF_GBP_SIZE
------- ------ ------------------- ---------------------- ------------------
cf1        128                6651                 342784             342784
cf2        129                6473                 342784             342784

查看CF全局缓冲池命中率

[db2inst1@member1 ~]$ db2 "select varchar(BP_NAME,20) as BP_NAME,MEMBER,POOL_DATA_GBP_L_READS+POOL_INDEX_GBP_L_READS AS LOGI_CAL_READS, 
POOL_DATA_GBP_P_READS+POOL_INDEX_GBP_P_READS AS PHYSICAL_READS, 
((FLOAT(POOL_DATA_GBP_L_READS+POOL_INDEX_GBP_L_READS) -FLOAT(POOL_DATA_GBP_P_READS+POOL_INDEX_GBP_P_READS))/FLOAT(POOL_DATA_GBP_L_READS+POOL_INDEX_GBP_L_READS)) 
* 100 AS HIT_RATIO FROM TABLE(MON_GET_BUFFERPOOL('',-2))"

BP_NAME              MEMBER LOGI_CAL_READS       PHYSICAL_READS       HIT_RATIO               
-------------------- ------ -------------------- -------------------- ------------------------
IBMDEFAULTBP              0                  906                  906   +0.00000000000000E+000

查看CF锁内存使用情况

[db2inst1@member1 ~]$ db2 "select substr(HOST_NAME, 1, 7) as HOST,ID as HOSTID,CURRENT_CF_LOCK_SIZE,CONFIGURED_CF_LOCK_SIZE,TARGET_CF_LOCK_SIZE from table(mon_get_cf(NULL))"

HOST    HOSTID CURRENT_CF_LOCK_SIZE CONFIGURED_CF_LOCK_SIZE TARGET_CF_LOCK_SIZE
------- ------ -------------------- ----------------------- -------------------
cf1        128                 1312                   65792               65792
cf2        129                  361                   65792               65792

查看CF节点CPU使用情况

[db2inst1@member1 ~]$ db2 "select varchar(NAME,20) as HOST_ATTRIBUTE,varchar(VALUE, 25) as VALUES,varchar(UNIT,8) as UNIT from sysibmadm.env_cf_sys_resources"

HOST_ATTRIBUTE       VALUES                    UNIT    
-------------------- ------------------------- --------
HOST_NAME            cf1                       -       
MEMORY_TOTAL         3817                      MB      
MEMORY_FREE          135                       MB      
MEMORY_SWAP_TOTAL    3951                      MB      
MEMORY_SWAP_FREE     3905                      MB      
VIRTUAL_MEM_TOTAL    7769                      MB      
VIRTUAL_MEM_FREE     4041                      MB      
CPU_USAGE_TOTAL      0                         PERCENT 
HOST_NAME            cf2                       -       
MEMORY_TOTAL         3817                      MB      
MEMORY_FREE          1677                      MB      
MEMORY_SWAP_TOTAL    3951                      MB      
MEMORY_SWAP_FREE     3918                      MB      
VIRTUAL_MEM_TOTAL    7769                      MB      
VIRTUAL_MEM_FREE     5596                      MB      
CPU_USAGE_TOTAL      0                         PERCENT

重启CF

查看CF信息

[db2inst1@cf2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

关闭cf2,cf2的ID是129

[db2inst1]# db2stop CF 129
SQL1064N  DB2STOP processing was successful.

查看CF状态,可以看到cf2的状态为“STOPPED”

[db2inst1@cf2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	         STOPPED		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

 

启动cf2

[db2inst1]# db2start CF 129
SQL1063N  DB2START processing was successful.

查看CF状态,可以看到CF2的状态变化是"STOPPED"-->"CATCHUP"-->"PEER"

[db2inst1@cf2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	         CATCHUP		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

[db2inst1@cf2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

重启MEMBER

查看MEMBER信息

[db2inst1@cf1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

关闭member2,ID为1

[db2inst1]# db2stop member 1
09/19/2022 03:37:35     1   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.

查看MEMBER信息,可以看到member2的状态为"STOPPED"

[db2inst1@cf1 ~]$ db2instance -list

ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

启动member2

[db2inst1]# db2start member 1
09/19/2022 03:39:47     1   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

查看MEMBER信息,可以看到member2的状态为"STARTED"

[db2inst1@cf1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

维护CF/MEMBER

提示:
  1. 此方式不适用于正常关闭操作系统维护,执行“shutdown”后会自动启动
  2. 此方式适用于更新数据库补丁,更新操作系统补丁等。

 

关闭member2

[db2inst1]# db2stop member 1 quiesce
09/19/2022 04:04:04     1   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.

查看MEMBER状态,member2状态为"STOPPED"

[db2inst1@cf1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

此时member2节点上的db2sysc进程还在

[db2inst1@member2 ~]$ ps -ef | grep db2sysc
db2inst1  54613  47343  0 04:06 pts/0    00:00:00 grep db2sysc
db2inst1  71845  71839  0 Sep18 ?        00:00:46 db2sysc (idle 999)                             
db2inst1  71846  71841  0 Sep18 ?        00:00:40 db2sysc (idle 997)                             
db2inst1  72229  72227  0 Sep18 ?        00:00:45 db2sysc (idle 998) 

关闭member2节点上的实例

[db2inst1@cf1 ~]$ db2stop instance on member2
SQL1064N  DB2STOP processing was successful.

再次查看member2节点的db2sysc进程

[db2inst1@member2 ~]$ ps -ef | grep db2sysc
db2inst1  55052  47343  0 04:08 pts/0    00:00:00 grep db2sysc

 

省略维护工作...

 

启动member2主机上的实例

[db2inst1@member2 ~]$ db2start instance on member2
SQL1063N  DB2START processing was successful.

启动member2

[db2inst1@member2 ~]$ db2start member 1
09/19/2022 04:14:08     1   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

查看MEMBER信息,此时member2状态为"STARTED"

[db2inst1@member2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

单节点维护模式

提示:
  1. 适用于主机断电更换硬件等操作。

 

查看MEMBER状态

[db2inst1@member1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

关闭member2

[db2inst1@member1 ~]$ db2stop member 1
09/19/2022 04:31:45     1   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.

再次查看MEMBER状态

[db2inst1@member1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

关闭member2节点的instance

[db2inst1@member1 ~]$ db2stop instance on member2
SQL1064N  DB2STOP processing was successful.

再次查看MEMBER状态

[db2inst1@member1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  INACTIVE		              YES	   YES
 member1		  ACTIVE		              NO	   NO

在member2节点上执行,将member2节点的集群管理器置于维护模式

[root@member2 ~]# db2cluster -cm -enter -maintenance
Host 'member2' has entered maintenance mode.

在member2节点上执行,将member2节点上的集群文件系统置于维护模式

[root@member2 ~]# db2cluster -cfs -enter -maintenance
Host 'member2' has successfully entered file system maintenance mode

此时member2可以正常停机

[root@member2 ~]# shutdown now

 

member2节点,将集群管理器退出维护模式

[root@member2 ~]# db2cluster -cm -exit -maintenance
Host 'member2' has exited maintenance mode. Domain 'db2domain_20220918082102' has been started.

member2节点,将集群文件系统退出维护模式

[root@member2]# db2cluster -cfs -exit -maintenance
Host 'member2' has successfully exited file system maintenance mode.

查看CF和MEMBER信息

[db2inst1@member2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		             YES	   NO
 member1		  ACTIVE		              NO	   NO

启动member2节点上的实例

[db2inst1@member2 ~]$ db2start instance on member2
SQL1063N  DB2START processing was successful.

查看CF和MEMBER信息,member2节点上的instance已经启动,member2状态目前还为"STOPPED"

[db2inst1@member2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

启动member2 

[db2inst1@member2 ~]$ db2start member 1
09/19/2022 09:53:58     1   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

查看CF和MEMBER信息,member2节点上的instance已经启动,member2状态为"STARTED"

[db2inst1@member2 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

集群维护模式

查看CF和MEMBER状态

[db2inst1@cf1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	            PEER		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

在任一节点上执行db2stop,停止所有主机上的数据库管理

[db2inst1@cf1 ~]$ db2stop
09/19/2022 10:00:48     0   0   SQL1064N  DB2STOP processing was successful.
09/19/2022 10:00:52     1   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.

查看CF和MEMBER状态,CF和MEMBER状态均为"STOPPED",但是各节点上的instance状态是"ACTIVE"

[db2inst1@cf1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STOPPED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         STOPPED		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	         STOPPED		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

分别关闭cf1,cf2,member1,member2 节点上的instance

[db2inst1@cf1 ~]$ db2stop instance on cf1
SQL1064N  DB2STOP processing was successful.

[db2inst1@cf1 ~]$ db2stop instance on cf2
SQL1064N  DB2STOP processing was successful.

[db2inst1@cf1 ~]$ db2stop instance on member1
SQL1064N  DB2STOP processing was successful.

[db2inst1@cf1 ~]$ db2stop instance on member2
SQL1064N  DB2STOP processing was successful.

 再次查看CF和MEMBER状态

[db2inst1@cf1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STOPPED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STOPPED		  member2		     member2		   NO	               0	           0	member2
128	CF	         STOPPED		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	         STOPPED		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		             YES	   NO
     cf1		  ACTIVE		             YES	   NO
 member2		  ACTIVE		             YES	   NO
 member1		  ACTIVE		             YES	   NO

在任一节点执行如下操作,会将所有MEMBER置于维护模式

[root@member1 ~]# db2cluster -cm -enter -maintenance -all
Domain 'db2domain_20220918082102' has entered maintenance mode.

在所有节点执行如下操作,将CF置于维护模式

[root@cf1 db2]# db2cluster -cfs -enter -maintenance -all
The shared file system has sucessfully entered maintenance mode.

[root@cf2 license]# db2cluster -cfs -enter -maintenance -all
The shared file system has sucessfully entered maintenance mode.

[root@member1 ~]# db2cluster -cfs -enter -maintenance -all
The shared file system has sucessfully entered maintenance mode.

[root@member2 ~]# db2cluster -cfs -enter -maintenance -all
The shared file system has sucessfully entered maintenance mode.

 

此时,所有节点可以正常关机。

 

任一节点执行将全部集群管理器退出维护模式

[root@cf1 ~]# db2cluster -cm -exit -maintenance -all
Domain 'db2domain_20220918082102' has successfully exited maintenance mode.

查看集群主机状态

[root@cf1 ~]# db2cluster -cm -list -host -state
HOSTNAME                	STATE
------------------------	-----------
member1                 	ONLINE
member2                 	ONLINE
cf2                     	ONLINE
cf1                     	ONLINE

 每个节点执行,退出CF维护模式

[root@cf1 ~]# db2cluster -cfs -exit -maintenance -all
The shared file system successfully exited from maintenance mode.

[root@cf2 ~]# db2cluster -cfs -exit -maintenance -all
The shared file system successfully exited from maintenance mode.

[root@member1 ~]# db2cluster -cfs -exit -maintenance -all
The shared file system successfully exited from maintenance mode.

[root@member2 ~]# db2cluster -cfs -exit -maintenance -all
The shared file system successfully exited from maintenance mode.

启动每个节点上的instance

[db2inst1@cf1 ~]$ db2start instance on cf1
SQL1063N  DB2START processing was successful.

[db2inst1@cf1 ~]$ db2start instance on cf2
SQL1063N  DB2START processing was successful.

[db2inst1@cf1 ~]$ db2start instance on member1
SQL1063N  DB2START processing was successful.

[db2inst1@cf1 ~]$ db2start instance on member2
SQL1063N  DB2START processing was successful.

任一节点启动数据库管理器,会将集群所有的CF和MEMBER启动

[db2inst1@cf1 ~]$ db2start
09/19/2022 21:39:42     1   0   SQL1063N  DB2START processing was successful.
09/19/2022 21:39:43     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

查看CF、MEMBER、INSTANCE状态,所有状态均正常

[db2inst1@cf1 ~]$ db2instance -list
ID	  TYPE	           STATE		HOME_HOST		CURRENT_HOST		ALERT	PARTITION_NUMBER	LOGICAL_PORT	NETNAME
--	  ----	           -----		---------		------------		-----	----------------	------------	-------
0	MEMBER	         STARTED		  member1		     member1		   NO	               0	           0	member1
1	MEMBER	         STARTED		  member2		     member2		   NO	               0	           0	member2
128	CF	         PRIMARY		      cf1		         cf1		   NO	               -	           0	    cf1
129	CF	         CATCHUP		      cf2		         cf2		   NO	               -	           0	    cf2

HOSTNAME		   STATE		INSTANCE_STOPPED	ALERT
--------		   -----		----------------	-----
     cf2		  ACTIVE		              NO	   NO
     cf1		  ACTIVE		              NO	   NO
 member2		  ACTIVE		              NO	   NO
 member1		  ACTIVE		              NO	   NO

此时,DB2 pureScale集群可以正常使用了。

 

参考:https://www.ibm.com/docs/zh/db2/10.5?topic=administration-instance-management-in-db2-purescale-environment