平台:Linux AS release 5,Oracle11.1.0.7
db_name = SBDB
1. 设置环境变量
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/11.1.0/db_1
export ORACLE_SID=SBDB
2. 建初始化参数文件
vi $ORACLE_HOME/dbs/initSBDB.ora
#以下为建库必需参数
db_name=SBDB
db_unique_name = SBDB
db_block_size=8192
memory_target=500M
undo_tablespace=UNDOTBS1
db_recovery_file_dest='/opt/oracle/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/opt/oracle'
control_files=(/opt/oracle/oradata/SBDB/control1.ctl,/opt/oracle/oradata/SBDB/control2.ctl,/opt/oracle/oradata/SBDB/control3.ctl)
open_cursors=500
processes=300
compatible ='11.1.0'
remote_login_passwordfile='EXCLUSIVE'
3. 建立密码文件
$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapwSBDB password=ocmb123 force=y
4. 建立需要的目录
mkdir -p $ORACLE_BASE/flash_recovery_area
mkdir -p $ORACLE_BASE/oradata/SBDB
5. 建spfile后启动实例并开始建库
$ sqlplus /nolog
SQL> CONNECT SYS AS SYSDBA
SQL> create spfile from pfile; (会自动读取pfile:$ORACLE_HOME/dbs/init$ORACLE_SID.ora)
SQL> startup nomount
SQL> create database SBDB CONTROLFILE REUSE
MAXINSTANCES 8 MAXDATAFILES 100
MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 5
character set UTF8 national character set UTF8
logfile group 1 ('/opt/oracle/oradata/SBDB/redo1.log') size 200M reuse,
group 2 ('/opt/oracle/oradata/SBDB/redo2.log') size 200M reuse,
group 3 ('/opt/oracle/oradata/SBDB/redo3.log') size 200M reuse
datafile '/opt/oracle/oradata/SBDB/system.dbf' size 1024M reuse autoextend on next 100M maxsize unlimited extent management local
sysaux datafile '/opt/oracle/oradata/SBDB/sysaux.dbf' size 1024M autoextend on next 100M maxsize unlimited
default temporary tablespace temp tempfile '/opt/oracle/oradata/SBDB/temp01.dbf' size 100M reuse autoextend on next 10M maxsize unlimited
undo tablespace undotbs1 datafile '/opt/oracle/oradata/SBDB/undotbs1.dbf' size 100M reuse autoextend on next 10M maxsize unlimited
USER SYS IDENTIFIED BY "ocmb123" USER SYSTEM IDENTIFIED BY "ocmb123";
6. 运行数据字典脚本,其中catalog和catproc是必需的,其它可选:
SQL> spool /opt/oracle/oradata/cat_SBDB.log
SQL> @?/rdbms/admin/catalog.sql (建数据字典视图)
SQL> @?/rdbms/admin/catproc.sql (建存储过程包)
SQL> @?/sqlplus/admin/pupbld.sql (Required for SQL*Plus. Enables SQL*Plus to disable commands by user.)
SQL> spool off
执行完后检查/orahome/cat.log看看有什么不可接受的错误没有。
7. 最后修改为归档模式并重启
SQL> shutdown immediate;
SQL> connect /as sysdba
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
重新编译所有失效过程:
SQL> execute utl_recomp.recomp_serial();
8、建立和配置EM(可选):
SQL> @?/sysman/admin/emdrep/sql/emreposcre /oracle/product/10.2 SYSMAN oracle TEMP ON;
SQL> alter user SYSMAN identified by "sysman" account unlock;
SQL> alter user DBSNMP identified by "dbsnmp" account unlock;
SQL> host emca -config dbcontrol db -silent -DB_UNIQUE_NAME SBDB -PORT 1521 -EM_HOME /opt/oracle/product/10.2.0/db_1/bin -LISTENER LISTENER -SERVICE_NAME SBDB.LK -SYS_PWD "oracle" -SID SBDB -ORACLE_HOME /opt/oracle/product/10.2.0/db_1 -DBSNMP_PWD "dbsnmp" -HOST "172.19.201.188" -LISTENER_OH /opt/oracle/product/10.2.0/db_1 -LOG_FILE /opt/oracle/oradata/SBDB/emConfig.log -SYSMAN_PWD "sysman";
到此建库完毕!