公司机房搬迁,Data Guard 环境需要修改IP地址。 提前整理顺便测试一下。 虽然只有几步,但怕晚上头晕了出了纰漏。 整理好了,晚上直接按文档,一步一步操作就可以了。
一. IP 及数据库信息
修改之前:
主库:192.168.2.242
备库:192.168.2.243
修改之后:
主库:192.168.2.22
备库:192.168.2.23
数据库版本: 10.2.0.5
操作系统版本: Redhat 5.5
二. Shutdown 主备库实例及监听
2.1 shutdown 主库
SQL> select db_unique_name,open_mode from v$database;
DB_UNIQUE_NAME OPEN_MODE
------------------------------ ----------
xezf_pd READ WRITE
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
2.2 shutdown 备库
SQL> select db_unique_name,open_mode from v$database;
DB_UNIQUE_NAME OPEN_MODE
------------------------------ ----------
xezf_st MOUNTED
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
2.3 停主备库的监听
[oracle@dg1 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 20-DEC-2010 09:49:43
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg1)(PORT=1521)))
The command completed successfully
[oracle@dg1 ~]$
[oracle@dg2 ~]$ lsnrctl stop
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 20-DEC-2010 09:49:50
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg2)(PORT=1521)))
The command completed successfully
[oracle@dg2 ~]$
三. 修改服务器IP信息
3.1 主库操作
3.1.1修改IP
[root@dg1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.2.22 dg1
[root@dg1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=dg1
GATEWAY=192.168.2.1
[root@dg1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.2.255
HWADDR=84:2B:2B:67:43:B9
IPADDR=192.168.2.22
NETMASK=255.255.255.0
NETWORK=192.168.2.0
ONBOOT=yes
3.1.2 重启network
[root@dg1 ~]# service network restart
3.1.3修改监听信息
[oracle@dg1 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = xezf)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(GLOBAL_DBNAME = xezf)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
)
[oracle@dg1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
XEZF =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xezf)
)
)
XEZF_PD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.22)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = xezf)
)
)
XEZF_ST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.23)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = xezf)
)
)
LISTENER_XEZF =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
3.2 备库操作
3.2.1修改IP
[root@dg2 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.2.23 dg2
[root@dg2 ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=dg2
GATEWAY=192.168.2.1
[root@dg2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.2.255
HWADDR=00:1E:C9:DA:AE:95
IPADDR=192.168.2.23
NETMASK=255.255.255.0
NETWORK=192.168.2.0
ONBOOT=yes
3.2.2 重启network
[root@dg2 ~]# service network restart
3.2.3 修改监听信息
[oracle@dg2 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = xezf)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(GLOBAL_DBNAME = xezf)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg2)(PORT = 1521))
)
)
[oracle@dg2 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
xezf_pd =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.22)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = xezf)
)
)
xezf_st =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.23)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = xezf)
)
)
四. 启动Data Guard并验证同步
4.1 启动备库监听和实例
4.1.1 启动监听
[oracle@dg2 ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 20-DEC-2010 10:11:47
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.5.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg2)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg2)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date 20-DEC-2010 10:11:47
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/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg2)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "xezf" has 1 instance(s).
Instance "xezf", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@dg2 ~]$
4.1.2 启动实例至mount状态
[oracle@dg2 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Dec 20 10:12:34 2010
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 5251268608 bytes
Fixed Size 2103600 bytes
Variable Size 939525840 bytes
Database Buffers 4294967296 bytes
Redo Buffers 14671872 bytes
SQL> alter database mount standby database;
Database altered.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL>
4.2 启动主库监听和实例
4.2.1 启动主库监听
[oracle@dg1 ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 20-DEC-2010 10:15:23
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.5.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date 20-DEC-2010 10:15:23
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/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg1)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "xezf" has 1 instance(s).
Instance "xezf", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
4.2.2 启动主库实例至open状态
[oracle@dg1 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Dec 20 10:15:51 2010
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 5251268608 bytes
Fixed Size 2103600 bytes
Variable Size 939525840 bytes
Database Buffers 4294967296 bytes
Redo Buffers 14671872 bytes
Database mounted.
Database opened.
SQL>
4.3 验证主备库同步
4.3.1 检查归档目录是否有误
SQL> select error from v$archive_dest;
ERROR
-----------------------------------------------------------------
10 rows selected.
SQL>
正常,没有错误。
4.3.2 在主库手工切换归档
SQL> alter system switch logfile;
System altered.
4.3.3 查看主库归档情况
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
25
4.3.4 查看备库归档情况
SQL> select sequence#,applied from v$archived_log;
SEQUENCE# APP
---------- ---
1 YES
2 YES
3 YES
4 YES
4 YES
5 YES
5 YES
6 YES
6 NO
7 YES
8 YES
SEQUENCE# APP
---------- ---
9 YES
10 YES
11 YES
12 YES
13 YES
14 YES
15 YES
16 YES
17 YES
18 YES
19 YES
SEQUENCE# APP
---------- ---
20 YES
21 YES
22 YES
23 YES
24 YES
25 YES
28 rows selected.
主备一致,同步正常。 IP 修改成功。
------------------------------------------------------------------------------