Home Database Mysql Tutorial 配置Oracle网络环境

配置Oracle网络环境

Jun 07, 2016 pm 05:39 PM
listener lsnrctl

当客户端通过网络以connect用户名/密码@连接字符串的形式连接oracle数据库时,需要监听程序的协助,当连接建立后,即使监听程序挂掉也不会影响已经建立好的连接

当客户端通过网络以"connect 用户名/密码@连接字符串"的形式连接oracle数据库时,需要监听程序的协助,当连接建立后,即使监听程序挂掉也不会影响已经建立好的连接。


用户连接oracle数据库服务器主要有两种方式:专有服务器连接和共享服务器连接

  • 在专用服务器模式中,对于每个运行数据库应用程序的用户进程都由执行Oracle 数据库服务器代码的专用服务器进程提供服务。

  • 每个服务器进程都有自己专用的PGA,这个PGA 在服务器进程启动时创建,对PGA 的访问权限仅限于该服务器进程,并且只能由代表该服务器进程的Oracle 代码对PGA 进行读写。

  • 在共享服务器模式中,不必为每个连接都提供一个专用服务器进程。分派程序将多个传入网络会话请求引到共享服务器进程池。共享服务器进程为所有客户机请求提供服务。

  • 多个客户端用户共享服务器进程,且UGA被转移到SGA(如果配置了共享池或者大型池),PGA将只剩下栈空间。


    配置和管理Oracle Net 的工具主要有dbconsole、netca、netmgr、和命令行工具(vi)


    Oracle Net支持多种连接解析方式:

  • Easy Connect(EZCONNECT)

  •    使用简便连接时,可提供Oracle Net 连接所需的所有信息作为连接字符串的一部分。简便连接的连接字符串采用以下形式:

       username/password@hostname[:port][/service_name]

       监听程序端口和服务名为可选项。如果未提供监听程序端口,Oracle Net 假定使用的是默认端口1521。如果未提供服务名,Oracle Net 假定连接字符串中提供的数据库服务名与主机名是相同的。

       SQL> conn hr/hr@192.168.0.90:1521/orcl.example.com

  • 本地命名(TNSNAMES)

  •    使用本地命名时,用户可提供Oracle Net 服务的别名。Oracle Net 会根据本地已知服务的列表来检查别名,如果发现匹配名称,会将别名转换为主机、协议、端口和服务名。

       本地命名的一个优势是,数据库用户仅需要记住简便连接所需的短别名,而不必记住很长的连接字符串。

       如果组织的Oracle Net 服务配置不经常更改,则适合使用本地命名。

       SQL> conn hr/hr@orcl

  • 目录命名和外部命名


  • Oracle 网络相关的文件位于$TNS_ADMIN目录下,其中主要有sqlnet.ora、listener.ora、tnsnames.ora三个文件

    sqlnet.ora    :位于数据库服务器上,用于定义连接解析方式(默认连接方式为TNSNAMES, EZCONNECT)

    listener.ora  :位于数据库服务器上,用于监听器的配置文件

    tnsname.ora   :位于客户机上,包含网络服务器名,并映射到连接字符串

    默认可能不存在sqlnet.ora、listener.ora两个文件,但监听程序仍然可以以默认方式启动。此时,Oracle将自动在解析地址为计算机主机名,端口为1521的地址上启动一个名为"LISTENER"的监听器。


    $ cat sqlnet.ora NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT) ADR_BASE = /u01/app/oracle $ cat listener.ora LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora11g.example.com)(PORT = 1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent $ cat tnsnames.ora ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = orcl.example.com) ) ) $ lsnrctl service LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-SEP-2013 22:11:58 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g.example.com)(PORT=1521))) Services Summary... Service "+ASM" has 1 instance(s). Instance "+ASM", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER Service "orcl.example.com" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER Service "orclXDB.example.com" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Handler(s): "D000" established:0 refused:0 current:0 max:972 state:ready DISPATCHER (ADDRESS=(PROTOCOL=tcp)(HOST=ora11g.example.com)(PORT=56668)) The command completed successfully


    向数据库注册实例的方法分为静态注册和动态注册。

    注册就是将数据库作为一个服务注册到监听程序。客户端不需要知道数据库名和实例名,只需要知道该数据库对外提供的服务名就可以申请连接到数据库。

    在数据库服务器启动过程中,数据库服务器会向监听程序注册相应的服务(无论何时启动一个数据库,默认地都有两条信息注册到监听器中:数据库服务器对应的实例名和服务名)

  • 静态注册就是实例启动时读取listener.ora文件的配置,将实例和服务注册到监听程序。无论何时启动一个数据库,默认地都有两条信息注册到监听器中:数据库服务器对应的实例和服务。

  •    静态注册时,listener.ora中的GLOBAL_DBNAME向外提供服务名,listener.ora中的SID_NAME提供注册的实例名。

  • 动态注册是在instance启动的时候PMON进程根据init.ora中的instance_name,service_names两个参数将实例和服务动态注册到listener中。

  •    注册到监听器中的实例名从参数文件中的instance_name参数取得。如果该参数没有设定值,那么它将取参数文件中的db_name的值。

       注册到监听器中的服务名从参数文件中的参数service_names取得。如果该参数没有设定值,数据库将拼接参数文件中的 db_name和db_domain的值来注册自己。

       由于动态注册需要pmon进程,所以监听必须在数据库启动之前启动,否则动态注册将失败;在数据库运行的过程中,如果重启监听也会造成动态注册失败。

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: How To Unlock Everything In MyRise
    1 months ago By 尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

    InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

    How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

    The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

    How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

    Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

    What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

    Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

    How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

    Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

    Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

    The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

    When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

    Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

    How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

    The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

    See all articles