'sid'에 해당되는 글 2건

  1. 2009.04.08 SID, DB_NAME,GLOBAL_NAME
  2. 2008.11.26 DBNAME, SID 변경하기.
ORACLE/ADMIN2009. 4. 8. 16:07
반응형
1. SID 란

A name that identifies a specific instance of a running pre-release 8.1 Oracle database.
For any database, there is at least one instance referencing the database.

For pre-release 8.1 databases, SID is used to identify the database.
The SID is included in the connect descriptor of a tnsnames.ora file and
in the definition of the listener in the listener.ora file. 

쉽게 이야기해서 SID 란 Oracle Instance 라고 생각하면 된다.
  ( 3 NODE 일 경우 SID 와 DB 와의 관계 )
  SID ---|
  SID ------- DB
  SID ---|

2. SID 확인 방법
select THREAD#,INSTANCE,STATUS from v$thread;
1    TG2010D    OPEN
--> Single DB 일 경우 Return 되는 Row 가 하나
1    TG2010D1    OPEN
2    TG2010D2    OPEN
--> RAC (2Node) 일 경우 Return 되는 Row 는 두개 이다.

3. DB_NAME 이란 ?
DB_NAME 은 8자리로 제한되는 Database 구분자이다.
이 파라미터는 CREATE DATABASE 일때 지정된다.
하나의 System 에 다수의 Database 가 운영되는 환경이라며,
SID(Oracle Instance Identifier) 와 DB Name 을 Matching 시켜 줘야 한다.
일반적으로 Single Database 일 경우 SID 와 DB Name 을 동일 하게 운영한다.
SID 지정을 통해서 접속 하고자 하는 DB NAME 을 지정한다고 생각하면 된다.
알파벳, _(Underscore), #(Number Signe), $(Dollar Singe) 만 가능하다.

EX) A(A), B(B), C(C)  -- DB_NAME ( SID )순서
    상기와 같은 구성 이라면 C 에 접속 하고자 한다면
    EXPORT ORACLE_SID=C [ UNIX, LINUX ]
    SET $ORACLE_SID=C   [ NT ]
    를 통해서 SID 지정 후 접속하면 원하는 DATABASE 에 접속이 가능하다.


4. DB_NAME 확인
select NAME, DB_UNIQUE_NAME from v$database ;
NAME      DB_UNIQUE_NAME
--------- ------------------------------
TG2010D   TG2010D

5. RAC 일 경우 INIT 파라미터 예제
*.cluster_database_instances=2
*.cluster_database=true
*.db_domain=''
*.db_name='TG2010D'
TG2010D1.instance_number=1
TG2010D2.instance_number=2

6. 기타
   일반적으로 SID 변경이란 SID 및 DB_NAME 을 변경 한다구 생각하면 된다.
   SID(INSTACNE) 만 변경 할 일은 극히 드물다..
   전 해본적이 없음


7. Global_Name
 네트워크 환경에서 데이타베이스 이름이 동일하여 구분하기 어려울 때,
 사용하는 전역 데이터베이스 이름을 사용할 것인지를 결정하는 파라미터이다.
 DB_NAME.DB_DOMAIN 이름으로 구성된다.
 INIT PARAMETER 화일 예제 )
  *.db_domain=''
  -- DB_DOMAIN 은 128 자 까지 가능, Default 값은 WORLD
  *.db_name='TG2010T'
 
8. Global_Name 관련 파라미터
8.1 GLOBAL_NAMES
SYS>show parameters global_names
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
global_names                         boolean     FALSE
==> Default 는 FALSE 값이다.
    DB LINK 를 통해서 접속 시에 GLLBAL_NAME 과 일치해야 하는지,
    FALSE 이면 DB LINK 값과 GLOBAL_NAME 이 달라도 접속이 된다.
    GLOBAL_NAME 의 효과(10번항목) 같이 생각하면
    GLOBAL_NAME 을 TRUE 로 설정하고, 같은 DOMAIN NAME 을 사용한다면
    같은 DOMAIN 내에서만 DB LINK 사용이 가능할것으로 예상된다.

8.2 GLOBAL_NAMES 변경
  SYS> ALTER SESSION SET global_names = TRUE;
  SYS> ALTER SYSTEM SET global_names = FALSE;

8.3 DB_DOMAIN    
SYS>show parameter domain
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_domain                            string
==>  DB_DOMAIN 은 128 자 까지 가능, Default 값은 WORLD

8.4 DB_NAME
SYS>show parameters db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------
db_name                              string      TG2010T
==> GLOBAL_NAME = DB_NAME.DB_DOMAIN 이니 TG2010T 가 GLOBAL_NAME 이고
    GLOBAL_NAME 의 설정은 FALSE 이다.


