Chinaunix首页 | 论坛 | 博客
  • 博客访问: 25708
  • 博文数量: 4
  • 博客积分: 91
  • 博客等级: 民兵
  • 技术积分: 56
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-10 15:25
文章分类

全部博文(4)

文章存档

2011年(4)

我的朋友

分类: Oracle

2011-03-30 10:19:10

1.配置sqlnet.ora文件 ($ORACLE_HOME/network/admin)目录下面 添加
  1. tcp.validnode_checking=yes
  2. tcp.invited_nodes=(192.168.123.1,192.168.123.123)

tcp.validnode_checking=yes  --打开ip检查
tcp.invited_nodes=(ip,ip) 可以连通数据库的ip

这里我们让192.168.123.1,192.168.123.123 这2台ip的主机可以访问数据库。

2.重启监听

  1. [oracle@test ~]$ lsnrctl

  2. LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 30-MAR-2011 00:39:39

  3. Copyright (c) 1991, 2005, Oracle. All rights reserved.

  4. Welcome to LSNRCTL, type "help" for information.

  5. LSNRCTL> stop
  6. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  7. The command completed successfully
  8. LSNRCTL> start
  9. Starting /oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

  10. TNSLSNR for Linux: Version 10.2.0.1.0 - Production
  11. Log messages written to /oracle/product/10.2.0/db_1/network/log/listener.log
  12. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test)(PORT=1521)))

  13. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  14. STATUS of the LISTENER
  15. ------------------------

  16. Alias LISTENER
  17. Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
  18. Start Date 30-MAR-2011 00:39:50
  19. Uptime 0 days 0 hr. 0 min. 0 sec
  20. Trace Level off
  21. Security ON: Local OS Authentication
  22. SNMP OFF
  23. Listener Log File /oracle/product/10.2.0/db_1/network/log/listener.log
  24. Listening Endpoints Summary...
  25.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test)(PORT=1521)))
  26. The listener supports no services
  27. The command completed successfully
  28. LSNRCTL>

测试一下主机192.168.123.123 能否连通数据库。

 

  1. [root@test ~]# ifconfig -a | grep 'inet addr'
  2.           inet addr:192.168.123.123 Bcast:192.168.123.255 Mask:255.255.255.0
  3.           inet addr:127.0.0.1 Mask:255.0.0.0
  4. [root@test ~]# su - oracle
  5. [oracle@test ~]$ tnsping testdb

  6. TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 30-MAR-2011 00:41:54

  7. Copyright (c) 1997, 2005, Oracle. All rights reserved.

  8. Used parameter files:
  9. /oracle/product/10.2.0/db_1/network/admin/sqlnet.ora


  10. Used TNSNAMES adapter to resolve the alias
  11. Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.123.123)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = testdb)))
  12. OK (20 msec)
  13. [oracle@test ~]$

是可以连数据库的。

3.把192.168.123.123 ip删除后,并重启监听。

 

  1. [oracle@test ~]$ tnsping testdb

  2. TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 30-MAR-2011 00:43:22

  3. Copyright (c) 1997, 2005, Oracle. All rights reserved.

  4. Used parameter files:
  5. /oracle/product/10.2.0/db_1/network/admin/sqlnet.ora


  6. Used TNSNAMES adapter to resolve the alias
  7. Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.123.123)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = testdb)))
  8. TNS-12537: TNS:connection closed
  9. [oracle@test ~]$

这时是不可以连通数据库的。

4. tcp.excluded_nodes=(ip1,ip2) 作用是限制这些ip访问。

  1. [oracle@test admin]$ cat sqlnet.ora
  2. tcp.validnode_checking=yes
  3. tcp.excluded_nodes=(192.168.123.123)
  4.  

现在192.168.123.123.主机无法连通数据库了。

  1. [oracle@test ~]$ tnsping testdb

  2. TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 30-MAR-2011 00:48:11

  3. Copyright (c) 1997, 2005, Oracle. All rights reserved.

  4. Used parameter files:
  5. /oracle/product/10.2.0/db_1/network/admin/sqlnet.ora


  6. Used TNSNAMES adapter to resolve the alias
  7. Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.123.123)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = testdb)))
  8. TNS-12537: TNS:connection closed
注:1 tcp.invited_nodes和tcp.excluded_nodes都存在是以tcp.invited_nodes 为主。
    2.每次修改后要重启监听
    3.数据库主机的ip不要忘记加入 tcp.invited_nodes中
阅读(5892) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~