oracle11g手工建库步骤
平台:Linux version 2.6.16.46-0.12-smp (geeko@buildhost) (gcc version 4.1.2 20070115 (prerelease)
(SUSE Linux)) #1 SMP Thu May 17 14:00:09 UTC 2007,
Oracle Release 11.1.0.7.0
db_name = testdb
1. 设置环境变量
$ export ORACLE_BASE=/opt/oracle
$ export ORACLE_HOME=/opt/oracle/product/11g/db
$ export ORACLE_SID=testdb
2. 建立需要的目录
$ 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
3. 建初始化参数文件
$ vi $ORACLE_HOME/dbs/inittestdb.ora
#以下为建库必需参数
control_files=(/opt/oradata/testdb/control1.ctl,/opt/oradata/testdb/control2.ctl,/opt/oradata/testdb/control3.ctl)
undo_management=AUTO
undo_tablespace=UNDOTBS1
db_name=testdb
db_unique_name=testdb
db_block_size=8192
memory_target=4000M
audit_file_dest=/opt/oradata/admin/testdb/adump
background_dump_dest=/opt/oradata/admin/testdb/bdump
core_dump_dest=/opt/oradata/admin/testdb/cdump
user_dump_dest=/opt/oradata/admin/testdb/udump
db_create_file_dest=/opt/oradata/testdb
open_cursors=1500
processes=1500
4. 建立密码文件
$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapwypythb password=oracle force=y
5. 建spfile后启动实例并开始建库
$ sqlplus '/as sysdba'
SQL> create spfile from pfile; (会自动读取pfile:$ORACLE_HOME/dbs/init$ORACLE_SID.ora)
SQL> startup nomount
SQL> create database testdb CONTROLFILE REUSE
MAXINSTANCES 8 MAXDATAFILES 2000
MAXLOGHISTORY 2 MAXLOGFILES 64 MAXLOGMEMBERS 5
character set ZHS16GBK national character set AL16UTF16
logfile group 1 ('/opt/oradata/testdb/redo1.log') size 512M reuse,
group 2 ('/opt/oradata/testdb/redo2.log') size 512M reuse,
group 3 ('/opt/oradata/testdb/redo3.log') size 512M reuse
datafile '/opt/oradata/testdb/system.dbf' size 1024M reuse autoextend on next 100M maxsize unlimited extent management local
sysaux datafile '/opt/oradata/testdb/sysaux.dbf' size 1024M autoextend on next 100M maxsize unlimited
default temporary tablespace temp tempfile '/opt/oradata/testdb/temp01.dbf' size 100M reuse autoextend on next 10M maxsize unlimited
undo tablespace undotbs1 datafile '/opt/oradata/testdb/undotbs1.dbf' size 100M reuse autoextend on next 10M maxsize unlimited
USER SYS IDENTIFIED BY "oracle" USER SYSTEM IDENTIFIED BY "oracle";
6. 运行数据字典脚本,其中catalog和catproc是必需的,其它可选:
SQL> spool /opt/oradata/cat_testdb.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看看有什么不可接受的错误没有。
7. 新建sqlplus属性和帮助、USERS表空间
SQL> connect system/oracle
SQL> @?/sqlplus/admin/pupbld.sql
SQL> @?/sqlplus/admin/help/hlpbld.sql helpus.sql
SQL> connect /as sysdba
SQL> CREATE TABLESPACE USERS LOGGING DATAFILE '/opt/oradata/testdb/users01.dbf' SIZE 1024M REUSE AUTOEXTEND ON NEXT 100m MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
SQL> ALTER DATABASE DEFAULT TABLESPACE USERS;
8. 最后修改为归档模式并重启(省略此步骤)
SQL> shutdown immediate;
SQL> connect /as sysdba
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
9.重新编译所有失效过程:
SQL> execute utl_recomp.recomp_serial();
10、建立和配置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 ypyhtb -PORT 1521 -EM_HOME /oracle/product/10.2/bin -LISTENER LISTENER -SERVICE_NAME ypythb.LK -SYS_PWD "oracle" -SID ypythb -ORACLE_HOME /oracle/product/10.2 -DBSNMP_PWD "dbsnmp" -HOST "172.19.201.184" -LISTENER_OH /oracle/product/10.2 -LOG_FILE /oradata/ypythb/emConfig.log -SYSMAN_PWD "sysman";
到此建库完毕!