啟動遠端圖形介面登入的工具
[root@db11g ~]# vncserver
監聽
監聽的啟動
[oracle@db11g ~]$ lsnrctl start
判斷監聽是否啟動
[oracle@db11g ~]$ netstat -tulnp | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 :::1521 :::* LISTEN 1440/tnslsnr
-- LISTEN:表示監聽已經啟動
-- 1440:監聽對應的程序編號
-- ::: 表示所有的IP地址都啟動1521埠
檢視監聽狀態
[oracle@db11g ~]$ lsnrctl status -- 這個命令預設是:lsnrctl status listener
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2017 02:56:53
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db11g)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 10-JAN-2017 19:47:03
Uptime 2 days 7 hr. 9 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/db11g/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=db11g)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
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…
The command completed successfully
檢視監聽程序
[oracle@db11g ~]$ ps -ef | grep 1440
oracle 1440 1 0 Jan10 ? 00:00:11 /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle 13687 13645 0 02:59 pts/0 00:00:00 grep 1440
監聽表現為一個程序,預設埠號:1521
監聽的配置檔案
1、listener.ora檔案(主要配置監聽)
listener.ora檔案:伺服器端的(啟動監聽的時候讀listener.ora檔案)
listener.ora檔案位置:
[oracle@db11g ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin
[oracle@db11g admin]$ ls
listener.ora samples shrept.lst tnsnames.ora
listener.ora檔案控制著監聽
沒有listener.ora檔案時:
如果沒有listener.ora配置檔案,監聽也可以啟動,預設使用1521埠,所有IP都啟動1521埠,下圖解釋:
預設情況下,以後透過所有的IP地址都可以連線
檢視任意一個IP地址是否啟動1521埠,啟動著1521埠都可以連線上資料庫例項
以192.168.56.70為例:
[oracle@db11g ~]$ telnet 192.168.56.70 1521
這就表示著:在192.168.56.70地址上啟動著1521埠
然後ctrl+c退出
啟動資料庫例項:
[oracle@db11g ~]$ sqlplus / as sysdba --登入資料庫
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 13 06:02:46 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup --啟動資料庫例項
配置listener.ora監聽檔案(建立、新增一個監聽)
只想要某一個IP地址啟動1521埠,例如:只想在192.168.56.70這個IP地址上啟動1521埠,這時要去生成一個配置檔案:
1、使用vnc連線上資料庫
2、點選continue按鈕
3、輸入密碼,點選OK
點選'X'關閉
開啟open terminal
4、使用netca命令配置監聽,可以生成listener.ora這個檔案:
首先Set and export DISPLAY(指定影像對映機器):
[oracle@db11g admin]$ export DISPLAY=192.168.56.1:0.0
5、選擇listener configuration,點選next
6、因為沒有listener.ora這個檔案,所以選擇Add,點選next
7、監聽的名字,預設就要LISTENER,點選next
8、選擇TCP,點選next
9、選擇預設埠1521
10、選擇No,點選next
11、點選finish
配置完成
12、檢視配置完成的listener.ora檔案:
[oracle@db11g ~]$ cd $ORACLE_HOME
[oracle@db11g db_1]$ cd network/admin
[oracle@db11g admin]$ ls
listener.ora samples shrept.lst tnsnames.ora
13、修改listener.ora檔案:
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.70)(PORT = 1521)) --將原來的主機名改為IP地址:192.168.56.70
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
注意:LISTENER監聽這個名字不要去修改它,因為pmonitor預設是往名字為LISTENER的監聽裡註冊instancename和servername
14、重新啟動監聽
[oracle@db11g admin]$ lsnrctl stop -- 關閉監聽
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 16-JAN-2017 15:08:18
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.12)(PORT=1521)))
The command completed successfully
[oracle@db11g admin]$ lsnrctl start -- 啟動監聽
[oracle@db11g admin]$ lsnrctl status --檢視監聽狀態
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 16-JAN-2017 15:09:53
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.12)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 16-JAN-2017 15:09:04
Uptime 0 days 0 hr. 0 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFFL
istener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/db11g/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.12)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
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…
The command completed successfully
15、再次檢視監聽
[oracle@db11g admin]$ netstat -tulpn | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 192.168.56.70:1521 0.0.0.0:* LISTEN 1583/tnslsnr
這時候只有192.168.56.70這個IP地址上啟動了1521埠
監聽的靜態註冊
我們也可以建立多個監聽,但是pmonitor預設是往名字為LISTENER的監聽裡註冊instancename和servername,就會導致使用其他監聽連線資料庫例項的時候連線不上
圖解:
如何靜態註冊監聽?
1、使用netmgr命令:
[oracle@db11g admin]$ netmgr
2、選擇listener1,然後選擇database services
3、選擇add database
4、輸入global database name:cis1(服務名,可以自己輸入),SID:cis(資料庫例項名)
5、儲存,然後退出
6、重啟監聽listener1,檢視狀態
[oracle@db11g admin]$ lsnrctl reload listener1
[oracle@db11g admin]$ lsnrctl status listener1
靜態註冊的監聽listener1:
status的幾個狀態
1、ready:可以連線,動態註冊
2、blocked:不可以連線,動態註冊
3、unknown:靜態註冊,是否可以連線取決於例項是否啟動
監聽的幾個情況:
多個監聽
1、兩個名字:
一個ip、兩個埠
兩個ip、一個埠
2、一個名字:
一個ip、兩個埠,但是隻起一個程序
兩個ip、一個埠
一般情況我們說的是:兩個名字、兩個ip、同一個埠,listener1靜態註冊的