您好,登錄后才能下訂單哦!
這篇文章主要介紹了如何修改oracle數據庫的db_name,instace_name,sid_name,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
概念:db_name 被記錄在數據文件,日志文件和控制文件中,可以不同于instance_name.
sid_name 1.主要是區別連接的數據庫
2. 在操作系統層面上進行區分,當Oracle實例啟動時,操作系統上fork的進程必須通過這個SID將實例與其他實例區分開來,后臺進程通過該sid表示數據庫 eg: ps-ef|grep smon
3.instance_name是數據庫中的一個重要參數,一個主機中可以有相同instance_name的多個數據庫。
Oracle的實例(instance)是由一塊共享內存區域(SGA)和一組后臺進程(background processes)共同組成;而后臺進程正是數據庫和操作系統進行交互的通道,這些進程的名稱就是通過ORACLE_SID決定的
數據庫名稱db_name >實例名稱 instance_name > oracle_sid
修改實例名稱
原來的實例名稱
SQL> select dbid,name from v$database;
DBID NAME
---------- ---------
1475786014 ORCL
SQL> select instance from v$thread ;
INSTANCE
--------------------------------------------------------------------------------
orcl
修改過程:
SQL> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
[root@node ~]# vi /etc/oratab
test:/u01/app/oracle/product/11.2.0/db_1:N
[oracle@node ~]$ vi .bash_profile
export ORACLE_SID=test
[oracle@node ~]$ source .bash_profile
[oracle@node ~]$ env|grep ORA
ORACLE_SID=test
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
[oracle@node ~]$ cd $ORACLE_HOME/dbs
[oracle@node dbs]$ ll
total 9544
-rw-rw----. 1 oracle oinstall 1544 Jun 30 21:04 hc_orcl.dat
-rw-r--r--. 1 oracle oinstall 2851 May 15 2009 init.ora
-rw-r--r--. 1 oracle oinstall 935 Jun 30 18:04 initorcl.ora
-rw-r-----. 1 oracle oinstall 24 Jun 30 06:47 lkORCL
-rw-r-----. 1 oracle oinstall 1536 Jun 30 06:50 orapworcl
-rw-r-----. 1 oracle oinstall 9748480 Jun 30 18:05 snapcf_orcl.f
-rw-r-----. 1 oracle oinstall 2560 Jun 30 13:09 spfileorcl.ora
[oracle@node dbs]$ mv initorcl.ora inittest.ora
[oracle@node dbs]$ mv hc_orcl.dat hc_test.dat
[oracle@node dbs]$ mv lkORCL lkTEST
[oracle@node dbs]$ mv snapcf_orcl.f snapcf_test.f
[oracle@node dbs]$ mv spfileorcl.ora spfiletest.ora
[oracle@node dbs]$ rm -rf orapworcl
[oracle@node dbs]$ orapwd file=orapwtest password=system
SQL> startup;
ORACLE instance started.
Total System Global Area 1152450560 bytes
Fixed Size 2252584 bytes
Variable Size 738197720 bytes
Database Buffers 402653184 bytes
Redo Buffers 9347072 bytes
Database mounted.
Database opened.
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
test OPEN
SQL> select instance from v$thread;
INSTANCE
--------------------------------------------------------------------------------
test
SQL> select dbid,name from v$database;
DBID NAME
---------- ---------
1475786014 ORCL
修改數據庫名稱
備份控制文件
SQL> alter database backup controlfile to trace ;
Database altered.
more /u01/app/oracle/diag/rdbms/orcl/test/trace/test_ora_119661.trc
修改后如下
CREATE CONTROLFILE set DATABASE "TEST" RESETLOGS noARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/test/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/oradata/test/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/oradata/test/redo03.log' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/oradata/test/system01.dbf',
'/oradata/test/sysaux01.dbf',
'/oradata/test/undotbs01.dbf',
'/oradata/test/users01.dbf',
'/oradata/test/fan.dbf'
CHARACTER SET AL32UTF8
;
(查找所有的orcl修改為test,所有的ORCL修改為test,找到CREATE CONTROLFILE REUSE DATABASE...語句,將其中的REUSE修改為SET
SQL> shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> create pfile from spfile;
修改inittest.ora
*.audit_file_dest='/u01/app/oracle/admin/test/adump'
*.audit_trail='NONE'
*.compatible='11.2.0.4.0'
*.control_files='/oradata/test/control01.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='test'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=testXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=1150287872
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
更換目錄
/u01/app/oracle/admin/orcl/adump
/oradata/orcl/
將orcl更改為test (控制文件中的目錄和操作系統保持一致)
sql>create spfile from pfile;
sql>startup nomount;
sql>
SQL> CREATE CONTROLFILE set DATABASE "TEST" RESETLOGS noARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/oradata/test/redo01.log' SIZE 50M BLOCKSIZE 512,
9 GROUP 2 '/oradata/test/redo02.log' SIZE 50M BLOCKSIZE 512,
10 GROUP 3 '/oradata/test/redo03.log' SIZE 50M BLOCKSIZE 512
11 -- STANDBY LOGFILE
12 DATAFILE
13 '/oradata/test/system01.dbf',
14 '/oradata/test/sysaux01.dbf',
15 '/oradata/test/undotbs01.dbf',
16 '/oradata/test/users01.dbf',
17 '/oradata/test/fan.dbf'
18 CHARACTER SET AL32UTF8
19 ;
Control file created.
SQL> alter database open resetlogs;
Database altered.
SQL> select dbid,name from v$database;
DBID NAME
---------- ---------
1475786014 TEST
SQL> select instance from v$thread;
INSTANCE
--------------------------------------------------------------------------------
test
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
test OPEN
感謝你能夠認真閱讀完這篇文章,希望小編分享的“如何修改oracle數據庫的db_name,instace_name,sid_name”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。