oracle10g手工建庫步驟

來源:互聯網
上載者:User

平台:RHEL4.5,Oracle10.2.0.1
規劃:db_name = ORCLDB, db_unique_name/ORACLE_SID = WENDING
上面這兩個參數也可以設定成一樣,這裡主要就是特意區別一下。

1. 設定環境變數
$ export ORACLE_BASE=/u01/app/oracle
$ export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

$ export ORACLE_SID=WENDING



2. 建初始化參數檔案
$ vi $ORACLE_HOME/dbs/init$ORACLE_SID.ora
#以下為建庫必需參數
control_files = (/orahome/oradata/control1.ctl,/orahome/oradata/control2.ctl,/orahome/oradata/control3.ctl)
undo_management = AUTO
undo_tablespace = UNDOTBS1
db_name = ORCLDB
db_unique_name = WENDING
db_block_size = 8192
sga_max_size = 320M

sga_target = 320M


#以下為一般建庫需設定的參數,不設定就採用預設值
audit_file_dest = /u01/app/oracle/admin/WENDING/adump #不設定預設$ORACLE_HOME/rdbms/adump
background_dump_dest = /u01/app/oracle/admin/WENDING/bdump #不設定預設$ORACLE_HOME/rdbms/log
core_dump_dest = /u01/app/oracle/admin/WENDING/cdump #不設定預設$ORACLE_HOME/rdbms/dbs
user_dump_dest = /u01/app/oracle/admin/WENDING/udump #不設定預設$ORACLE_HOME/rdbms/log
db_domain = LK #不設定預設為空白
open_cursors = 1500 #不設定預設50
processes = 500 #不設定預設40
log_archive_dest_1 = 'LOCATION=/orahome/arch/WENDING' #不設定預設為空白,Archive Storage在$ORACLE_HOME/rdbms/dbs/arch
log_archive_format = 'log_%t_%s_%r.arc' #不設定預設為%t_%s_%r.dbf
job_queue_processes = 10 #不設定預設為0

undo_retention = 10800 #不設定預設為900


#如果需要開通審計功能,設定如下參數
audit_sys_operations = TRUE
audit_trail = db,extended #這裡注意,如果將來會轉換成物理備庫,這裡就不能設定db,否則將來物理備庫沒法開啟read only模式
db_recovery_file_dest = /orahome/flash_recovery_area #OMF模式必需設定

db_recovery_file_dest_size = 2G #OMF模式必需設定



#如果採用OMF管理資料庫檔案,則還需設定以下參數
db_create_file_dest = /orahome/oradata #自動在該目錄下建立./{db_name}/datafile 目錄
db_create_online_log_dest_1 = /orahome/oradata #自動在該目錄下建立./{db_name}/onlinelog 目錄



3. 建立密碼檔案
$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=iamwangnc force=y

4. 建立需要的目錄
$ rm -rf $ORACLE_BASE/admin/$ORACLE_SID
$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/bdump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/cdump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/dpdump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/udump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/pfile



#如果採用OMF管理資料庫檔案,則無需建立下面的目錄
$ rm -rf /orahome/oradata/WENDING
mkdir -p /orahome/oradata/WENDING
$ rm -rf /orahome/arch/WENDING
mkdir -p /orahome/arch/WENDING



5. 建spfile後啟動執行個體並開始建庫
$ sqlplus '/as sysdba'
SQL> create spfile from pfile; (會自動讀取pfile:$ORACLE_HOME/dbs/init$ORACLE_SID.ora)
SQL> startup nomount
SQL> create database ORCLDB CONTROLFILE REUSE
MAXINSTANCES 8 MAXDATAFILES 100
MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 5
character set ZHS16GBK national character set AL16UTF16
logfile group 1 ('/orahome/oradata/WENDING/redo1.log') size 50M reuse,
group 2 ('/orahome/oradata/WENDING/redo2.log') size 50M reuse,
group 3 ('/orahome/oradata/WENDING/redo3.log') size 50M reuse
datafile '/orahome/oradata/WENDING/system.dbf' size 500M reuse autoextend on next 10M maxsize unlimited extent management local
sysaux datafile '/orahome/oradata/WENDING/sysaux.dbf' size 100M autoextend on next 10M maxsize unlimited
default temporary tablespace temp tempfile '/orahome/oradata/WENDING/temp01.dbf' size 100M reuse autoextend on next 10M maxsize unlimited
undo tablespace undotbs1 datafile '/orahome/oradata/WENDING/undotbs1.dbf' size 100M reuse autoextend on next 10M maxsize unlimited
USER SYS IDENTIFIED BY "iamwangnc" USER SYSTEM IDENTIFIED BY "iamwangnc";