9. Global_Name 확인 및 변경
SYS>ALTER DATABASE RENAME GLOBAL_NAME TO TG2010Z ;
Database altered.

SYS>select * from global_name ;
GLOBAL_NAME
--------------------------------------------------------------------------------
TG2010Z

SYS>ALTER DATABASE RENAME GLOBAL_NAME TO TG2010T ;
Database altered.

SYS>select * from global_name ;

GLOBAL_NAME
--------------------------------------------------------------------------------
TG2010T

10. Global_Name의 효과 
10. 1 Global_Name 효과
 DB LINK 에 영향을 준다.
 DB LINK 생성 시에 DB_DOMAIN 값이 아닌, GLOBAL_NAME 의 접미사 부분이
 자동으로 DBA_DB_LINKS.DB_LINK 에 붙는다.
 예제) 일반적으로 .WORLD 를 붙이지 않는다.
       테스트로 구별이 쉽게 하기 위해서 .WORLD 로 설정
      
 SYS> SELECT GLOBAL_NAME  FROM GLOBAL_NAME ;
 TG.WORLD
 SYS> CREATE DATABASE LINK JT USING 'JT' ;
 SYS> SELECT OWNER,DB_LINK,HOST FROM DBA_DB_LINKS  ;
 SYS    JT2010D.WORLD   JT010d
 ==> 이런식으로 LOCAL DATABASE 의 아래의 값이 DB LINK 생성 시 자동으로 할당된다.
     예제에선 .WORLD
 ( SELECT GLOBAL_NAME  FROM GLOBAL_NAME ) - ( SELECT INSTANCE_NAME FROM V$INSTANCE )
 
10.2  DB_DOMAIN 확인 방법
 SYS> SELECT NAME, VALUE FROM V$PARAMETER WHERE NAME = 'db_domain';

출처 : http://www.oracleclub.com/article/23879
반응형
Posted by [PineTree]
ORACLE/ADMIN2008. 11. 26. 11:33
반응형
(V7.X ~ V9.X) Modifying a database to run under a new ORACLE_SID
================================================================

1. Shutdown instance

2. Backup all control, redo and data files.

3. Go thru the .profile, .cshrc, .login, oratab, tnsnames.ora(for net v2)
, and redefine the environment variable ORACLE_SID to a new value.
ie search thru disks and do a grep ORACLE_SID *

4. cd $ORACLE_HOME/dbs and rename the following files:

o init<sid>.ora (or use pfile to point to the init file.)
o control file(s) This is optional if you don't rename any of
the controlfiles, and the control_files parameter is used.
control_files would be set in the initSID.ora file or in a file
it references with the ifile parameter. Make sure control_files
doesn't point to any old file names, if you renamed them.

o crdb<sid>.sql & crdb2<sid>.sql This is optional. These are
only used at database creation.

5. cd $ORACLE_HOME/rdbms/admin and rename the file:
o startup<sid>.sql This is optional.
(On some platforms, this file may be in $ORACLE_HOME/rdbms/install.)
Make sure the contents of this file do not reference old initSID.ora
files that have been renamed. This file simplifies the process to
"startup exclusive" your database.

6. To rename the database files and redo log files, you would follow
the instructions in the bulletin: 98863.723.

7. Change the ORACLE_SID environment variable to the new value.

8. start up database and verify it works. Once you have done this,
shutdown the database and take a final backup of all control, redo
and data files.

9. When the instance is started, the control file gets updated with
the current ORACLE_SID.


Changing the dbname for a database
----------------------------------

1. sqldba

2. connect internal

3. alter database backup controlfile to trace;
This will write in a trace file, the CREATE CONTROLFILE command that
would recreate the controlfile as it currently exists.

4. Exit and go to the directory where your trace files are located.
They are usually in the $ORACLE_HOME/rdbms/log directory.
If user_dump_dest is set in the initSID.ora, then go to the directory
listed in the user_dump_dest variable.
The trace file will have the form "ora_NNNN.trc with NNNN being a
number.

5. Get the CREATE CONTROLFILE command from the trace file and put it in
a new file called something like ccf.sql.

6. Edit the ccf.sql file and modify the CREATE CONTROLFILE command.
Just change the word "REUSE" to "SET",and "NORESETLOGS" to
"RESETLOGS", and modify the dbname.
Old line:
CREATE CONTROLFILE REUSE DATABASE "olddbname" NORESETLOGS ...
New line:
CREATE CONTROLFILE set DATABASE "newdbname" RESETLOGS ...
Then save the ccf.sql file.

