`
1enny
  • 浏览: 70735 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

网络原理及其配置

 
阅读更多
oracle033

网络原理及其配置
oracle网络没有负载
1、Oracle监听拓扑结构
1521:oracle默认的端口号
监听的独立性
是独立的一个模块,没有和数据库实例存在长连接,只知道数据库存在哪个地方
连接建立流程
连接建立的过程:客户端向监听请求连接,监听器就把消息传递给数据库实例
数据库就为其创建一个serverPro 告诉监听器叫客户端连接哪个serverPro
客户端就连接serverPro进行用户名和密码校验,连接建立以后,监听就不再
起作用,以后客户端对数据库的操作就是在建立起来的会话中进行信息交换。
所以说监听负载很小,只是在大量请求连接的时候才会出现。
2、共享和专用服务器模式

3、Oracle数据库的几个名字
SQL> show parameter name

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string jiagulun// 数据库名
db_unique_name string jiagulun
global_names boolean FALSE
instance_name string jiagulun// 实例名
lock_name_space string
log_file_name_convert string
service_names string jiagulun// 服务名
SQL>
4、netca
listener.ora//服务器必须有的
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER=//监听器的名称
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
//监听器的地址包括使用的协议,主机名和端口号;这是服务端监听器配置文件信息
)
)

ADR_BASE_LISTENER = /u01/app/oracle

tnsnames.ora//客户端必须有的

[oracle@localhost admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

JIAGULUN=客户端的本地服务名,作用是用来客户端解析的:使用sqlplus hr/hr@jiagulun‘@’后面的来和这个名字进行对应的
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
//连接服务端的监听器需要的信息
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jiagulun)//数据库实例把数据库的服务名注册到监听器中,该名字必须和数据库服务名相同
)
)

[oracle@localhost admin]$

sqlnet.ora
5、双监听:双IP或者双端口,一个oracle可以起来多个监听,多网卡的问题
6、相关命令
lsnrctl status/stop/start
tnsping

7、 动态注册:数据服务自行加到监听中去,也可以使用 alter system register命令来强制注入
怎样才能验证他是注册进来的呢?
[oracle@localhost admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-JAN-2015 01:27:51

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Starting /u01/app/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 05-JAN-2015 01:27:52
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
The listener supports no services//这时候实例还未把服务注册到监听里面去
The command completed successfully
[oracle@localhost admin]$
可以通过 alter system register命令来强制注册:

[oracle@localhost admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-JAN-2015 01:29:30

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 05-JAN-2015 01:27:52
Uptime 0 days 0 hr. 1 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "jiagulun" has 1 instance(s).//监听中被注册了jiagulun服务进来了
Instance "jiagulun", status READY, has 1 handler(s) for this service...
Service "jiagulunXDB" has 1 instance(s).
Instance "jiagulun", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$
静态注册:解决不稳定问题使用多

global_names 等于服务名字,sid_name等于实例的名字


[oracle@localhost admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-JAN-2015 01:36:40

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Starting /u01/app/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 05-JAN-2015 01:36:40
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "jiagulun" has 1 instance(s).
Instance "jiagulun", status UNKNOWN, has 1 handler(s) for this service...
服务已启动就显示服务信息,因为静态注册的原因了;但是status显示是UNKNOWN因为静态注册并没有立马检测到实例是否启动了
The command completed successfully
[oracle@localhost admin]$

[oracle@localhost admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 05-JAN-2015 01:39:19

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 05-JAN-2015 01:36:40
Uptime 0 days 0 hr. 2 min. 38 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Services Summary...
Service "jiagulun" has 2 instance(s).
Instance "jiagulun", status UNKNOWN, has 1 handler(s) for this service...
Instance "jiagulun", status READY, has 1 handler(s) for this service...

Service "jiagulunXDB" has 1 instance(s).
Instance "jiagulun", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$

8、几种连接方式
sqlplus hr/hr //不走监听
sqlplus hr/hr@jiagulun
sqlplus hr/hr@192.168.0.100:1521/jiagulun//走监听了,没走tsnames.ora
//红色代表是用户名和密码,紫色代表ip和端口号,绿色代表服务名
sqlplus / as sysdba//不走监听

9、排错流程
tnsnames.ora
ip、端口号:服务器端 netstat -tulnp|grep 1521
service_names 与 show parameter service相同
tnsping
lsnrctl status
10、连接流程




















分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics