Oracle 11g 手动创建数据库过程

Oracle · ruyi · 于 2年前发布 · 1785 次阅读

以下为Oracle 11g 手动创建数据库详细过程:

1.修改oracle用户环境变量

$ vim .bash_profile
#oracle env  
NLS_LANG="SIMPLIFIED CHINESE_CHINA.UTF8"
ORACLE_BASE=/home/oracle/product
ORACLE_HOME=$ORACLE_BASE/11203/db1
export ORACLE_BASE ORACLE_HOME NLS_LANG
ORACLE_SID=yhd
export ORACLE_SID
ORACLE_TERM=xterm
export ORACLE_TERM
PATH=$HOME/bin:$ORACLE_HOME/bin:$PATH
export PATH
NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_LANG

修改完成后使设置生效

$ . .bash_profile
$ env |grep ORACLE
ORACLE_SID=yhd
ORACLE_BASE=/home/oracle/product
ORACLE_TERM=xterm
ORACLE_HOME=/home/oracle/product/11203/db1

2.创建数据文件目录和其他需要的目录

# mkdir -p /data/oradata/yhd
# chown -R oracle:oinstall /data/oradata
# su - oracle
$ mkdir -p /home/oracle/product/admin/yhd/adump
$ mkdir -p /home/oracle/product/admin/yhd/cdump
$ mkdir -p /home/oracle/product/admin/yhd/diag

3.创建参数文件

$ cd $ORACLE_HOME/dbs
$ cat init.ora |grep -v ^# > inityhd.ora
$ vim inityhd.ora

写入和修改配置文件

db_name='yhd'
memory_target=8G
processes = 150
audit_file_dest= /home/oracle/product/admin/yhd/adump
audit_trail ='db'

db_block_size=8192
db_domain=''
db_recovery_file_dest='/data/oradata/flash_recovery_area'
db_recovery_file_dest_size=6G
diagnostic_dest='<ORACLE_BASE>'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
undo_management=auto
control_files = ('/data/oradata/yhd/control01.ctl','/data/oradata/yhd/control02.ctl','/data/oradata/yhd/control03.ctl')
sga_target = 4G
compatible ='11.2.0'
core_dump_dest=/home/oracle/product/admin/yhd/cdump
diagnostic_dest=/home/oracle/product/admin/yhd/diag

wmssh6.__db_cache_size=109521666048
wmssh6.__java_pool_size=268435456
wmssh6.__large_pool_size=268435456
wmssh6.__oracle_base='/home/oracle/app'#ORACLE_BASE set from environment
wmssh6.__pga_aggregate_target=21474836480
wmssh6.__sga_target=118111600640
wmssh6.__shared_io_pool_size=0
wmssh6.__shared_pool_size=7516192768
wmssh6.__streams_pool_size=0
*._b_tree_bitmap_plans=FALSE
*._in_memory_undo=FALSE
*._memory_imm_mode_without_autosga=FALSE
*._optim_peek_user_binds=FALSE
*._optimizer_adaptive_cursor_sharing=FALSE
*._optimizer_extended_cursor_sharing_rel='NONE'
*._optimizer_extended_cursor_sharing='NONE'
*.compatible='11.2.0'
*.control_files='/data2/oracle/oradata/wmssh6/control01.ctl','/data2/oracle/oradata/wmssh6/control02.ctl','/data2/oracle/oradata/wmssh6/control03.ctl'
*.db_block_size=8192
*.db_name='wmssh6'
*.db_securefile='NEVER'
*.db_unique_name='wmsshdg2'
*.deferred_segment_creation=FALSE
*.diagnostic_dest='/home/oracle/app'
*.fal_client='wmsshdg2'
*.fal_server='wmssh'
*.filesystemio_options='SETALL'
*.job_queue_processes=10
*.log_archive_config='DG_CONFIG=(wmssh,wmsshdg,wmsshdg2)'
*.log_archive_dest_1='LOCATION=/data/oracle/arch'
*.log_archive_dest_2='service=wmssh lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=wmssh'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.log_archive_format='%t_%s_%r.dbf'
*.pga_aggregate_target=21474836480
*.processes=4000
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_manager_plan=''
*.sga_max_size=118111600640
*.sga_target=118111600640
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'

4.创建密码文件

$ cd $ORACLE_HOME/dbs 
$ orapwd file=orapwyhd password=oracle

5.启动数据库到nomount

$ sqlplus / as sysdba
SQL> startup nomount;

6.编写建库脚本

$ vim createdb.sql
CREATE DATABASE yhd
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
MAXINSTANCES 2
MAXDATAFILES 2048
MAXLOGMEMBERS 5
MAXLOGHISTORY 20
DATAFILE '/data/oradata/yhd/system01.dbf' SIZE 1G AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
SYSAUX DATAFILE '/data/oradata/yhd/sysaux01.dbf' SIZE 500M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/data/oradata/yhd/temp01.dbf' SIZE 500M
UNDO TABLESPACE undotbs1 DATAFILE '/data/oradata/yhd/undotbs1.dbf' SIZE 200M AUTOEXTEND ON NEXT 20M MAXSIZE UNLIMITED
DEFAULT TABLESPACE yhd
      DATAFILE '/data/oradata/yhd/yhd01.dbf'
      SIZE 1G
LOGFILE GROUP 1 ('/data/oradata/yhd/redo1_1.rdo','/data/oradata/yhd/redo1_2.dbf') SIZE 50M,
        GROUP 2 ('/data/oradata/yhd/redo2_1.rdo','/data/oradata/yhd/redo2_2.dbf') SIZE 50M,
        GROUP 3 ('/data/oradata/yhd/redo3_1.rdo','/data/oradata/yhd/redo3_2.dbf') SIZE 50M;

7.执行建库脚本

SQL> @/home/oracle/product/11203/db1/dbs/createdb.sql

8.运行数据字典

SQL> @?/rdbms/admin/catalog.sql 
SQL> @?/rdbms/admin/catproc.sql
SQL> @?/rdbms/admin/catblock.sql

9.新建sqlplus属性和帮助

SQL> conn system/oracle
SQL> @?/sqlplus/admin/pupbld.sql
SQL> @?/sqlplus/admin/help/hlpbld.sql helpus.sql

至此,数据库创建完毕,谢谢大家。


如果这篇文章对您有帮助,不妨微信小额赞助我一下,让我有动力继续写出高质量的帖子。

本帖已经被管理员设置为: 精华帖 !
共收到 1 条回复 数据库 oracle 创建数据库
ruyi#12年前 0 个赞

刚才按照该文档建立了一个库,没什么大问题。但是参数文件里面需要注意路径。还有 sga 和 pga大小需要根据需要调整。

回复本帖 (需要登录)