手動建庫(未實踐)
在node1進行如下操作:
su - oracle
1)使用vi init11grac.ora創建pifle,內容如下:
*.audit_file_dest=‘/u01/app/oracle/admin/prod/adump‘
*.audit_trail=‘db‘
*.control_files=‘+proddata/prod/controlfile/control01.ctl‘,‘+proddata/prod/controlfile/control02.ctl‘,‘+proddata/prod/controlfile/control03.ctl‘
*.db_block_size=8192
*.db_domain=‘‘
*.db_name=‘prod‘
*.db_recovery_file_dest_size=32212254720
*.db_recovery_file_dest=‘+proddata‘
*.diagnostic_dest=‘/u01/app/oracle‘
*.log_archive_dest_1=‘location=+proddata‘
*.open_cursors=500
*.optimizer_mode=‘FIRST_ROWS_100‘
*.PGA_AGGREGATE_TARGET=100m
*.processes=500
*.remote_login_passwordfile=‘EXCLUSIVE‘
*.sec_case_sensitive_logon=FALSE
*.sga_target=280m
*.undo_management=‘auto‘
*.undo_retention=10800
*.lock_sga=true
prod1.undo_tablespace=‘UNDOTBS1‘
prod2.undo_tablespace=‘UNDOTBS2‘
prod1.thread=1
prod2.thread=2
prod1.instance_number=1
prod2.instance_number=2
*.cluster_database=false
*.CLUSTER_DATABASE_INSTANCES=2
相關參數可根據自己需要修改
若有*.audit_file_dest=‘/u01/app/oracle/admin/prod/adump‘ *.audit_trail=‘db‘參數則根據需要分別在兩個節點創建相應目錄
使用本文附件提供的pfile文件init11grac.ora將數據庫啟動到nomount狀態
sqlplus / as sysdba
startup nomount pfile=‘/home/oracle/init11grac.ora‘
2)使用vi crtdbrac.sql創建建庫腳本,腳本內容如下,可根據自己需要進行修改:
create database prod
user sys identified by oracle
user system identified by oracle
controlfile reuse
maxdatafiles 3000
maxinstances 8
character set AL32UTF8
national character set AL16UTF16
set time_zone=‘+8:00‘
datafile ‘+proddata/prod/datafile/system01.dbf‘ size 300m autoextend on next 10m maxsize unlimited extent management local
sysaux datafile ‘+proddata/prod/datafile/sysaux01.dbf‘ size 300m autoextend on next 10m maxsize unlimited
undo tablespace undotbs1 datafile ‘+proddata/prod/datafile/undotbs1_01.dbf‘ size 100m autoextend on next 10m maxsize unlimited
default temporary tablespace temp tempfile ‘+proddata/prod/tempfile/temp01.dbf‘ size 100m autoextend on next 10m maxsize unlimited
maxlogfiles 30
maxlogmembers 5
maxloghistory 1000
logfile
group 1 (‘+proddata/prod/onlinelog/redo1_1.rdo‘,‘+proddata/prod/onlinelog/redo1_2.rdo‘) size 50m,
group 2 (‘+proddata/prod/onlinelog/redo2_1.rdo‘,‘+proddata/prod/onlinelog/redo2_2.rdo‘) size 50m,
group 3 (‘+proddata/prod/onlinelog/redo3_1.rdo‘,‘+proddata/prod/onlinelog/redo3_2.rdo‘) size 50m;
在sqlplus中運行該建庫腳本
SQL>@crtdbrac.sql
庫建完後創建相應視圖
SQL>@?/rdbms/admin/catalog
SQL>@?/rdbms/admin/catproc
SQL>@?/rdbms/admin/owminst.plb
SQL>@?/rdbms/admin/catclust.sql
切換到system用戶運行以下腳本
SQL>conn system/oracle
SQL>@?/sqlplus/admin/pupbld
SQL>@?/sqlplus/admin/help/hlpbld.sql helpus.sql
3)創建SPFILE
SQL>create spfile=‘+PRODDATA/prod/PARAMETERFILE/spfileprod.ora‘ from pfile=‘/home/oracle/init11grac.ora‘
分別在兩個節點的$ORACLE_HOME/dbs下創建initprod1.ora和initprod2.ora內容為
spfile=‘+PRODDATA/prod/PARAMETERFILE/spfileprod.ora‘
在node1使用默認路徑$ORACLE_HOME/dbs下的pfile文件initprod1.ora重啟數據庫
4)創建數據庫默認表空間users
SQL>create tablespace users datafile ‘+proddata/prod/datafile/users01.dbf‘ size 100m autoextend on next 10m maxsize unlimited segment space management auto;
SQL>alter database default tablespace users;
5)創建節點2的undo表空間undotbs2
SQL>create undo tablespace undotbs2 datafile ‘+proddata/prod/datafile/undotbs2_01.dbf‘ size 100m autoextend on next 10m maxsize unlimited segment space management auto;
6)創建thread 2的3組redo日誌組並啟用thread 2
SQL>alter database add logfile thread 2 (‘+proddata‘,‘+proddata‘) size 50m;
SQL>alter database add logfile thread 2 (‘+proddata‘,‘+proddata‘) size 50m;
SQL>alter database add logfile thread 2 (‘+proddata‘,‘+proddata‘) size 50m;
SQL>alter database enable thread 2;
7)開啟歸檔和flashback
在node1上將數據庫重啟到mount狀態,然後開啟歸檔和flashback
SQL>alter database archivelog;
SQL>alter database flashback on;
7)node2使用默認路徑$ORACLE_HOME/dbs下的pfile文件initprod2.ora啟動數據庫
SQL>startup
8)將數據庫資源添加到CRS管理
在任意節點上以oracle用戶執行以下命令
srvctl add database -d prod -o /u01/app/oracle/product/11.2/db_1/ -c RAC -y AUTOMATIC
9)將兩個節點的實例資源添加到CRS管理
在任意節點上以ORACLE用戶執行以下命令
srvctl add instance -d prod -i prod1 -n ora1
srvctl add instance -d prod -i prod2 -n ora2
10)使用sqlplus關閉兩節點實例,使用crs啟動數據庫
從11GR2開始,instance資源在crs_stat -t中是看不到的,只能看到DB的資源
可以使用srvctl start database -d prod 來檢查數據庫實例的運行狀況
關閉兩個節點後,在任意節點以oracle或root帳戶使用以下命令啟動數據庫
srvctl start database -d prod
或者
crs_start ora.prod.db
手動建庫(未實踐)