ORACLE RAC 手動建庫

renjixinchina發表於2013-12-13

環境

11.2.0.1 RAC

前提條件

Grid Infrastructure已經安裝 ASM已經建立 DB軟體已經安裝

透過手動建立RAC可以更深的理解單例項DBRAC DB 的一些區別,DBCA無法使用的場景中,也需要手動的方式建立,建立步驟如下:

大概思路:先建立單例項DB再轉為RAC DB

1.       建立目錄

mkdir -p /u01/app/oracle/admin/orcl/adump

2.       編輯引數檔案

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'

*.audit_trail='db'

*.control_files=’+DATA/orcl/controlfile/control01.ctl’, ‘+DATA/orcl/controlfile/control02.ctl’                                             

*.db_block_size=8192

*.db_create_file_dest='+DATA'

*.db_domain=''

*.db_name='orcl'

*.db_recovery_file_dest='+DATA'

*.db_recovery_file_dest_size=10737418240

*.diagnostic_dest='/u01/app/oracle'

*.memory_target=1658847232

*.open_cursors=300

*.processes=150

*.remote_listener='scanip:1521'

*.remote_login_passwordfile='exclusive'

3.       建立ASM目錄和建立spfile

[oracle@node1 ~]$ export ORACLE_SID=orcl1

[oracle@node1 ~]$ sqlplus / as sysdba   

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 12 08:03:22 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile='+DATA/orcl/spfileorcl.ora' from pfile='/home/oracle/orcl.ora';

create spfile='+DATA/orcl/spfileorcl.ora' from pfile='/home/oracle/orcl.ora'

*

ERROR at line 1:

ORA-17502: ksfdcre:4 Failed to create file +DATA/orcl/spfileorcl.ora

ORA-15056: additional error message

ORA-17502: ksfdcre:4 Failed to create file +DATA/orcl/spfileorcl.ora

ORA-15173: entry 'orcl' does not exist in directory '/'

ORA-06512: at line 4

SQL> exit

Disconnected

[oracle@node1 ~]$ su - grid

Password:

su: incorrect password

[oracle@node1 ~]$ su - grid

Password:

[grid@node1 ~]$ asmcmd

ASMCMD> ls

CRS/

DATA/

ASMCMD> cd DATA

ASMCMD> ls

RACDB/

ASMCMD> mkdir ORCL

ASMCMD> exit

[grid@node1 ~]$

[grid@node1 ~]$

[grid@node1 ~]$ exit

logout

[oracle@node1 ~]$ export ORACLE_SID=orcl1

[oracle@node1 ~]$ sqlplus / as sysdba   

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 12 08:05:10 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile='+DATA/orcl/spfileorcl.ora' from pfile='/home/oracle/orcl.ora';

File created.

SQL>

建立init檔案

節點1

vi initorcl1.ora

SPFILE='+DATA/orcl/spfileorcl.ora'

節點2

vi initorcl2.ora

SPFILE='+DATA/orcl/spfileorcl.ora'

4.       建立密碼檔案

cd $ORACLE_HOME/dbs

節點1

orapwd file=orapwORCL1 password=oracle

節點

orapwd file=orapwORCL2 password=oracle

5.       建立DB

CREATE DATABASE orcl

   USER SYS IDENTIFIED BY oracle

   USER SYSTEM IDENTIFIED BY oracle

   LOGFILE GROUP 1  SIZE 100M,

           GROUP 2  SIZE 100M,

           GROUP 3  SIZE 100M

   MAXLOGFILES 5

   MAXLOGMEMBERS 5

   MAXLOGHISTORY 1

   MAXDATAFILES 100

   CHARACTER SET US7ASCII

   NATIONAL CHARACTER SET AL16UTF16

   EXTENT MANAGEMENT LOCAL

   DATAFILE  SIZE 325M

   SYSAUX DATAFILE  SIZE 325M

   DEFAULT TABLESPACE users

      DATAFILE

      SIZE 500M  AUTOEXTEND ON MAXSIZE UNLIMITED

   DEFAULT TEMPORARY TABLESPACE tempts1

      TEMPFILE

      SIZE 20M

   UNDO TABLESPACE undotbs1

      DATAFILE

      SIZE 200M  AUTOEXTEND ON MAXSIZE UNLIMITED;

