[20160126]建立loopback link问题.txt

[20160126]建立loopback link问题.txt

--今天为了测试的需要,我想建立loop link。执行如下:

SCOTT@book> @ &r/ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

CREATE PUBLIC DATABASE LINK loopback USING 'localhost:1521/book';

SCOTT@book> select * from dept@loopback;
select * from dept@loopback
                   *
ERROR at line 1:
ORA-12541: TNS:no listener

$ oerr ora 12541
12541, 00000, "TNS:no listener"
// *Cause: The connection request could not be completed because the listener
// is not running.
// *Action: Ensure that the supplied destination address matches one of
// the addresses used by the listener - compare the TNSNAMES.ORA entry with
// the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to
// go by way of an Interchange). Start the listener on the remote machine.

--奇怪给这么简单的问题给难住了。

$ rlsqlplus scott/book@127.0.0.1:1521/book
SQL*Plus: Release 11.2.0.4.0 Production on Tue Jan 26 09:19:33 2016
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-12541: TNS:no listener

$ rlsqlplus scott/book@192.168.100.78:1521/book
--通过。难道监听配置有什么问题吗?

$ netstat -tnlp | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp        0      0 192.168.100.78:1521         0.0.0.0:*                   LISTEN      24647/tnslsnr

--难道我要给在listener.ora加入127.0.0.1的IP吗? 试着加入看看:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle
DIAG_ADR_ENABLED_LISTENER=OFF

$ lsnrctl start

SYS@book> alter system register;
System altered.

$ netstat -tnlp | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp        0      0 192.168.100.78:1521         0.0.0.0:*                   LISTEN      24739/tnslsnr
tcp        0      0 127.0.0.1:1521              0.0.0.0:*                   LISTEN      24739/tnslsnr

$ rlsqlplus scott/book@127.0.0.1:1521/book
$ rlsqlplus scott/book@192.168.100.78:1521/book

--测试都可以通过。

SCOTT@book> select * from dept@loopback;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

--我对比别的机器发现在配置文件listener.ora 是写入主机名。设置修改主机名看看。

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
#      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
#      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = xxxxx)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle
DIAG_ADR_ENABLED_LISTENER=OFF

--再重新启动监听。

$ netstat -tnlp | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp        0      0 :::1521                     :::*                        LISTEN      24817/tnslsnr

--可以发现这个时候监听在该主机的任何接口。测试上面的语句通过。
--从这里看出一些小细节。在监听指定IP,仅仅在特定的IP上监听。而如果使用主机名可以在该机器的任意IP上监听。

时间: 2024-08-30 04:38:09

[20160126]建立loopback link问题.txt的相关文章

[20170712]建立dblink的问题.txt

[20170712]建立dblink的问题.txt SYS@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- -------------------------------------------------------------------------------- x86_64/Linux 2.4.xx   

[20160526]建立主键问题.txt

[20160526]建立主键问题.txt --生产系统有1个表没有主键,要求建立发现无法建立,有重复.而且这个索引查询是需要. --实际上可以限制以后的记录不再重复,以前我自己也遇到过,做一个记录. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- ---------------------

[20150626]建立索引pctfree=0.txt

[20150626]建立索引pctfree=0.txt --昨天看了链接: https://richardfoote.wordpress.com/2015/06/25/quiz-time-why-do-deletes-cause-an-index-to-grow-up-the-hill-backwards/ --自己测试看看来解答问题,不知道是否正确:-) 1.建立测试环境: SCOTT@test> @ver1 PORT_STRING                    VERSION    

[20150930]建立dg想到的....txt

[20150930]建立dg想到的....txt --前几天建立dataguard,这个项目主库是11g asm,而dataguard使用的是文件系统. --在dataguard的spfile文件中,配置了转换: SYS@xxxxdg> show parameter convert NAME                   TYPE    VALUE ---------------------- ------- ----------------------------------------

[20140928]数据库建立在内存中.txt

[20140928]数据库建立在内存中.txt --单位正好到了几台新机器,内存128G. --测试一下dbca slient建立数据库,因为完成后可以丢弃,把数据库建立在内存中. # mkdir -p /mnt/ramdisk # mount -t tmpfs -o size=8G tmpfs /mnt/ramdisk # su - oracle --检查环境变量是否设置正确 $ env | grep -i oracle USER=oracle LD_LIBRARY_PATH=/u01/app

建立dblink(database link)

database linke是建立一个数据库到另一个数据库的路径的对象,通过database link可以允许查询远程表,我理解可以算作一种分布式数据库的用法. database link是单向连接,既然它是一种对象,那自然可以在xxx_objects表中查询到相关的信息.建立database link前需要明确几个事情: 1.确认从建立方的server可以访问远程数据库. 2.需要在建立方的tnsnames中配置远程数据库连接串. 3.只有在服务端配置的连接才能在dblink中使用,如果仅是在

Python中使用不同编码读写txt文件详解

  这篇文章主要介绍了Python中使用不同编码读写txt文件详解,本文给出不同编码下的读写文件代码方法,需要的朋友可以参考下 代码如下: import os import codecs filenames=os.listdir(os.getcwd()) out=file("name.txt","w") for filename in filenames: out.write(filename.decode("gb2312").encode(&q

Oracle创建Database Link的两种方式详解_oracle

创建一个dblink,命名为dblink_name,从A数据库连到B数据库,B数据库的IP为192.168.1.73,端口为1521,实例名为oracle,登录名为tast,密码为test. 一菜单方式: 打开plsql,点击[File]-[New]-[Database link],打开如下图所示窗口 填好各项信息后,点击[Apply]即可完成Database Link的创建. 二SQL方式 -- Drop existing database link drop public database

oracle database link

原文整理自网络: database link基础知识 什么是database link? database link,它是用来更方便的一个数据库中访问另一个数据库(包括本地和远程的,道理是一样的),一开始,很多人会发生误解,其实是在本地建立的.即数据库连接只是连到别的数据库的快捷方式. database link是定义一个数据库到另一个数据库的路径的对象,database link允许你查询远程表及执行远程程序.在任何分布式环境里,database都是必要的.另外要注意的是database li