SRVCTL 刪除和新增資料庫服務

hellohf123發表於2022-01-28

背景:

架構rac+單節點asm的dg

我搭建的dataguard的unique_name 我更改為了prodstd

現在的情況:

[root@racdg ~]# crsctl status resource -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATADG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.FRADG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       racdg                    STABLE
ora.MGMTDG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.OCRDG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.asm
               ONLINE  ONLINE       racdg                    Started,STABLE
ora.ons
               OFFLINE OFFLINE      racdg                    STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       racdg                    STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       racdg                    STABLE
ora.prod.db
      1        ONLINE  ONLINE       racdg                    Open,Readonly,HOME=/
                                                             u01/app/oracle/produ
                                                             ct/19c/db_1,STABLE
--------------------------------------------------------------------------------

雖然現在還可以使用srvctl start database -db prod啟動,但是其實已經不對了

檢視現在的配置

[oracle@racdg:/home/oracle]$srvctl config database -db prod
Database unique name: prod
Database name: prod
Oracle home: /u01/app/oracle/product/19c/db_1
Oracle user: oracle
Spfile: +DATADG/PROD/PARAMETERFILE/spfile.269.1084619231
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups: DATADG
Services:
OSDBA group:
OSOPER group:
Database instance: proddg

我真實的spfile,其實在我的ORACLE_HOME目錄,不在asm上

SQL> show parameter spfile;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/19c/db
                                                 _1/dbs/spfileproddg.ora


spfile錯誤,unique name錯誤,但是卻不影響透過srvctl 啟動資料庫,而且啟動的prod  實際啟動的確是prodstd,所以我們測試一下,如何新增刪除。



1、刪除

[oracle@racdg:/home/oracle]$srvctl remove database -db prod
PRKO-3141 : Database prod could not be removed because it was running

關閉資料庫再刪除

[oracle@racdg:/home/oracle]$srvctl stop database -db prod
[oracle@racdg:/home/oracle]$srvctl remove database -db prod
Remove the database prod? (y/[n]) y


2、新增

[oracle@racdg:/home/oracle]$srvctl add database -h
Adds a database configuration to be managed by Oracle Restart.
Usage: srvctl add database -db <db_unique_name> -oraclehome <oracle_home> [-domain <domain_name>] [-spfile <spfile>] [-pwfile <password_file_path>] [-role {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY | FAR_SYNC}] [-startoption <start_options>] [-stopoption <stop_options>] [-dbname <db_name>] [-instance <inst_name>] [-policy {AUTOMATIC | MANUAL | NORESTART | USERONLY}] [-diskgroup "<diskgroup_list>"] [-verbose]
    -db <db_unique_name>           Unique name for the database
    -oraclehome <path>             Oracle home path
    -domain <domain_name>          Domain for database. Must be set if database has DB_DOMAIN set.
    -spfile <spfile>               Server parameter file path
    -pwfile <password_file_path>   Password file path
    -role <role>                   Role of the database (PRIMARY, PHYSICAL_STANDBY, LOGICAL_STANDBY, SNAPSHOT_STANDBY, FAR_SYNC)
    -startoption <start_options>   Startup options for the database. Examples of startup options are OPEN, MOUNT, or "READ ONLY".
    -stopoption <stop_options>     Stop options for the database. Examples of shutdown options are NORMAL, TRANSACTIONAL, IMMEDIATE, or ABORT.
    -dbname <db_name>              Database name (DB_NAME), if different from the unique name given by the -db option
    -instance <inst_name>          Instance name
    -policy <dbpolicy>             Management policy for the database (AUTOMATIC, MANUAL, NORESTART or USERONLY)
    -diskgroup "<diskgroup_list>"  Comma separated list of disk group names
    -verbose                       Verbose output
    -help                          Print usage

按照提示新增

[oracle@racdg:/home/oracle]$srvctl add database -db prodstd -oraclehome /u01/app/oracle/product/19c/db_1
[oracle@racdg:/home/oracle]$srvctl config database -db prodstd
Database unique name: prodstd
Database name:
Oracle home: /u01/app/oracle/product/19c/db_1
Oracle user: oracle
Spfile:
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups:
Services:
OSDBA group:
OSOPER group:
Database instance: prodstd
[oracle@racdg:/home/oracle]$srvctl start database -db prodstd
PRCR-1079 : Failed to start resource ora.prodstd.db
CRS-5017: The resource action "ora.prodstd.db start" encountered the following error:
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/19c/db_1/dbs/initprodstd.ora'
. For details refer to "(:CLSN00107:)" in "/u01/app/grid/diag/crs/racdg/crs/trace/ohasd_oraagent_grid.trc".
CRS-2674: Start of 'ora.prodstd.db' on 'racdg' failed
[oracle@racdg:/home/oracle]$

