最简单的oracle10g手工建库步骤

最简单的oracle10g手工建库步骤
平台:Linux AS release 4,Oracle10.2.0.4
db_name = ypythb

1. 设置环境变量
$ export ORACLE_BASE=/oracle
$ export ORACLE_HOME=/oracle/product/10.2
$ export ORACLE_SID=ypythb

2. 建初始化参数文件
$ vi $ORACLE_HOME/dbs/initypythb.ora
#以下为建库必需参数
control_files=(/oradata/ypythb/control1.ctl,/oradata/ypythb/control2.ctl,/oradata/ypythb/control3.ctl)
undo_management=AUTO
undo_tablespace=UNDOTBS1
db_name=ypythb
db_unique_name = ypythb
db_block_size=8192
sga_max_size=2000M
sga_target=3000M
audit_file_dest=/oracle/admin/ypythb/adump
background_dump_dest=/oracle/admin/ypythb/bdump
core_dump_dest=/oracle/admin/ypythb/cdump
user_dump_dest=/oracle/admin/ypythb/udump
open_cursors=1500
processes=500

3. 建立密码文件
$ $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapwypythb password=oracle 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

5. 建spfile后启动实例并开始建库
$ sqlplus '/as sysdba'
SQL> create spfile from pfile;   (会自动读取pfile:$ORACLE_HOME/dbs/init$ORACLE_SID.ora)
SQL> startup nomount
SQL> create database ypythb CONTROLFILE REUSE
   MAXINSTANCES 8 MAXDATAFILES 100
   MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 5  
   character set UTF8 national character set UTF8
   logfile group 1 ('/oradata/ypythb/redo1.log') size 200M reuse,
   group 2 ('/oradata/ypythb/redo2.log') size 200M reuse,
   group 3 ('/oradata/ypythb/redo3.log') size 200M reuse
datafile '/oradata/ypythb/system.dbf' size 1024M reuse autoextend on next 100M maxsize unlimited extent management local
sysaux datafile '/oradata/ypythb/sysaux.dbf' size 1024M autoextend on next 100M maxsize unlimited
default temporary tablespace temp tempfile '/oradata/ypythb/temp01.dbf' size 100M reuse autoextend on next 10M maxsize unlimited
undo tablespace undotbs1 datafile '/oradata/ypythb/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 /oradata/cat_ypythb.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 '/oradata/ypythb/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;
重新编译所有失效过程:
SQL> execute utl_recomp.recomp_serial();

9、建立和配置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";

到此建库完毕!

你可能感兴趣的:(oracle10g)