建庫還可以考慮如下參數:
SET TIMEZONE = 'time_zone_region'
SET TIMEZONE = '{+|-} hh:mm'
FORCE LOGGING
建完庫,資料庫就自動open了。
注意:MAXLOGFILES代表可建立的logfile group數,MAXLOGMEMBERS代表每個group內的member數。10.2前如果超過了就需要重建控制檔案,10.2中就沒這個必要了,Oracle會自動更新控制檔案裡這兩個參數值,不需要重建控制檔案了!oracle10g中預設MAXLOGFILES為16,MAXLOGMEMBERS為3但建立時不能超過5否則會出現ORA-02249錯誤。
另外,如果以後要獲得指定的這些MAXxxx參數,可以通過通過轉儲控制檔案的方式獲得:alter database backup controlfile to trace;

如果採用OMF管理資料庫檔案,則通過以下方式建庫:
SQL> create database ORCLDB
controlfile reuse ARCHIVELOG
character set ZHS16GBK national character set AL16UTF16
undo tablespace undotbs1
default temporary tablespace temp;
或者直接最小方式建立(字元集根據作業系統會自動指定,其它參數用預設值):
SQL> create database ORCLDB;



7. 運行資料字典指令碼,其中catalog和catproc是必需的,其它可選:
SQL> spool /orahome/cat.log
SQL> @?/rdbms/admin/catalog.sql (建資料字典視圖)
SQL> @?/rdbms/admin/catproc.sql (建預存程序包)
SQL> @?/rdbms/admin/catblock.sql (建鎖相關的幾個視圖)
SQL> @?/rdbms/admin/catoctk.sql (建密碼工具包dbms_crypto_toolkit)
SQL> @?/rdbms/admin/owminst.plb (建工作空間管理相關對象,如dmbs_wm)
SQL> spool off
執行完後檢查/orahome/cat.log看看有什麼不可接受的錯誤沒有。



8. 建立sqlplus屬性和協助、USERS資料表空間
SQL> connect system/iamwangnc
SQL> @?/sqlplus/admin/pupbld.sql
SQL> @?/sqlplus/admin/help/hlpbld.sql helpus.sql
SQL> connect /as sysdba
SQL> CREATE TABLESPACE USERS LOGGING DATAFILE '/orahome/oradata/WENDING/users01.dbf' SIZE 100M REUSE AUTOEXTEND ON NEXT 10m MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
SQL> ALTER DATABASE DEFAULT TABLESPACE USERS;



9. 最後修改為歸檔模式並重啟
SQL> shutdown immediate;
SQL> connect /as sysdba
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
重新編譯所有失效過程:
SQL> execute utl_recomp.recomp_serial();



10、建立和配置EM(可選):
SQL> @?/sysman/admin/emdrep/sql/emreposcre /u01/app/oracle/product/10.2.0/db_1 SYSMAN iamwangnc TEMP ON;
SQL> alter user SYSMAN identified by "iamwangnc" account unlock;
SQL> alter user DBSNMP identified by "iamwangnc" account unlock;
SQL> host emca -config dbcontrol db -silent -DB_UNIQUE_NAME WENDING -PORT 1521 -EM_HOME /u01/app/oracle/product/10.2.0/db_1 -LISTENER LISTENER -SERVICE_NAME WENDING.LK -SYS_PWD "iamwangnc" -SID WENDING -ORACLE_HOME /u01/app/oracle/product/10.2.0/db_1 -DBSNMP_PWD "iamwangnc" -HOST "vmone" -LISTENER_OH /u01/app/oracle/product/10.2.0/db_1 -LOG_FILE /orahome/emConfig.log -SYSMAN_PWD "iamwangnc";

到此建庫完畢!

--End-- 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.