溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何自動(dòng)啟動(dòng)數(shù)據(jù)庫(kù)

發(fā)布時(shí)間:2021-11-25 11:03:07 來(lái)源:億速云 閱讀:236 作者:小新 欄目:數(shù)據(jù)庫(kù)

這篇文章主要介紹如何自動(dòng)啟動(dòng)數(shù)據(jù)庫(kù),文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

自動(dòng)重啟,需要grid的支持

自動(dòng)管理資源

[oracle@edsir1p8-+ASM ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    edsir1p8    
ora.asm        ora.asm.type   ONLINE    ONLINE    edsir1p8    
ora.cssd       ora.cssd.type  ONLINE    ONLINE    edsir1p8    
ora.diskmon    ora....on.type ONLINE    ONLINE    edsir1p8

通常2種方式自動(dòng)啟動(dòng)數(shù)據(jù)庫(kù)

1.

[oracle@edsir1p8-+ASM ~]$ tail -3 /etc/oratab
PROD4:/u01/app/oracle/product/11.2.0/db_1:N
EMREP:/u01/app/oracle/product/11.2.0/db_1:N
+ASM:/u01/app/oracle/product/11.2.0/grid:N
---這種方式通常不好用

2.crs_stat

這是個(gè)資源表,讓數(shù)據(jù)庫(kù)和監(jiān)聽注冊(cè)到這個(gè)表里

[oracle@edsir1p8-+ASM ~]$ srvctl add  database -d PROD4  -o /u01/app/oracle/product/11.2.0/db_1
[oracle@edsir1p8-+ASM ~]$ srvctl config database   --查看哪些數(shù)據(jù)庫(kù)已經(jīng)注冊(cè)

關(guān)監(jiān)聽,注冊(cè)

[oracle@edsir1p8-+ASM ~]$ srvctl add  listener -l  listener -p 1521 -o /u01/app/or
acle/product/11.2.0/db_1PRCN-2061 : Failed to add listener ora.LISTENER.lsnr
PRCN-2065 : Port(s) 1521 are not available on the nodes given
PRCN-2035 : Port 1521 is not available on node(s) or virtual host(s): edsir1p8.us.
oracle.com

--關(guān)監(jiān)聽

[oracle@edsir1p8-+ASM ~]$ lsnrctl stop
[oracle@edsir1p8-+ASM ~]$ srvctl add  listener -l  listener -p 1521 -o /u01/app/oracle/pr
oduct/11.2.0/db_1
[oracle@edsir1p8-+ASM ~]$ srvctl config listener   --查看監(jiān)聽是否注冊(cè)成功
[oracle@edsir1p8-+ASM ~]$ crs_stat -t
Name           Type           Target    State     Host       
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    edsir1p8   
ora....ER.lsnr ora....er.type OFFLINE   OFFLINE              
ora.asm        ora.asm.type   ONLINE    ONLINE    edsir1p8   
ora.cssd       ora.cssd.type  ONLINE    ONLINE    edsir1p8   
ora.diskmon    ora....on.type ONLINE    ONLINE    edsir1p8   
ora.prod4.db   ora....se.type OFFLINE   OFFLINE

=============================================================

--重啟服務(wù)器,看效果

oracle@edsir1p8- ~]$ ps -ef | grep smon
oracle    5387  5106  0 09:25 pts/2    00:00:00 grep smon     --沒(méi)有實(shí)例啟動(dòng)
[oracle@edsir1p8- ~]$ lsnrctl status
-bash: lsnrctl: command not found       --沒(méi)有任何的Oracle環(huán)境變量
[oracle@edsir1p8- ~]$ . oraenv
ORACLE_SID = [oracle] ? +ASM
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle
[oracle@edsir1p8-+ASM ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-JUN-2017 09:25:58
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused     --監(jiān)聽沒(méi)有啟動(dòng)
[oracle@edsir1p8-+ASM ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 09:28:48 2017
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> quit
Disconnected
[oracle@edsir1p8-+ASM ~]$ srvctl start database -d PROD4
PRCD-1027 : Failed to retrieve database PROD4
PRCR-1070 : Failed to check if resource ora.prod4.db is registered
Cannot communicate with crsd
[oracle@edsir1p8-+ASM ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 22 09:30:20 2017
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
ORA-29701: unable to connect to Cluster Synchronization Service
SQL> quit
Disconnected
[oracle@edsir1p8-+ASM ~]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[oracle@edsir1p8-+ASM ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    OFFLINE               
ora....ER.lsnr ora....er.type ONLINE    ONLINE    edsir1p8    
ora.asm        ora.asm.type   ONLINE    OFFLINE               
ora.cssd       ora.cssd.type  ONLINE    OFFLINE               
ora.diskmon    ora....on.type ONLINE    ONLINE    edsir1p8    
ora.prod4.db   ora....se.type OFFLINE   OFFLINE
[oracle@edsir1p8-+ASM ~]$ crsctl enable has
CRS-4622: Oracle High Availability Services autostart is enabled.
--必須開機(jī)自啟動(dòng),只有他開機(jī)自啟動(dòng),注冊(cè)到里面的資源才能開機(jī)自啟動(dòng)

重啟服務(wù)器,看效果

===========================================================

--集群管理的方式將數(shù)據(jù)庫(kù)開

[oracle@edsir1p8-+ASM ~]$ srvctl start database -d PROD4

--執(zhí)行相反操作
srvctl remove database -d PROD4    ---移除數(shù)據(jù)庫(kù)
srvctl remove listener -l listener     ---如果注冊(cè)錯(cuò)誤可以使用該命令刪除

以上是“如何自動(dòng)啟動(dòng)數(shù)據(jù)庫(kù)”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI