oracle 03-04 网络
Posted 世界树
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 03-04 网络相关的知识,希望对你有一定的参考价值。
Configuring the Oracle Network Environment
Objectives
After completing this lesson, you should be able to:
• Use Enterprise Manager Cloud Control and Oracle Net
Manager to:
– Create additional listeners
– Create Oracle Net Service aliases
– Control Oracle Net Listener
• Use the Listener Control Utility to manage Oracle Net
Listener
• Use tnsping to test Oracle Net connectivity
• Identify when to use shared servers and when to use
dedicated servers
监听用于聆听客户端连接请求,一旦链接成功,监听就不再发挥作用
Establishing Oracle Network Connections
To make a client or middle-tier connection, Oracle Net requires
the client to know the:
• Host where the listener is running 主机名
• Port that the listener is monitoring 端口号 TCP服务中默认端口号 1521 防火墙要将1521例如白名单
• Protocol 协议 that the listener is using 主要是TCP/IP协议
• Name of the service that the listener is handling
Name Resolution 名称解析
flowers-server
CONNECT jsmith/jspass@finflowers
finflowers =(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=flowers-server)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=finance.us.flowers.com)))
LISTENER
port 1521
Name resolution
finance
[oracle@yf /]$ echo $ORACLE_SID 查看当前数据库名称
orcl
Naming Methods
Oracle Net supports several methods of resolving connection
information:
• Easy connect naming: Uses a TCP/IP connect string 简易链接模式
• Local naming: Uses a local configuration file 本地链接方式
• Directory naming: Uses a centralized 目录命名方式
LDAP-compliant directory server
• External naming: Uses a supported non-Oracle naming 第三方链接
service
Client/application server
Oracle Net
Oracle Net configuration files
Easy Connect 简单链接方式
• Is enabled by default
• Requires no client-side configuration
• Supports only TCP/IP (no SSL)
• Offers no support for advanced connection options such as:
– Connect-time failover 不支持链接故障转移
– Source routing 不支持原目标路由
– Load balancing 不支持负载均衡
SQL> CONNECT hr/hr@db.us.oracle.com:1521/dba11g
SQL> CONNECT hr/hr@db.us.oracle.com主机名:1521监听端口号/dba11g数据库服务名
[oracle@yf ~]$ sqlplus hr/hr@yf.example.com:1521/orcl
No Oracle Net configuration files
Local Naming 本地命名方式
• Requires a client-side names-resolution file
• Supports all Oracle Net protocols
• Supports advanced connection options such as:
– Connect-time failover 支持链接故障转移
– Source routing 支持原目标路由
– Load balancing 支持负载均衡
SQL> CONNECT hr/hr@orcl
Oracle Net
configuration files
[oracle@yf ~]$ netmgr 配置建议命名方式
oracle@yf ~]$ cd $ORACLE_HOME/network/admin
[oracle@yf admin]$ ls
samples shrept.lst tnsnames.ora
[oracle@yf admin]$ more tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/18c/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = yf.example.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
[oracle@yf admin]$
Directory Naming 目录命名
• Requires LDAP with Oracle Net names resolution
information loaded:
– Oracle Internet Directory
– Microsoft Active Directory Services
• Supports all Oracle Net protocols
• Supports advanced connection options
SQL> CONNECT hr/hr@orcl
LDAP directory
Oracle Net
configuration files
External Naming Method 第三方命名
• Uses a supported non-Oracle naming service
• Includes:
– Network Information Service (NIS) External Naming
– Distributed Computing Environment (DCE) Cell Directory
Services (CDS)
Oracle Net
Tools for Configuring and Managing 监听配置工具
Oracle Net Services
• Enterprise Manager Net Services Administration page
• Oracle Net Manager
• Oracle Net Configuration Assistant
• Listener Control Utility
Using Oracle Net Configuration Assistant
[oracle@yf admin]$ netca 启动netca
监听命令
Using the Listener Control Utility
$ lsnrctl 监听命令
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 08-OCT-2014 10:07:23
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> help
The following operations are available
An asterisk (*) denotes a modifier or extended command:
start启动 stop停止 status检查 services
version reload save_config trace
spawn quit exit set*
show*
Listener Control Utility Syntax
Commands for the Listener Control Utility can be issued from
the command line or from the lsnrctl prompt.
• Command-line syntax:
• Prompt syntax:
$ lsnrctl <command name>
$ lsnrctl start
$ lsnrctl status
LSNRCTL> <command name>
LSNRCTL> start
LSNRCTL> status
动态注册与静态
在启动监听时没有描述数据库服务名时则动态注册
需要由后台进程lreg对数据库服务进行动态监听注册
Advanced Connection Options
Oracle Net supports the following advanced connection options
with local and directory naming:
• Connect-time failover
• Load balancing
• Source routing
Testing Oracle Net Connectivity
The tnsping utility that tests Oracle Net service aliases:
• Ensures connectivity between the client and the Oracle
Net Listener
• Does not verify that the requested service is available
• Supports Easy Connect Names Resolution:
• Supports local and directory naming:
tnsping host01.example.com:1521/orcl
tnsping orcl
[oracle@yf admin]$ tnsping test 连接测试 test是连接字符串
Comparing Dedicated Server and 数据库服务配置
Shared Server Configurations
• Dedicated专属模式 server configuration: One server process for
each client
• Shared共享模式 server configuration: A small pool of server
processes can serve a large number of clients
专属模式与共享模式的配置
PGA是由UGA加堆栈空间stwck构成的
配置完共享模式后PGA中的UGA会移动到SGA,此时可配置巨大池large-pool将SGA中的UGA调入
Shared Server Configuration Considerations
Certain types of database work must not be performed using
shared servers:
• Database administration
• Backup and recovery operations
• Batch processing and bulk load operations
• Data warehouse operations
Dispatcher Dedicated server
process
硬件充足则用专属模式,响应时间块,但耗资源。
Configuring Communication
Between Databases 数据库间的通信
• Sending data or messages between sites requires network
configuration on both sites.
• You must configure the following:
– Network connectivity (for example, tnsnames.ora)
– Database links
CREATE DATABASE LINK创建数据库链接 <remote_global_name>
CONNECT TO <user> IDENTIFIED BY <pwd>
USING \'<connect_string_for_remote_db>\';
REMOTE_ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = host02.example.com)
(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl2.example.com)
)
)
CONNECT hr/hr@orcl1;
CREATE DATABASE LINK remote
CONNECT TO HR IDENTIFIED BY HR
USING \'REMOTE_ORCL\';
SELECT * FROM employees@remote
[oracle@yf ~]$ ps -ef|grep smon 查看后台进程命令
oracle 20753 1 0 10:37 ? 00:00:00 ora_smon_orcl
oracle 65252 64657 0 17:36 pts/2 00:00:00 grep --color=auto smon
SQL> create database link db_link2 connect to hr identified by oracle using \'demo\'; 从orcl远程连接到demo数据库
建立第二个监听:my_listener
端口号1525
主机名:使用hostname查看
静态注册orcl数据库服务
启动新的监听服务(注意需要使用自定义监听名称)
建立一个tnsnames名称:my_tns然后测试数据库orcl是否能通过新的监听连接到数据库(注意匹配端口号1521)
netmgr 打开图形化界面
[oracle@yf admin]$ cd $ORACLE_HOME/network/admin
[oracle@yf admin]$ pwd
/u01/app/oracle/product/18c/network/admin
[oracle@yf admin]$ ls
listener.ora samples shrept.lst tnsnames.ora
[oracle@yf admin]$ more listener.ora 查看监听文件
[oracle@yf admin]$ lsnrctl start my_listener 启动新建的my_listener监听
添加新的链接字符串my_tns
主机名要一致,端口号要一致
服务名就是orcl数据库的名称
[oracle@yf admin]$ more tnsnames.ora 查看tns情况
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/18c/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = yf.example.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
MY_TNS = 这里出现了新建的tns名
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = yf.example.com)(PORT = 1525))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
[oracle@yf admin]$ tnsping my_tns 测试新建的tns链接情况
TNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 10-JUN-2020 10:08:56
Copyright (c) 1997, 2018, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = yf.example.com)(PORT = 1525))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (80 msec) 链接成功
[oracle@yf admin]$ sqlplus hr/hr@my_tns 登陆sqlplus 用户名/密码@链接字符串
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Jun 10 10:10:55 2020
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
????????: ??? 6? 08 2020 17:43:51 +08:00
???:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> 至此用hr登陆数据库成功
以上是关于oracle 03-04 网络的主要内容,如果未能解决你的问题,请参考以下文章