一、概述
二、數(shù)據(jù)庫(kù)重啟
# su到oracle用戶下
[root@localhost ~]# su - oracle
#重啟數(shù)據(jù)庫(kù)
[oracle@localhost ~]$ sqlplus /nolog
SQL> conn /as sysdba
# 關(guān)閉數(shù)據(jù)庫(kù)
SQL> shutdown immediate
# 數(shù)據(jù)庫(kù)啟動(dòng)
SQL> startup
SQL> exit
shutdown有四個(gè)參數(shù),四個(gè)參數(shù)的含義如下:
-
Normal 需要等待所有的用戶斷開(kāi)連接
-
Immediate 等待用戶完成當(dāng)前的語(yǔ)句
-
Transactional 等待用戶完成當(dāng)前的事務(wù)
-
Abort 不做任何等待,直接關(guān)閉數(shù)據(jù)庫(kù)
-
normal需要在所有連接用戶斷開(kāi)后才執(zhí)行關(guān)閉數(shù)據(jù)庫(kù)任務(wù),所以有的時(shí)候看起來(lái)好象命令沒(méi)有運(yùn)行一樣!在執(zhí)行這個(gè)命令后不允許新的連接
-
immediate在用戶執(zhí)行完正在執(zhí)行的語(yǔ)句后就斷開(kāi)用戶連接,并不允許新用戶連接。
-
transactional 在擁護(hù)執(zhí)行完當(dāng)前事物后斷開(kāi)連接,并不允許新的用戶連接數(shù)據(jù)庫(kù)。
-
abort 執(zhí)行強(qiáng)行斷開(kāi)連接并直接關(guān)閉數(shù)據(jù)庫(kù)。
前三種方式不回丟失用戶數(shù)據(jù)。第四種在不的已的情況下,不建議采用!
經(jīng)常遇到的問(wèn)題:
-
權(quán)限問(wèn)題,解決方法,切換到oracle用戶
-
沒(méi)有關(guān)閉監(jiān)聽(tīng)器 ,解決方法:關(guān)閉監(jiān)聽(tīng)器
-
有oracle實(shí)例沒(méi)有關(guān)閉,解決辦法:關(guān)閉oracle實(shí)例
-
環(huán)境變量設(shè)置不全,解決辦法:修改環(huán)境變量
三、監(jiān)聽(tīng)
1、常用命令
前提:登錄用戶有dba權(quán)限,能夠進(jìn)行查看
# 查看監(jiān)聽(tīng)狀態(tài)
[oracle@scorl root]$ lsnrctl status
# 啟用監(jiān)聽(tīng)
[oracle@localhost ~]$ lsnrctl start
# 停掉lsnrctl
[oracle@localhost ~]$ lsnrctl stop
# 退出oracle用戶
[oracle@localhost ~]$ exit
logout
[root@localhost ~]#
2、案例
# 查看監(jiān)聽(tīng)狀態(tài)
[oracle@scorl root]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 18-JUL-2019 14:45:23
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=scorl.dyedu.cn)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
# 啟動(dòng)監(jiān)聽(tīng)
[oracle@scorl root]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 18-JUL-2019 14:45:32
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Starting /Database/oraapp/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /Database/oraapp/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /Database/oraapp/oracle/diag/tnslsnr/scorl/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=scorl.dyedu.cn)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 18-JUL-2019 14:45:32
Uptime 0 days 0 hr. 0 min. 17 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /Database/oraapp/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /Database/oraapp/oracle/diag/tnslsnr/scorl/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=scorl.dyedu.cn)(PORT=1521)))
Services Summary...
Service "scorl.dyedu.cn" has 1 instance(s).
Instance "scorl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
# 停掉lsnrctl
[oracle@localhost ~]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-JAN-2018 08:00:14
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully
這個(gè)命令會(huì)列出Oracle Net Listener的進(jìn)程
[oracle@localhost ~]$ netstat -antp | grep tnslsnr
(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.241.155:1521 0.0.0.0:* LISTEN 6407/tnslsnr
[oracle@localhost ~]$
四、使用plsql連接
用plsql連接到數(shù)據(jù)庫(kù),tnsnames.ora增加配置
TEST_DB155 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.155)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)
五、更換IP
有一次Linux的ip變了以后,出現(xiàn)了這個(gè)
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 01-SEP-2018 03:38:08
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.241.155)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
TNS-12560: TNS:protocol adapter error
TNS-00515: Connect failed because target host or object does not exist
Linux Error: 99: Cannot assign requested address
Listener failed to start. See the error message(s) above...
進(jìn)去改了下ip就好了文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-457981.html
[oracle@localhost ~]$ vim /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-457981.html
到了這里,關(guān)于Oracle運(yùn)維(數(shù)據(jù)庫(kù)、監(jiān)聽(tīng)、重啟)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!