6.       建立undo 和新增redo

CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE SIZE 200M;

ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 4 SIZE 100M; 

ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 5 SIZE 100M;

ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 6 SIZE 100M; 

(以下轉單例項dbRAC DB)

7.       新增rac 引數

*.cluster_database=true

orcl1.instance_number=1

orcl2.instance_number=2

orcl2.thread=2

orcl1.thread=1

orcl1.undo_tablespace='UNDOTBS1'

orcl2.undo_tablespace='UNDOTBS2'

8.       啟動所有節點例項

 [oracle@node1 ~]$ sqlplus / as sysdba

SQL> startup

ORACLE instance started.

Total System Global Area 1653518336 bytes

Fixed Size                  2213896 bytes

Variable Size             956303352 bytes

Database Buffers          687865856 bytes

Redo Buffers                7135232 bytes

Database mounted.

Database opened.

SQL> ALTER DATABASE ENABLE PUBLIC THREAD 2;

Database altered.

[oracle@node1 ~]$

[oracle@node1 ~]$

[oracle@node1 ~]$ ssh node2         

Last login: Thu Dec 12 09:43:51 2013 from node1

[oracle@node2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 12 10:00:33 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area 1653518336 bytes

Fixed Size                  2213896 bytes

Variable Size             956303352 bytes

Database Buffers          687865856 bytes

Redo Buffers                7135232 bytes

Database mounted.

Database opened.

SQL>

SQL>

SQL>

SQL> select instance_name from gv$instance;

INSTANCE_NAME

----------------

orcl2

orcl1

9.       執行建立資料字典指令碼

@$ORACLE_HOME/rdbms/admin/catalog.sql

@$ORACLE_HOME/rdbms/admin/catproc.sql

@$ORACLE_HOME/rdbms/admin/catclust.sql

--rac 相關字典

@$ORACLE_HOME/rdbms/admin/utlrp.sql

10. 註冊資料庫到Clusterware 

[oracle@node1 ~]$ srvctl add database -d orcl -o $ORACLE_HOME

[oracle@node1 ~]$ srvctl add instance -d orcl -i orcl1 -n node1

[oracle@node1 ~]$ srvctl add instance -d orcl -i orcl2 -n node2

[oracle@node1 ~]$ srvctl enable database -d orcl

PRCC-1010 : orcl was already enabled

[oracle@node1 ~]$ srvctl start database -d orcl    

 

[grid@node1 ~]$ crsctl stat res -t

--------------------------------------------------------------------------------

NAME           TARGET  STATE        SERVER                   STATE_DETAILS      

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.CRS.dg

               ONLINE  ONLINE       node1                                       

               ONLINE  ONLINE       node2                                       

ora.DATA.dg

               ONLINE  ONLINE       node1                                       

               ONLINE  ONLINE       node2                                       

ora.LISTENER.lsnr

               ONLINE  ONLINE       node1                                       

               ONLINE  ONLINE       node2                                       

ora.asm

               ONLINE  ONLINE       node1                    Started            

               ONLINE  ONLINE       node2                                       

ora.eons

               ONLINE  ONLINE       node1                                       

               ONLINE  ONLINE       node2                                       

ora.gsd

               OFFLINE OFFLINE      node1                                        

               OFFLINE OFFLINE      node2                                       

ora.net1.network

               ONLINE  ONLINE       node1                                       

               ONLINE  ONLINE       node2                                        

ora.ons

               ONLINE  ONLINE       node1                                       

               ONLINE  ONLINE       node2                                       

ora.registry.acfs

               ONLINE  ONLINE       node1                                       

               ONLINE  ONLINE       node2                                       

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       node2                                       

ora.node1.vip

      1        ONLINE  ONLINE       node1                                        

ora.node2.vip

      1        ONLINE  ONLINE       node2                                       

ora.oc4j

      1        OFFLINE OFFLINE                                                  

ora.orcl.db

      1        ONLINE  ONLINE       node1                    Open               

      2        ONLINE  ONLINE       node2                    Open               

ora.scan1.vip

      1        ONLINE  ONLINE       node2                                       

11. 兩個節點配置tnsnames.ora

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

相關文章