将192.168.56.101修改为192.168.56.111
将192.168.56.102修改为192.168.56.112
1.实验环境,dg01为Primary节点,dg02为Standby节点https://www.cndba.cn/hbhe0316/article/5041
[root@dg01 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.101 dg01
192.168.56.102 dg02
[root@dg01 ~]# su - oracle
Last login: Sat Nov 6 09:39:04 CST 2021 on pts/2
[oracle@dg01 ~]$ sqlplus -V
SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.12.0.0.0
2.Primary节点和Standby节点停止数据库
主库:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
备库:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
Database altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
3.Primary节点和Standby节点停止监听
主库https://www.cndba.cn/hbhe0316/article/5041
https://www.cndba.cn/hbhe0316/article/5041
[oracle@dg01 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 06-NOV-2021 10:08:24
Copyright (c) 1991, 2021, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg01)(PORT=1521)))
The command completed successfully
备库
https://www.cndba.cn/hbhe0316/article/5041
[oracle@dg02 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 06-NOV-2021 10:08:50
Copyright (c) 1991, 2021, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg02)(PORT=1521)))
The command completed successfully
4.修改主库和备库IP地址
主库:
[root@dg01 ~]# cd /etc/sysconfig/network-scripts/
[root@dg01 network-scripts]# cat ifcfg-enp0s3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.56.111
NETMASK=255.255.255.0
GATEWAY=192.168.56.1
备库:
[root@dg02 ~]# cd /etc/sysconfig/network-scripts/
[root@dg02 network-scripts]# cat ifcfg-enp0s3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.56.112
NETMASK=255.255.255.0
GATEWAY=192.168.56.1
5.主库和备库重启网卡
主库:
[root@dg01 network-scripts]# systemctl restart network.service
备库:https://www.cndba.cn/hbhe0316/article/5041https://www.cndba.cn/hbhe0316/article/5041
[root@dg02 network-scripts]# systemctl restart network.service
6.使用新的IP登录主备机,并修改/etc/hosts文件
主库:
https://www.cndba.cn/hbhe0316/article/5041
[root@dg01 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.111 dg01
192.168.56.112 dg02
备库:
[root@dg01 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.111 dg01
192.168.56.112 dg02
7.修改tnsnams.ora文件
主库:https://www.cndba.cn/hbhe0316/article/5041
[root@dg01 ~]# su - oracle
Last login: Sat Nov 6 09:57:19 CST 2021 on pts/2
[oracle@dg01 ~]$ cd $ORACLE_HOME/network/admin
[oracle@dg01 admin]$ cat tnsnames.ora
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
ORCL_P =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_S =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg02)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
备库:
[root@dg02 ~]# su - oracle
Last login: Sat Nov 6 10:08:46 CST 2021 on pts/2
[oracle@dg02 ~]$ cd $ORACLE_HOME/network/admin
[oracle@dg02 admin]$ cat tnsnames.ora
ORCL_P =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL_S =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg02)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
8.修改listener.ora文件
主库:https://www.cndba.cn/hbhe0316/article/5041
https://www.cndba.cn/hbhe0316/article/5041
[oracle@dg01 ~]$ cd $ORACLE_HOME/network/admin
[oracle@dg01 admin]$ cat listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg01)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
备库:
[oracle@dg02 admin]$ cat listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg02)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
9.启动主库和备库监听
主库:
[oracle@dg01 admin]$ lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 06-NOV-2021 10:26:45
Copyright (c) 1991, 2021, Oracle. All rights reserved.
Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/dg01/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg01)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 06-NOV-2021 10:26:46
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dg01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg01)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
备库
[oracle@dg02 ~]$ lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 06-NOV-2021 10:28:16
Copyright (c) 1991, 2021, Oracle. All rights reserved.
Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/dg02/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg02)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg02)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 06-NOV-2021 10:28:16
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dg02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg02)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
10.启动主库和备库数据库
备库:
[oracle@dg02 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Nov 6 10:29:26 2021
Version 19.12.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2516581448 bytes
Fixed Size 9141320 bytes
Variable Size 654311424 bytes
Database Buffers 1845493760 bytes
Redo Buffers 7634944 bytes
SQL> alter database mount standby database;
Database altered.
SQL> alter database open read only;
Database altered.
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
主库:
SQL> STARTUP
ORACLE instance started.
Total System Global Area 2516581448 bytes
Fixed Size 9141320 bytes
Variable Size 1157627904 bytes
Database Buffers 1342177280 bytes
Redo Buffers 7634944 bytes
Database mounted.
Database opened.
11.验证主备库状态
主库:
SQL> set linesize 200
SQL> set pagesize 200
SQL> select open_mode,protection_mode,database_role,switchover_status from v$database;
OPEN_MODE PROTECTION_MODE DATABASE_ROLE
------------------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------
SWITCHOVER_STATUS
------------------------------------------------------------
READ WRITE MAXIMUM PERFORMANCE PRIMARY
TO STANDBY
备库:
SQL> set linesize 200
SQL> set pagesize 200
SQL> select open_mode,protection_mode,database_role,switchover_status from v$database;
OPEN_MODE PROTECTION_MODE DATABASE_ROLE
------------------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------
SWITCHOVER_STATUS
------------------------------------------------------------
READ ONLY WITH APPLY MAXIMUM PERFORMANCE PHYSICAL STANDBY
NOT ALLOWED
版权声明:本文为博主原创文章,未经博主允许不得转载。
Linux,oracle