listener之一二_MySQL
bitsCN.com
listener之一二
一、注册
注册就是将数据库作为一个服务注册到监听程序。客户端不需要知道数据库名和实例名,只需要
知道该数据库对外提供的服务名就可以申请连接到数据库。这个服务名可以与实例名一致,也可以不
一致,且可以注册多个服务。
注册可以分为静态注册与动态注册,下面分别介绍静态注册和动态注册。
二、静态注册
静态注册就是预先配置好listener.ora文件,配置信息如下:
#listener.oraSID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/app/oracle/product/10.2/db_1) (PROGRAM = extproc) ) (SID_DESC = (SID_NAME = orcl)##数据库的实例名 (ORACLE_HOME = /u01/app/oracle/product/10.2/db_1)##监听程序所在路径 (GLOBAL_DBNAME = test01)##数据库对外提供的服务名 ) )LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = db01)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) )
当用户通过客户端申请连接数据库时,首先通过监听程序读取listener.ora中的配置信息(无论数据库
是否启动,用户的连接请求都会通过监听程序的检查,因为静态监听是无法识别数据库的启动状态的
,只有用户试图连接数据库时,数据库才会返回相关信息。)
下面我们来看下数据库处于打开和关闭状态时,服务test01的实例状态:
1、打开状态
[oracle@db01 admin]$ lsnrctl statusLSNRCTL for Linux: Version 10.2.0.1.0 - Production on 16-OCT-2013 06:58:27Copyright (c) 1991, 2005, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db01)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 10.2.0.1.0 - ProductionStart Date 16-OCT-2013 06:39:09Uptime 0 days 0 hr. 19 min. 18 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/oracle/product/10.2/db_1/network/admin/listener.oraListener Log File /u01/app/oracle/product/10.2/db_1/network/log/listener.logListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))Services Summary...Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service...Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service...Service "orcl_XPT" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service...Service "test01" has 1 instance(s). Instance "orcl", status UNKNOWN, has 1 handler(s) for this service... =>实例orcl的状态为unknownThe command completed successfully此时当用户通过客户端连接数据库时:SQL> conn system/hat@test01
已连接。
2、关闭状态:
[oracle@db01 admin]$ lsnrctl statusLSNRCTL for Linux: Version 10.2.0.1.0 - Production on 16-OCT-2013 06:54:44Copyright (c) 1991, 2005, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db01)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 10.2.0.1.0 - ProductionStart Date 16-OCT-2013 06:39:09Uptime 0 days 0 hr. 15 min. 35 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/oracle/product/10.2/db_1/network/admin/listener.oraListener Log File /u01/app/oracle/product/10.2/db_1/network/log/listener.logListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db01)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))Services Summary...Service "PLSExtProc" has 1 instance(s). Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...Service "test01" has 1 instance(s). Instance "orcl", status UNKNOWN, has 1 handler(s) for this service... =>实例orcl的状态为unknownThe command completed successfully
此时当用户通过客户端连接数据库时:
SQL> conn system/hat@test01
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
由此可知,用户的连接请求通过了监听的检查,但数据库没有打开,于是就返回了ora-01034的错误。
通过上面的实验,验证了当监听静态注册时,服务的实例状态均为unknown,监听程序无法知道数据库
是否处于打开状态。
三、动态注册
动态注册就是不需预先配置listener.ora文件,而是instance在启动的时候PMON进程根据
init.ora中的instance_name、service_names两个参数将实例和服务动态的注册到listener中。
注册到监听器中的实例名从init.ora文件中的instance_name参数取得。如果该参数没有设定值,
那么它将取init.ora文件中的db_name值。
注册到监听器中的服务名从init.ora文件中的参数service_names(该参数可以设置多个值,且值
以逗号分隔)和db_domain取得。如果service_names参数没有设定值,数据库将取init.ora文件中的
db_name值。
采取动态注册时,listener.ora配置如下:
#listener.oraSID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/app/oracle/product/10.2/db_1) (PROGRAM = extproc) ) )LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = db01)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) )
动态注册默认只注册到默认的监听器上(名称是LISTENER、端口是1521、协议是TCP),如果需要向
非默认监听注册,则只需要配置local_listener参数。
四、如何区分静态注册与动态注册
方法一:通过lsnrctl status监测
静态注册的监听实例状态为unknown,动态注册的监听实例状态为ready
方式二:查看listener.ora文件
listener.ora文件中添加了如下信息的为静态注册,没有添加为动态注册
(SID_DESC =
(SID_NAME = orcl)##数据库的实例名
(ORACLE_HOME = /u01/app/oracle/product/10.2/db_1)##监听程序所在路径
(GLOBAL_DBNAME = test01)##数据库对外提供的服务名
)
注:1、由于动态注册监听是通过pmon进程来动态添加的,因此一旦数据库关闭,那么动态注册的服务便立即从监听程序中消除。
2、如果想远程启动数据库,需要通过静态注册。
bitsCN.com
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app

MQTT (MessageQueuingTelemetryTransport) is a lightweight message transmission protocol commonly used for communication between IoT devices. PHP is a commonly used server-side programming language that can be used to develop MQTT clients. This article will introduce how to use PHP to develop an MQTT client and include the following content: Basic concepts of the MQTT protocol Selection and usage examples of the PHPMQTT client library: Using the PHPMQTT client to publish and

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.
