SYS@ boston> alter system set global_names=true; SYS@ boston> create database link oibs1 connect to test identified by oracle using 'oibs1'; Database link created. SYS@ boston> select * from t1@oibs1; ID ---------- 1 2 SYS@ boston> create database link oibs connect to test identified by oracle using 'oibs1'; Database link created. Elapsed: 00:00:00.03 SYS@ boston> select * from t1@oibs; select * from t1@oibs * ERROR at line 1: ORA-02085: database link OIBS connects to OIBS1
18:50:14 SYS@ boston> show parameter service_names NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string boston
修改service_names
1 2 3
19:56:42 SYS@ boston> alter system set service_names='chicago.us.oracle'; System altered. Elapsed: 00:00:00.23
查看service_names已修改
1 2 3 4
19:56:56 SYS@ boston> show parameter service_names NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string chicago.us.oracle
[oracle@dax-mysql-slave admin]$ lsnrctl status ...... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dax-mysql-slave)(PORT=1521))) Services Summary... Service "boston" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.us.oracle" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully
再次修改service_names
1 2 3
19:56:59 SYS@ boston> alter system set service_names='chicago.us.oracle.com'; System altered. Elapsed: 00:00:00.12
查看监听
1 2 3 4 5 6 7 8 9 10 11
[oracle@dax-mysql-slave admin]$ lsnrctl status ...... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dax-mysql-slave)(PORT=1521))) Services Summary... Service "boston" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.us.oracle.com" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully
chicago.us.oracle的服务名被替代为chicago.us.oracle.com
5.2、在db_domain存在的情况下(如果没有,可以自己修改,修改该值需要重启库)
先修改db_domain值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
22:18:05 SYS@ boston> alter system set db_domain='us.oracle.cn' scope=spfile; System altered. 22:18:22 SYS@ boston> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. 22:18:38 SYS@ boston> startup ORACLE instance started. Total System Global Area 1603411968 bytes Fixed Size 2253664 bytes Variable Size 503319712 bytes Database Buffers 1090519040 bytes Redo Buffers 7319552 bytes Database mounted. Database opened. 22:19:36 SYS@ boston> show parameter db_domain NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_domain string us.oracle.cn
修改service_names,在不指定后缀的情况下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
22:45:57 SYS@ boston> alter system set service_names='chicago'; System altered. Elapsed: 00:00:00.11 22:46:45 SYS@ boston> show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string chicago
[oracle@dax-mysql-slave admin]$ lsnrctl status ...... Services Summary... Service "boston.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully
22:46:49 SYS@ boston> alter system set service_names='chicago.cn.oracle.com'; System altered. Elapsed: 00:00:00.15 22:48:40 SYS@ boston> show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string chicago.cn.oracle.com [oracle@dax-mysql-slave admin]$ lsnrctl status ..... Services Summary... Service "boston.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.cn.oracle.com" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully