1 、确定数据库的sid 和db_name
sid='hsj'
db_name='hsj'
2、设置环境变量env
ORACLE_BASE=/u01/app ORACLE_HOME=$ORACLE_BASE/oracle ORACLE_SID=hsj PATH=$ORACLE_HOEM/bin:$PATH; LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH |
3、设置登录方法,使用操作系统登录还是远程登录
使用本地操作系统用户,具有dba权限的oracle用户
sqlplus /nolog
conn as sysdba;
4、创建一个使用的pfile文件
vi inithsj.ora hsj.__db_cache_size=385875968 hsj.__java_pool_size=4194304 hsj.__large_pool_size=4194304 hsj.__shared_pool_size=163577856 hsj.__streams_pool_size=0 audit_file_dest='/u01/app/admin/hsj/adump' background_dump_dest='/u01/app/admin/hsj/bdump' compatible='10.2.0.1.0' control_files='/u01/app/oradata/hsj/control01.ctl','/u01/app/oradata/hsj/control02.ctl','/u01/app/oradata/hsj/control03.ctl' core_dump_dest='/u01/app/admin/hsj/cdump' db_block_size=8192 db_domain='' db_file_multiblock_read_count=16 db_name='hsj' db_recovery_file_dest='/u01/app/flash_recovery_area' db_recovery_file_dest_size=2147483648 dispatchers='(PROTOCOL=TCP) (SERVICE=hsjXDB)' job_queue_processes=10 log_archive_format='%t_%s_%r.dbf' open_cursors=300 pga_aggregate_target=187695104 processes=150 remote_login_passwordfile='EXCLUSIVE' sga_target=563085312 undo_management='AUTO' undo_tablespace='UNDOTBS1' user_dump_dest='/u01/app/admin/hsj/udump' |
5、根据pfile文件创建想对应的目录
需要在$ORACLE_BASE/admin 下创建一个目录 hsj及其相关的子目录
$ORACLE_BASE/oradate 下面增加一个目录 hsj 及其子目录 archivelog
6、根据pfile文件创建spfile
startup nomount;
create spfile from pfile;
shutdown immediate;
7、在$ORACLE_HOME/dbs/ 下创建 orapwhsj
orapwd file=orapwhsj password=root entries=5
8、使用spfile启动数据库到nomount状态
startup up nomount
9、使用脚本创建数据库
spool db.log; CREATE DATABASE "hsj" USER SYS IDENTIFIED BY root USER SYSTEM IDENTIFIED BY root MAXDATAFILES 500 MAXINSTANCES 8 MAXLOGFILES 32 CHARACTER SET "UTF8" NATIONAL CHARACTER SET AL16UTF16 ARCHIVELOG DATAFILE '/u01/app/oradata/hsj/system01.dbf' size 300M EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '/u01/app/oradata/hsj/sysaux01.dbf' SIZE 325M REUSE DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/u01/app/oradata/hsj/tempts01.dbf' SIZE 100M EXTENT MANAGEMENT LOCAL UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/app/oradata/hsj/undotbs01.dbf' SIZE 200M LOGFILE GROUP 1 ( '/u01/app/oradata/hsj/redo01a.rdo', '/u01/app/oradata/hsj/redo01b.rdo' ) SIZE 100M, GROUP 2 ( '/u01/app/oradata/hsj/redo02a.rdo', '/u01/app/oradata/hsj/redo02b.rdo' ) SIZE 100M, GROUP 3 ( '/u01/app/oradata/hsj/redo03a.rdo', '/u01/app/oradata/hsj/redo03b.rdo' ) SIZE 100M ; spool off; |
10 运行脚本创建数据字典
@ORACLE_HOME/admin/catalog.sql(@/u01/app/oracle/admin/catalog.sql)
@ORACLE_HOME/admin/catproc.sql(@/u01/app/oracle/admin/catproc.sql)
11 启动数据库
startup
12 备份数据库
backup database