客户端配置tnsnames
[oracle@ha admin]$ more tnsnames.ora
tt=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.111)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
[oracle@ha admin]$ tnsping tt
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 08-MAR-2016 14:45:02
Copyright (c) 1997, 2013, Oracle. All rights reserved.
Used parameter files:
/oracle/app/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.111)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (0 msec)
[oracle@ha admin]$
测试连接
oracle@ha admin]$ sqlplus system/oracle@tt
SQL*Plus: Release 11.2.0.4.0 Production on Tue Mar 8 14:37:13 2016
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, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string orcl
db_unique_name string orcl
global_names boolean FALSE
instance_name string orcl
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string orcl
创建一个名为ll的dblink
SQL> create public database link ll connect to sa identified by oracle using 'tt';
Database link created.
SQL> select * from dba_db_links;
OWNER DB_LINK USERNAME HOST CREATED
----------- --------------- ------------------- ------------------ ---------
PUBLIC LL SA tt 08-MAR-16
测试
oracle@ha admin]$ sqlplus sys/oracle as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Mar 8 14:50:56 2016
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, OLAP, Data Mining and Real Application Testing options
SQL> select * from sa.gg;
select * from sa.gg
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> select * from sa.gg@ll;
ID
----------
1
SQL>