Магадгүй үе үе өгөгдлийн сангийн нэрийг солих шаардлага, хүсэл тулгарч болох юм. Тиймээс өгөгдлийн сангийн нэрийг nid комманд ашиглан хэрхэн солих талаар жишээгээр танилцуулъя.
- Орчин тохируулна
$ . oraenv
ORACLE_SID = [oracle] ? orcl
The Oracle base has been set to /u01/app/oracle
$
- Өгөгдлийн санг mount горимд асаана
$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Sep 17 01:43:56 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> shu immediate
SQL> startup mount
- Коммандын мөрнөөс nid коммандыг ашиглан нэрийг солино. Доорхи жишээний хувьд “orcl” нэрийг “aa” болгон өөрчилж байна. Үр дүнгээс DBID солигдож байгааг анхаараарай.
$ nid target=SYS/syspass dbname=aa
DBNEWID: Release 19.0.0.0.0 - Production on Fri Sep 17 01:45:18 2021
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
Connected to database ORCL (DBID=1611241859)
Connected to server version 19.3.0
Control Files in database:
/u01/app/oracle/oradata/ORCL/control01.ctl
/u01/app/oracle/fast_recovery_area/ORCL/control02.ctl
Change database ID and database name ORCL to AA? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1611241859 to **2195382510**
Changing database name from ORCL to AA
Control File /u01/app/oracle/oradata/ORCL/control01.ctl - modified
Control File /u01/app/oracle/fast_recovery_area/ORCL/control02.ctl - modified
Datafile /u01/app/oracle/oradata/ORCL/system01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/ORCL/sysaux01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/ORCL/undotbs01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/ORCL/users01.db - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/ORCL/temp01.db - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/ORCL/control01.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/fast_recovery_area/ORCL/control02.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to AA.
Modify parameter file and generate a new password file before restarting.
Database ID for database AA changed to 2195382510.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
- Өгөгдлийн санг mount горимд асаахад control файлд өгөгдлийн сангийн нэр зөрөх тул алдаа зааж nomount горимдоо үлдэнэ. Тиймээс db_name болон db_unique_name параметрийг тохируулж өгнө.
$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Sep 17 01:45:58 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 3707763120 bytes
Fixed Size 8903088 bytes
Variable Size 721420288 bytes
Database Buffers 2969567232 bytes
Redo Buffers 7872512 bytes
ORA-01103: database name 'AA' in control file is not 'ORCL'
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string ORCL
SQL> show parameter db_unique_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string orcl
SQL> alter system set db_name=aa scope=spfile;
System altered.
SQL> alter system set db_unique_name=aa scope=spfile;
System altered.
- Өгөгдлийн санг дахин унтрааж асааснаар шинэ нэрээр ашиглахад бэлэн болно.
SQL> shu immediate
SQL> startup mount
ORACLE instance started.
SQL> select dbid from v$database;
DBID
----------
2195382510
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string AA
SQL> show parameter db_uniq
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string AA
SQL>
SQL> alter database open resetlogs;
Database altered.
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ WRITE PRIMARY
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>exit
$ echo $ORACLE_SID
orcl
$
Үүний дараа нөөцлөлтөө (backup) дахин шинээр авахаа мартав.