主库操作:
SQL> select switchover_status,database_role from v$database;
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
TO STANDBY PRIMARY
查询结果为 TO STANDBY,当结果为TO STANDBY或者SESSIONS ACTIVE时表明可以进行切换
SQL> alter database commit to switchover to physical standby with session shutdown;
数据库已更改。
SQL> shutdown immediate
SQL> startup mount;
SQL> alter database open read only;
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
备库操作:
SQL> select switchover_status,database_role from v$database;
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
TO PRIMARY PHYSICAL STANDBY
查询结果为TO PRIMARY,当结果为TO PRIMARY或SESSIONS ACTIVE表明可以进行切换
SQL> alter database commit to switchover to primary with session shutdown;
数据库已更改。
SQL> alter database open;
数据库已更改。
SQL> select switchover_status,database_role,open_mode from v$database;
SWITCHOVER_STATUS DATABASE_ROLE OPEN_MODE
-------------------- ---------------- --------------------
TO STANDBY PRIMARY READ WRITE
已经切换为主库
现备库操作:需要开启实时同步
SQL> alter database recover managed standby database using current logfile disconnect from session;
数据库已更改。
新主库修改IP:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
...
IPADDR=192.168.133.30
...
修改后重启网卡:
nmctl con reload
nmctl con up eth0
注意修改hosts文件
同理新备库修改IP:
检查主备库TNS文件是否需要调整:
检查主备库监听文件静态监听是否需要调整:
新备库参数调整:
alter system set fal_server=' ';
alter system set fal_client=' ';
alter system set log_archive_config='dg_config=( , )';
路径转换:
alter system set db_file_name_convert=' ',' ';
alter system set log_file_name_convert=' ',' ';
|