由上面可知道,只新增了unique_name 和 oracle_home 預設回去home目錄查詢 

initprodstd.ora

的引數檔案,但是不存在,所以我們需要新增一下,具體的dbname,讓他自動去尋找home目錄下的

initproddg.ora或者spfileproddg.ora

所以參照以下

[oracle@racdg:/home/oracle]$srvctl modify database -db prodstd -h
Modifies the configuration for the database.
Usage: srvctl modify database -db <db_unique_name> [-dbname <db_name>] [-instance <inst_name>] [-oraclehome <oracle_home>] [-user <oracle_user>] [-domain <domain>] [-spfile <spfile>] [-pwfile <password_file_path>] [-role {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}] [-startoption <start_options>] [-stopoption <stop_options>] [-policy {AUTOMATIC | MANUAL | NORESTART | USERONLY}] [-diskgroup "<diskgroup_list>"|-nodiskgroup] [-force]
    -db <db_unique_name>           Unique name for the database
    -dbname <db_name>              Database name (DB_NAME), if different from the unique name given by the -db option
    -instance <inst_name>          Instance name
    -oraclehome <path>             Oracle home path
    -user <oracle_user>            Oracle user
    -domain <domain_name>          Domain for database. Must be set if database has DB_DOMAIN set.
    -spfile <spfile>               Server parameter file path
    -pwfile <password_file_path>   Password file path
    -role <role>                   Role of the database (PRIMARY, PHYSICAL_STANDBY, LOGICAL_STANDBY, SNAPSHOT_STANDBY)
    -startoption <start_options>   Startup options for the database. Examples of startup options are OPEN, MOUNT, or "READ ONLY".
    -stopoption <stop_options>     Stop options for the database. Examples of shutdown options are NORMAL, TRANSACTIONAL, IMMEDIATE, or ABORT.
    -policy <dbpolicy>             Management policy for the database (AUTOMATIC, MANUAL, NORESTART or USERONLY)
    -diskgroup "<diskgroup_list>"  Comma separated list of disk group names
    -nodiskgroup                   To remove database's dependency upon disk groups
    -force                         Force the modify operation to stop database and service resources on some nodes as necessary, or to change management policy of all service to match new database management policy
    -verbose                       Verbose output
    -help                          Print usage
[oracle@racdg:/home/oracle]$srvctl modify database -db prodstd -dbname prod -instance proddg
[oracle@racdg:/home/oracle]$srvctl start database -db prodstd
[oracle@racdg:/home/oracle]$srvctl status database -db prodstd
Database is running.

至此就透過srvctl命令啟動了資料庫,資料庫prodstd也註冊到了srvctl中了


確認

[root@racdg ~]# srvctl config database -d prodstd
Database unique name: prodstd
Database name: prod
Oracle home: /u01/app/oracle/product/19c/db_1
Oracle user: oracle
Spfile:
Password file:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups: DATADG
Services:
OSDBA group:
OSOPER group:
Database instance: proddg
[root@racdg ~]# crsctl status resource -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATADG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.FRADG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       racdg                    STABLE
ora.MGMTDG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.OCRDG.dg
               ONLINE  ONLINE       racdg                    STABLE
ora.asm
               ONLINE  ONLINE       racdg                    Started,STABLE
ora.ons
               OFFLINE OFFLINE      racdg                    STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       racdg                    STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       racdg                    STABLE
ora.prodstd.db
      1        ONLINE  ONLINE       racdg                    Open,Readonly,HOME=/
                                                             u01/app/oracle/produ
                                                             ct/19c/db_1,STABLE
--------------------------------------------------------------------------------
[root@racdg ~]#

這樣透過srvctl就刪除新增資料庫服務完成了

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70004783/viewspace-2854384/,如需轉載,請註明出處,否則將追究法律責任。

相關文章