oracle 网络配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 网络配置相关的知识,希望对你有一定的参考价值。
网络:
服务器端:一定要启动监听程序
无配置启动监听程序:rm -f $ORACLE_HOME/network/admin/listener.ora
查看监听状态:lsnrctl status
启动监听:lsnrctl start
客户端:使用服务命名(网络连接字符串)
cat /etc/hosts
------------------------------------------------------------
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
172.25.254.250 foundation0.ilt.example.com
------------------------------------------------------------
客户端使用简单连接:
sqlplus scott/[email protected]:1521/primary
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
使用监听配置文件:可以控制IP、端口、监听名字
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------
LISTENER=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=1521))
)
-------------------------------------------------------------
使用客户端配置文件:
vi $ORACLE_HOME/network/admin/tnsnames.ora
-------------------------------------------------------------
250=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME = primary)
)
)
-------------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
修改监听的端口号:
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------
LISTENER=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788))
)
-------------------------------------------------------------
pmon默认情况只能向1521注册实例!
使用local_listener指明注册实例的详细信息:
alter system set local_listener=‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788)))‘;
使用remote_listener将实例注册到远程监听
alter system set remote_listener=‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.0.10)(PORT=1521)))‘;
客户端的端口号需要同步修改:
vi $ORACLE_HOME/network/admin/tnsnames.ora
-------------------------------------------------------------
250=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788))
(CONNECT_DATA=
(SERVICE_NAME = primary)
)
)
-------------------------------------------------------------
修改监听的名字:对客户端没有任何影响
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------
LISTENER_DB01 =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788))
)
-------------------------------------------------------------
操作非默认命名的监听:
lsnrctl status LISTENER_DB01
lsnrctl status LISTENER_DB01
lsnrctl status LISTENER_DB01
激活pmon注册实例信息到监听程序
SQL> alter system register;
使用pmon注册实例信息到监听程序,属于动态注册,没有实例的情况下是不能使用oracle的网络!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在数据库停止的状态如果向使用oracle的网络,需要静态注册
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------
LISTENER=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = primary) #数据库唯一名+域名,db_unique_name+db_domain
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = db01) # $ORACLE_SID,决定寻找口令文件和参数文件的后缀
)
)
-------------------------------------------------------------
客户端的故障转移配置:服务器异常时客户端的连接不中断
vi $ORACLE_HOME/network/admin/tnsnames.ora
-------------------------------------------------------------
250=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788))
(CONNECT_DATA=
(SERVER = DEDICATED)
(SERVICE_NAME = primary)
(FAILOVER_MODE =
(TYPE = select)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
)
)
)
-------------------------------------------------------------
查看会话是否支持故障转移:
select USERNAME,FAILOVER_TYPE,FAILOVER_METHOD,FAILED_OVER
from v$session where username=‘SCOTT‘;
预衍生服务进程:
vi $ORACLE_HOME/network/admin/listener.ora
-------------------------------------------------------------
LISTENER=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = primary)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = db01)
(PRESPAWN_MAX = 10)
(PRESPAWN_LIST =
(PRESPAWN_DESC =
(PROTOCOL = tcp)
(POOL_SIZE = 10)
(TIMEOUT = 1)
)
)
)
)
-------------------------------------------------------------
配置共享连接:
1.允许服务器启动共享服务进程
alter system set shared_servers=5;
2.允许client端以共享方式连接服务器
alter system set shared_server_sessions=2000;
3.允许服务器启动调度器
SQL> select * from v$dispatcher;
alter system set dispatchers=‘(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=56352)(DISPATCHERS=5))‘;
vi $ORACLE_HOME/network/admin/tnsnames.ora
-------------------------------------------------------------
test =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.25.254.250)(PORT=7788))
(CONNECT_DATA=
#(server = DEDICATED)
#(server = SHARED)
(SERVICE_NAME = primary)
)
)
-------------------------------------------------------------
数据库链接:可以在sql语句级别建立网络连接同时获得多个数据库中的数据
SQL> grant create database link to scott;
使用本地户名口令到远程进行安全审核:动态安全审核
SQL> create database link link_254_scott using ‘250‘;
静态安全审核
SQL> create database link link_254_scott
connect to scott identified by lion
using ‘250‘;
共有数据库链接:
SQL> conn / as sysdba
SQL> create public database link link_254_scott using ‘250‘;
本文出自 “梁小明的博客” 博客,请务必保留此出处http://7038006.blog.51cto.com/7028006/1847126
以上是关于oracle 网络配置的主要内容,如果未能解决你的问题,请参考以下文章