7. Rename the old control files for backup purposes and so they are not
in the way of creating the new ones.

8. Edit initSID.ora so that db_name="newdbname".

9. sqldba

10. connect internal

11. startup nomount

12. @ccf

13. alter database open resetlogs;

14. Make sure the database is working. Shutdown and backup the database.


Reference Documents
-------------------
<Note:15390.1>

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

# UNIX 환경
# 단순 SID 변경은 .profile 변경 및 dbs 의 init<원한는SID> 로만 변경 하면 된다.
# 결과적으로 단순 SID 변경은 Process 만 변경 된다.
# 간만에 SID 변경할 일이 있어서 테스트 한번 해봤음 ㅇ_ㅇ;
# 늘 그렇지만 엄청 새롭다.

TESTTG ==> TESTTGB 로 변경한다고 가정
1. vi .profile 에서 ORACLE_SID 를 원하는 SID 로 변경
   export ORACLE_SID=TESTTGB
2. dbs 에서 init<SID>.ora 을 init<원하는SID>.ora 로 copy 한다.
    cd /app/oracle/product/10.2.0/dbs
    cp initTESTTG.ora initTESTTGB.ora
# 작업 하시 편하게 pfile 환경에서 한다. pfile 생성은
   SQL> create pfile from spfile ;

3.  2번에서 생성한, initTESTTGB.ora 에서 db_name 을 수정한다.
     *.db_name='TESTTGB'

     주의 사항 :

     1.Control File Path 에 주의 하자  ( 원래 DB 가 떠 있는 동일 Machine 에서 하면 Overwrite 된다 ㅇ_ㅇ;)

         #*.control_files='/an01/TEST/TESTTG/control01.ctl'              -- 원본
         *.control_files='/an01/TEST/TESTTG/TESTTGB_control01.ctl' -- 테스트

     2. SGA , PGA 를 적당히 Edit 하자

     3. 필요하다면 필요한 Tablespace 의 Datafile 만 선택 하자 Control file 을 생성하자.

     4. Archive Dest 를 Edit 하자 ( Mount 이후에 alter system 으로 변경 가능하다 )

4. controlfile 재생성 ( 아래와 같이 )
화일 생성을 아래와 같이 TRACE 떨군 후에 Editing
SQL> alter database backup controlfile to trace  ;
Database altered.
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "TESTTGB" RESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/an01/TEST/TESTTG/redo01.log'  SIZE 10M,
  GROUP 2 '/an01/TEST/TESTTG/redo02.log'  SIZE 10M,
  GROUP 3 '/an01/TEST/TESTTG/redo03.log'  SIZE 10M
-- STANDBY LOGFILE
DATAFILE
  '/an01/TEST/TESTTG/system01.dbf',
  '/an01/TEST/TESTTG/undotbs01.dbf',
  '/an01/TEST/TESTTG/sysaux01.dbf',
  '/an01/TEST/TESTTG/users01.dbf'
CHARACTER SET UTF8
;

5. controlfile 재성성 후 Recover Database 진행
(  새로 생성한 control file 을 통한 복구이기 때문에 using backup control 사용

   테스트용이라 until cancel 로 하고 바로 cancel 적용

   SID 변경 후 recovery 도 되고, recovery 후 SID 변경이 가능하다.

   개인적으로, 작업 하기 쉬운건 Recovery 후 SID 변경 을 더 편하다

   아주 가끔 백업 본이 이상하던지, archive file 이상해서, 복구가 안되는 케이스가 발생한다. )
SQL> RECOVER DATABASE using backup controlfile until cancel ;
ORA-00279: change 9151408584711 generated at 11/19/2009 23:56:21 needed for
thread 1
ORA-00289: suggestion : /app/oracle/product/10.2.0/dbs/arch1_12_703375834.dbf
ORA-00280: change 9151408584711 for thread 1 is in sequence #12
 
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Cancel
Media recovery cancelled.

6. RESETLOGS 로 OPEN 한다.
SQL> alter database open resetlogs ;

Database altered.

7. DB NAME 변경된것을 확인 한다.
SQL>  select dbid,name, to_char(created,'YYYY/MM/DD HH24:MI:SS') from v$database ;

      DBID NAME      TO_CHAR(CREATED,'YY
---------- --------- -------------------
3876231960 TESTTGB   2009/11/20 00:26:00

8. Local Listenr 변경 및 Remote tnsnames.ora 에서 TESTTG ==> TESTTGB 로 변경

EM 은 SID 변경에 따라서 당근 재생성 해야 한다.

단순 SID 만 변경해도, EM CONFIG정보는 HOSTNAME_SID 라는 디렉토리에 저장된다.

반응형
Posted by [PineTree]