Pages

Wednesday, July 3, 2019

Oracle Listener and Networking

How to verify how many databases are up?
ps -ef |grep pmon



3) How to verify how many databases are configured in a server (up or down)?
cat /etc/oratab
or

cd $ORACLE_HOME/dbs
ls -ltr init*
ls -ltr spfile*


4) How to verify how many listeners are up?
ps -ef |grep lsnr
or 
ps -ef|grep tnslsnr|awk '{ print $9; }'

What is the location of Oracle Network Administration files?
$ORACLE_HOME/network/admin

6) Where is tnsnames.ora file?
$ORACLE_HOME/network/admin
cat $TNS_ADMIN/tnsnames.ora 

TigerDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.83)(PORT = 1693))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = TigerDB)
    )
  )

Where:
TigerDB is called the “Connect Identifier” and can be named anything. Typically, we keep this as same name as the database name to avoid the confusion. Another name for connection identifier is “Net Service Name”. Do not confuse “Net Service Name” with “Service Name”. They both are different. 

Net Service Name  = User’s personal choice name configured on Client side.
Service Name  = Database Name or DBA assigned service name on the Server side. 

To check the service names configured on the database, login to the database as sys and issue the following:

SQL> show parameter service.

9) Where is the listener.ora file?
$ORACLE_HOME/network/admin
cat $TNS_ADMIN/listener.ora | more

10) How to work in a specific database?
? export ORACLE_SID=<Database Name>
ex: export ORACLE_SID=KhanDB


11) How to start a database as a Database Administrator (sys user)?
Complete #1 and issue the following:
$ cat /etc/hosts
$ sqlplus / as sysdba
startup

12) Listener Management Commands:
lsnrctl <enter>

set current_listener <your listener name>

The following commands are used to manage the listener: 

start  – Starts the listener with the name specified, otherwise LISTENER will be used.  For Windows systems, the listener can also be started from the Control Panel.
stop  --Stops the listener.  For Windows systems, the listener can also be stopped from the Control Panel.
Status   – Provides status information about the listener.  (including start date, uptime, and trace level)
services   – Displays each service available, along with the connection history.
version                             – Displays the version information of the listener.
reload  – Forces a read of the configuration file in order for new settings to take effect without stopping and starting the listener.
save_config   – Creates a backup of the existing listener.ora file and saves changes to the current version.
trace    – Sets the trace level to one of the following – OFF, USER, ADMIN, or SUPPORT.
change_password  – Sets a new password for the listener.
quit and exit   – Exits the utility.
set    – Changes the value of any parameter.  Everything that can be shown can be set.
show    – Displays current parameter settings. 
reload    -- to stop and start
services   --To check how many services are configured in your listener?



13) Listener Help commnds
LSNRCTL> help 
LSNRCTL> show help
LSNRCTL> set help

LSNRCTL> help


The following lsnrctl operations are available
An asterisk (*) denotes a modifier or extended command:
start              stop                status
services            version             reload
save_config         trace               spawn
dbsnmp_start        dbsnmp_stop         dbsnmp_status
change_password     quit                exit
set*                show*




14) To find out the location of Trace Directory and Trace File Name:

LSNRCTL> show trc_directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Linux-223)(PORT=1521)))
listener parameter "trc_directory" set to /u01/app/oracle/product/10.2.0/db_1/network/trace/
The command completed successfully

LSNRCTL> show trc_file
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Linux-223)(PORT=1521)))
listener parameter "trc_file" set to listener.trc
The command completed successfully


15) How to set the Trace Level:

set trc_level <value>

Values can be any of the following:
0 - 1   off
2 - 3   err
4 - 5   user
6 - 14   admin  --> DBAs mostly use this trace level.
15        dev
16 - 99       support

Example: 
LSNRCTL> set current_listener listener
LSNRCTL> set trc_level 0

LSNRCTL> show trc_level
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Linux-223)(PORT=1521)))
listener parameter "trc_level" set to off
The command completed successfully

LSNRCTL> set trc_level on
TNS-01107: A valid trace level was not specified

LSNRCTL> set trc_level 8
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Linux-223)(PORT=1521)))
listener parameter "trc_level" set to admin
The command completed successfully


16) How to check how many services are configured in your listener?

lsnrctl
LSNRCTL> set current_listener listener
LSNRCTL > services

17) How to check the status of the listener?
ps -ef |grep pmon

18) How to password protect the listener?

LSNRCTL> change_password
Old password:
New password:
Reenter new password:
LSNRCTL> save_config


19) How to force database to register the services in the listener?
Login to database as sys

export ORACLE_SID=<YourDatabaseName>
sqlplus / as sysdba
alter system register;
exit
lsnrctl status <YourListenerName>

No comments:

Post a Comment