重庆思庄Oracle、Redhat认证学习论坛

标题: oracle 主备切换 [打印本页]

作者: mahan    时间: 2023-6-4 16:48
标题: oracle 主备切换
主库操作:
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=' ',' ';







欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2