由于客户想要在新的生产环境中仍然使用原来的虚拟IP,所以当数据从原数据迁移到新的rac环境中后,我们需要修改虚拟IP,但原来是个单实例使用两上虚拟IP地址,现在是一个RAC数据库,如果是修改RAC的虚拟IP,那么不能做负载均衡,每次都连接到的是一个节点,由于SCAN IP使用/etc/hosts方式创建并且在安装生产环境时只指定了一个IP地址(10.138.130.155),所以这里需要通过增加SCAN IP地址(10.138.130.156/157)的方式来解决。
检查现在/etc/hosts配置:
[root@jyrac1 ~]# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 jyrac1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 10.138.130.151 jyrac1 10.138.130.152 jyrac2 10.138.130.153 jyrac1-vip 10.138.130.154 jyrac2-vip 10.10.10.1 jyrac1-priv 10.10.10.2 jyrac2-priv 10.138.130.155 jyrac-scan
查看scan ip所在节点,发现scan ip是在节点jyrac1上
[grid@jyrac1 ~]$ crsctl stat res -t -------------------------------------------------------------------------------- NAME TARGET STATE SERVER STATE_DETAILS -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- ora.ARCHDG.dg ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.CRSDG.dg ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.DATADG.dg ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.LISTENER.lsnr ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.asm ONLINE ONLINE jyrac1 Started ONLINE ONLINE jyrac2 Started ora.gsd OFFLINE OFFLINE jyrac1 OFFLINE OFFLINE jyrac2 ora.net1.network ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.ons ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.registry.acfs ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 -------------------------------------------------------------------------------- Cluster Resources -------------------------------------------------------------------------------- ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE jyrac1 ora.cvu 1 ONLINE ONLINE jyrac1 ora.jyrac.db 1 ONLINE ONLINE jyrac1 Open 2 ONLINE ONLINE jyrac2 Open ora.jyrac1.vip 1 ONLINE ONLINE jyrac1 ora.jyrac2.vip 1 ONLINE ONLINE jyrac2 ora.oc4j 1 ONLINE ONLINE jyrac1 ora.scan1.vip 1 ONLINE ONLINE jyrac1
查看scan ip所在的网卡,发现在eth0上
[root@jyrac1 ~]# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:50:56:B1:00:FD inet addr:10.138.130.151 Bcast:10.138.130.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:feb1:fd/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1077473 errors:0 dropped:0 overruns:0 frame:0 TX packets:9663995 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:103934930 (99.1 MiB) TX bytes:14096320534 (13.1 GiB) Base address:0x2800 Memory:fd5c0000-fd5e0000 eth0:1 Link encap:Ethernet HWaddr 00:50:56:B1:00:FD inet addr:10.138.130.153 Bcast:10.138.130.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Base address:0x2800 Memory:fd5c0000-fd5e0000 eth0:2 Link encap:Ethernet HWaddr 00:50:56:B1:00:FD inet addr:10.138.130.155 Bcast:10.138.130.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Base address:0x2800 Memory:fd5c0000-fd5e0000 eth1 Link encap:Ethernet HWaddr 00:50:56:B1:B6:3C inet addr:10.10.10.1 Bcast:10.10.10.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:feb1:b63c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:371756 errors:0 dropped:0 overruns:0 frame:0 TX packets:290401 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:193253619 (184.3 MiB) TX bytes:185131607 (176.5 MiB) Base address:0x2840 Memory:fd5a0000-fd5c0000 eth1:1 Link encap:Ethernet HWaddr 00:50:56:B1:B6:3C inet addr:169.254.202.209 Bcast:169.254.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Base address:0x2840 Memory:fd5a0000-fd5c0000
检查scan的配置信息
[grid@jyrac1 ~]$ srvctl config scan SCAN name: jyrac-scan, Network: 1/10.138.130.0/255.255.255.0/eth0 SCAN VIP name: scan1, IP: /jyrac-scan/10.138.130.155
检查scan listener状态
[grid@jyrac1 ~]$ srvctl status scan_listener SCAN Listener LISTENER_SCAN1 is enabled SCAN listener LISTENER_SCAN1 is running on node jyrac1
关闭scan listener
[grid@jyrac1 ~]$ srvctl stop scan_listener
关闭scan
[grid@jyrac1 ~]$ srvctl stop scan [grid@jyrac1 ~]$ srvctl status scan_listener SCAN Listener LISTENER_SCAN1 is enabled SCAN listener LISTENER_SCAN1 is not running
修改各节点的/etc/hosts文件增加两个scan ip地址
[root@jyrac1 ~]# vi /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 jyrac1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 10.138.130.151 jyrac1 10.138.130.152 jyrac2 10.138.130.153 jyrac1-vip 10.138.130.154 jyrac2-vip 10.10.10.1 jyrac1-priv 10.10.10.2 jyrac2-priv 10.138.130.155 jyrac-scan 10.138.130.156 jyrac-scan 10.138.130.157 jyrac-scan [root@jyrac2 /]# vi /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 jyrac2 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 10.138.130.151 jyrac1 10.138.130.152 jyrac2 10.138.130.153 jyrac1-vip 10.138.130.154 jyrac2-vip 10.10.10.1 jyrac1-priv 10.10.10.2 jyrac2-priv 10.138.130.155 jyrac-scan 10.138.130.156 jyrac-scan 10.138.130.157 jyrac-scan
修改scan配置,但一定要用root用户来执行
[root@jyrac1 ~]# cd /u01/app/product/11.2.0/crs/bin [root@jyrac1 bin]# ./srvctl modify scan -n jyrac-scan
检查scan配置
[grid@jyrac1 ~]$ srvctl config scan SCAN name: jyrac-scan, Network: 1/10.138.130.0/255.255.255.0/eth0 SCAN VIP name: scan1, IP: /jyrac-scan/10.138.130.155
对于/etc/hosts文件解析scan ip,因为不能做轮训的负载均衡,所以这时候scan ip就只能有一个了
但是在oracle linux 6.4中确会显示所有scan ip,例如:
[root@db1 ~]# cd /u01/app/11.2.0/grid/bin [root@db1 bin]# ./srvctl modify scan -n scan-ip [grid@db1 bin]$ srvctl config scan SCAN name: scan-ip, Network: 1/10.138.129.0/255.255.255.0/eth2 SCAN VIP name: scan1, IP: /scan-ip/10.138.129.105 SCAN VIP name: scan2, IP: /scan-ip/10.138.129.120 SCAN VIP name: scan3, IP: /scan-ip/10.138.129.121
具体操作请见:http://www.jydba.net/oracle-linux-11-2-rac-grid-infrastructure-add-scan-ip/
重启scan ,scan listener
[grid@jyrac1 ~]$ crsctl stat res -t -------------------------------------------------------------------------------- NAME TARGET STATE SERVER STATE_DETAILS -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- ora.ARCHDG.dg ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.CRSDG.dg ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.DATADG.dg ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.LISTENER.lsnr ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.asm ONLINE ONLINE jyrac1 Started ONLINE ONLINE jyrac2 Started ora.gsd OFFLINE OFFLINE jyrac1 OFFLINE OFFLINE jyrac2 ora.net1.network ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.ons ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 ora.registry.acfs ONLINE ONLINE jyrac1 ONLINE ONLINE jyrac2 -------------------------------------------------------------------------------- Cluster Resources -------------------------------------------------------------------------------- ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE jyrac2 ora.cvu 1 ONLINE ONLINE jyrac1 ora.jyrac.db 1 ONLINE ONLINE jyrac1 Open 2 ONLINE ONLINE jyrac2 Open ora.jyrac1.vip 1 ONLINE ONLINE jyrac1 ora.jyrac2.vip 1 ONLINE ONLINE jyrac2 ora.oc4j 1 ONLINE ONLINE jyrac1 ora.scan1.vip 1 ONLINE ONLINE jyrac2
手动增加scan ip
[root@jyrac1 bin]# ./crsctl stat res ora.scan1.vip -p > /tmp/2.txt [root@jyrac1 bin]# ./crsctl stat res ora.scan1.vip -p > /tmp/3.txt [root@jyrac1 bin]# vi /tmp/2.txt NAME=ora.scan2.vip TYPE=ora.scan_vip.type ACL=owner:root:rwx,pgrp:root:r-x,other::r--,group:oinstall:r-x,user:grid:r-x ACTION_FAILURE_TEMPLATE= ACTION_SCRIPT= ACTIVE_PLACEMENT=1 AGENT_FILENAME=%CRS_HOME%/bin/orarootagent%CRS_EXE_SUFFIX% AUTO_START=restore CARDINALITY=1 CHECK_INTERVAL=1 CHECK_TIMEOUT=120 DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_vip) ELEMENT(HOSTING_MEMBERS=%HOSTING_MEMBERS%) DEGREE=1 DESCRIPTION=Oracle SCAN VIP resource ENABLED=1 FAILOVER_DELAY=0 FAILURE_INTERVAL=0 FAILURE_THRESHOLD=0 GEN_USR_ORA_STATIC_VIP= GEN_USR_ORA_VIP= HOSTING_MEMBERS= LOAD=1 LOGGING_LEVEL=1 NLS_LANG= NOT_RESTARTING_TEMPLATE= OFFLINE_CHECK_INTERVAL=0 PLACEMENT=balanced PROFILE_CHANGE_TEMPLATE= RESTART_ATTEMPTS=0 SCAN_NAME=jyrac-scan SCRIPT_TIMEOUT=60 SERVER_POOLS=* START_DEPENDENCIES=hard(ora.net1.network) dispersion:active(type:ora.scan_vip.type) pullup(global:ora.net1.network) START_TIMEOUT=120 STATE_CHANGE_TEMPLATE= STOP_DEPENDENCIES=hard(intermediate:ora.net1.network) STOP_TIMEOUT=0 TYPE_VERSION=1.1 UPTIME_THRESHOLD=1h USR_ORA_ENV= USR_ORA_VIP=10.138.130.156 VERSION=11.2.0.4.0 ~ "/tmp/2.txt" 43L, 1092C written [root@jyrac1 bin]# ./crsctl add resource ora.scan2.vip -type ora.scan_vip.type -file /tmp/2.txt [root@jyrac1 bin]# vi /tmp/3.txt NAME=ora.scan3.vip TYPE=ora.scan_vip.type ACL=owner:root:rwx,pgrp:root:r-x,other::r--,group:oinstall:r-x,user:grid:r-x ACTION_FAILURE_TEMPLATE= ACTION_SCRIPT= ACTIVE_PLACEMENT=1 AGENT_FILENAME=%CRS_HOME%/bin/orarootagent%CRS_EXE_SUFFIX% AUTO_START=restore CARDINALITY=1 CHECK_INTERVAL=1 CHECK_TIMEOUT=120 DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_vip) ELEMENT(HOSTING_MEMBERS=%HOSTING_MEMBERS%) DEGREE=1 DESCRIPTION=Oracle SCAN VIP resource ENABLED=1 FAILOVER_DELAY=0 FAILURE_INTERVAL=0 FAILURE_THRESHOLD=0 GEN_USR_ORA_STATIC_VIP= GEN_USR_ORA_VIP= HOSTING_MEMBERS= LOAD=1 LOGGING_LEVEL=1 NLS_LANG= NOT_RESTARTING_TEMPLATE= OFFLINE_CHECK_INTERVAL=0 PLACEMENT=balanced PROFILE_CHANGE_TEMPLATE= RESTART_ATTEMPTS=0 SCAN_NAME=jyrac-scan SCRIPT_TIMEOUT=60 SERVER_POOLS=* START_DEPENDENCIES=hard(ora.net1.network) dispersion:active(type:ora.scan_vip.type) pullup(global:ora.net1.network) START_TIMEOUT=120 STATE_CHANGE_TEMPLATE= STOP_DEPENDENCIES=hard(intermediate:ora.net1.network) STOP_TIMEOUT=0 TYPE_VERSION=1.1 UPTIME_THRESHOLD=1h USR_ORA_ENV= USR_ORA_VIP=10.138.130.157 VERSION=11.2.0.4.0 ~ "/tmp/3.txt" 43L, 1092C written [root@jyrac1 bin]# ./crsctl add resource ora.scan2.vip -type ora.scan_vip.type -file /tmp/2.txt [root@jyrac1 bin]# ./crsctl add resource ora.scan3.vip -type ora.scan_vip.type -file /tmp/3.txt
手动增加scan listener
[root@jyrac1 bin]# ./crsctl stat res ora.LISTENER_SCAN1.lsnr -p > /tmp/l_2.txt [root@jyrac1 bin]# ./crsctl stat res ora.LISTENER_SCAN1.lsnr -p > /tmp/l_3.txt [root@jyrac1 bin]# vi /tmp/l_3.txt NAME=ora.LISTENER_SCAN3.lsnr TYPE=ora.scan_listener.type ACL=owner:grid:rwx,pgrp:oinstall:r-x,other::r-- ACTION_FAILURE_TEMPLATE= ACTION_SCRIPT= ACTIVE_PLACEMENT=1 AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX% AUTO_START=restore CARDINALITY=1 CHECK_INTERVAL=60 CHECK_TIMEOUT=120 DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_listener) PROPERTY(LISTENER_NAME=PARSE(%NAME%, ., 2)) DEGREE=1 DESCRIPTION=Oracle SCAN listener resource ENABLED=1 ENDPOINTS=TCP:1521 FAILOVER_DELAY=0 FAILURE_INTERVAL=0 FAILURE_THRESHOLD=0 HOSTING_MEMBERS= LOAD=1 LOGGING_LEVEL=1 NLS_LANG= NOT_RESTARTING_TEMPLATE= OFFLINE_CHECK_INTERVAL=0 PLACEMENT=balanced PORT=1521 PROFILE_CHANGE_TEMPLATE= REGISTRATION_INVITED_NODES= REGISTRATION_INVITED_SUBNETS= RESTART_ATTEMPTS=5 SCRIPT_TIMEOUT=60 SERVER_POOLS=* START_DEPENDENCIES=hard(ora.scan3.vip) dispersion:active(type:ora.scan_listener.type) pullup(ora.scan3.vip) START_TIMEOUT=180 STATE_CHANGE_TEMPLATE= STOP_DEPENDENCIES=hard(intermediate:ora.scan3.vip) STOP_TIMEOUT=0 TYPE_VERSION=2.2 UPTIME_THRESHOLD=1d USR_ORA_ENV= USR_ORA_OPI=false VERSION=11.2.0.4.0 "/tmp/l_3.txt" 44L, 1091C written [root@jyrac1 bin]# vi /tmp/l_2.txt NAME=ora.LISTENER_SCAN2.lsnr TYPE=ora.scan_listener.type ACL=owner:grid:rwx,pgrp:oinstall:r-x,other::r-- ACTION_FAILURE_TEMPLATE= ACTION_SCRIPT= ACTIVE_PLACEMENT=1 AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX% AUTO_START=restore CARDINALITY=1 CHECK_INTERVAL=60 CHECK_TIMEOUT=120 DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_listener) PROPERTY(LISTENER_NAME=PARSE(%NAME%, ., 2)) DEGREE=1 DESCRIPTION=Oracle SCAN listener resource ENABLED=1 ENDPOINTS=TCP:1521 FAILOVER_DELAY=0 FAILURE_INTERVAL=0 FAILURE_THRESHOLD=0 HOSTING_MEMBERS= LOAD=1 LOGGING_LEVEL=1 NLS_LANG= NOT_RESTARTING_TEMPLATE= OFFLINE_CHECK_INTERVAL=0 PLACEMENT=balanced PORT=1521 PROFILE_CHANGE_TEMPLATE= REGISTRATION_INVITED_NODES= REGISTRATION_INVITED_SUBNETS= RESTART_ATTEMPTS=5 SCRIPT_TIMEOUT=60 SERVER_POOLS=* START_DEPENDENCIES=hard(ora.scan2.vip) dispersion:active(type:ora.scan_listener.type) pullup(ora.scan2.vip) START_TIMEOUT=180 STATE_CHANGE_TEMPLATE= STOP_DEPENDENCIES=hard(intermediate:ora.scan2.vip) STOP_TIMEOUT=0 TYPE_VERSION=2.2 UPTIME_THRESHOLD=1d USR_ORA_ENV= USR_ORA_OPI=false VERSION=11.2.0.4.0 "/tmp/l_2.txt" 44L, 1091C written [root@jyrac1 bin]# ./crsctl add resource ora.LISTENER_SCAN2.lsnr -type ora.scan_listener.type -file /tmp/l_2.txt [root@jyrac1 bin]# ./crsctl add resource ora.LISTENER_SCAN3.lsnr -type ora.scan_listener.type -file /tmp/l_3.txt
使用增加的scan ip连接数据库,登录不了数据库
C:\Users\Administrator>sqlplus "system/system"@10.138.130.156:1521/jyrac SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 22:18:58 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务 请输入用户名: ERROR: ORA-12560: TNS: 协议适配器错误 请输入用户名: ERROR: ORA-12560: TNS: 协议适配器错误 SP2-0157: 在 3 次尝试之后无法连接到 ORACLE, 退出 SQL*Plus C:\Users\Administrator>
修改rac所有数据库实例中的listener_networks参数
SQL> alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=10.138.130.153:1521)(REMOTE_LISTENER=10.138.130.155:1521))','((NAME=network2)(LOCAL_LISTENER=10.138.130.153:1521)(REMOTE_LISTENER=10.138.130.156:1521))','((NAME=network3)(LOCAL_LISTENER=10.138.130.153:1521)(REMOTE_LISTENER=10.138.130.157:1521))' sid='jyrac1'; System altered. SQL> alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=10.138.130.154:1521)(REMOTE_LISTENER=10.138.130.155:1521))','((NAME=network2)(LOCAL_LISTENER=10.138.130.154:1521)(REMOTE_LISTENER=10.138.130.156:1521))','((NAME=network3)(LOCAL_LISTENER=10.138.130.154:1521)(REMOTE_LISTENER=10.138.130.157:1521))' sid='jyrac2'; System altered. SQL> show parameter listener NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ listener_networks string ((NAME=network1)(LOCAL_LISTENE R=10.138.130.152:1521)(REMOTE_ LISTENER=10.138.130.155:1521)) , ((NAME=network2)(LOCAL_LISTE NER=10.138.130.152:1521)(REMOT E_LISTENER=10.138.130.156:1521 )), ((NAME=network3)(LOCAL_LIS TENER=10.138.130.152:1521)(REM OTE_LISTENER=10.138.130.157:15 21)) local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST= NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ 10.138.130.153)(PORT=1521)) remote_listener string jyrac-scan:1521
再次使用增加的scan ip连接数据库,成功登录
C:\Users\Administrator>sqlplus "system/system"@10.138.130.156:1521/jyrac SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 22:25:24 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. 连接到: 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> exit 从 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 断开 C:\Users\Administrator>sqlplus "system/system"@10.138.130.157:1521/jyrac SQL*Plus: Release 11.2.0.4.0 Production on 星期二 11月 22 22:25:36 2016 Copyright (c) 1982, 2013, Oracle. All rights reserved. 连接到: 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>