把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(4)—— 修改 oracle11g rac 集群的 scanIP
在生产环境中迁移数据时,需要先创建目标数据库集群,数据迁移成功后还需要使用原来的 IP 地址访问 oracle 数据库,这样原来的客户端不需要做任何改变。此时,需要改变目标数据库集群的 scanIP 为源数据库的 IP 地址。
当客户端应用程序使用 scanIP 访问数据库时,scan listener 会将连接转发到 local listener 上。 节点 rac1 的本地监听内容如下:
LISTENER_RAC1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1-vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521)
(IP=FIRST))))
一、查看scan ip的状态信息
[grid@rac1 ~]$ srvctl config scan
SCAN name: rac-scan, Network: 1/192.168.1.0/255.255.255.0/ens34
SCAN VIP name: scan1, IP: /rac-scan/192.168.1.201
二、停止 scan_listener 和 scan
srvctl stop scan_listener
srvctl stop scan
[grid@rac1 ~]$ srvctl stop scan_listener
[grid@rac1 ~]$ srvctl stop scan
[grid@rac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
[grid@rac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is not running
[grid@rac1 ~]$ crs_stat -t | grep scan
ora.scan1.vip ora....ip.type OFFLINE OFFLINE
[grid@rac1 ~]$ crs_stat -t | grep lsnr
ora....ER.lsnr ora....er.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type OFFLINE OFFLINE
ora....C1.lsnr application ONLINE ONLINE rac1
ora....C2.lsnr application ONLINE ONLINE rac2
三、修改 /etc/hosts 文件中的 scanIP(所有节点)
[root@rac1 ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.101 rac1
192.168.1.102 rac2
10.1.1.101 rac1-priv
10.1.1.102 rac2-priv
192.168.1.111 rac1-vip
192.168.1.112 rac2-vip
192.168.1.221 my-racscan
四、修改 DNS 服务的配置信息
[root@rac1 ~]
$TTL 86400
@ IN SOA dns.oracle.com. root.oracle.com. (
19997022700 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ) ; minimum
@ IN NS dns.oracle.com.
101 IN PTR dns.oracle.com.
101 IN PTR rac1.oracle.com.
102 IN PTR rac2.oracle.com.
221 IN PTR scan.oracle.com.
[root@rac1 ~]
$TTL 86400
@ IN SOA dns.oracle.com. root.oracle.com. (
42 ; serial
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum
@ IN NS dns.oracle.com.
dns IN A 192.168.1.101
rac1 IN A 192.168.1.101
rac2 IN A 192.168.1.102
scan IN A 192.168.1.221
[root@rac1 ~]
[root@rac1 ~]
Server: 192.168.1.101
Address: 192.168.1.101
221.1.168.192.in-addr.arpa name = scan.oracle.com.
[root@rac1 ~]
Server: 192.168.1.101
Address: 192.168.1.101
Name: scan.oracle.com
Address: 192.168.1.221
五、修改 SCAN 名称
[root@rac1 ~]
[root@rac1 bin]
/u01/app/11.2.0/grid/bin
[root@rac1 bin]
[root@rac1 bin]
SCAN 名称: my-racscan, 网络: 1/192.168.1.0/255.255.255.0/ens34
SCAN VIP 名称: scan1, IP: /my-racscan/192.168.1.221
六、启动 scan 和 scan_listener
[grid@rac1 admin]$ srvctl start scan
[grid@rac1 admin]$ srvctl start scan_listener
[grid@rac1 admin]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac1
[grid@rac1 admin]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac1
[grid@rac1 admin]$ crs_stat -t | grep scan
ora.scan1.vip ora....ip.type ONLINE ONLINE rac1
[grid@rac1 admin]$ crs_stat -t | grep lsnr
ora....ER.lsnr ora....er.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora....C2.lsnr application ONLINE ONLINE rac2
七、测试:使用新的 scanIP 访问数据库
1、测试新的 scanIP 是否能够使用
[grid@rac2 ~]$ ping 192.168.1.221
PING 192.168.1.221 (192.168.1.221) 56(84) bytes of data.
64 bytes from 192.168.1.221: icmp_seq=1 ttl=64 time=2.84 ms
64 bytes from 192.168.1.221: icmp_seq=2 ttl=64 time=0.267 ms
64 bytes from 192.168.1.221: icmp_seq=3 ttl=64 time=14.3 ms
^C
--- 192.168.1.221 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.267/5.827/14.374/6.134 ms
2、使用新的 scanIP 访问数据库
[oracle@rac1 ~]$ sqlplus sys/oracle@192.168.1.221/hisdb as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Jun 19 10:24:11 2022
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
八、解决 ORA-12514 错误
1、在节点 rac1 执行如下操作
SQL> show parameter remote_listener
NAME TYPE VALUE
remote_listener string
SQL> alter system set remote_listener='';
System altered.
SQL> alter system register;
System altered.
SQL> alter system set remote_listener='my-racscan:1521';
System altered.
SQL> show parameter remote_listener
NAME TYPE VALUE
remote_listener string my-racscan:1521
2、测试:使用新的 scanIP 访问数据库
[oracle@rac2 ~]$ sqlplus sys/oracle@192.168.1.221/hisdb as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 22 13:57:47 2022
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL>
|