ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 手动创建oracle数据库

手动创建oracle数据库

原创 Linux操作系统 作者:Candy_pro 时间:2012-03-26 15:09:38 0 删除 编辑
通过挂载磁盘,活动软件安装包
[root@Candy-2 ~]# service nfs start
Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS daemon: [  OK  ]
Starting NFS mountd: [  OK  ]
[root@Candy-2 ~]# showmount -e 192.168.0.181
Export list for 192.168.0.181:
/soft 192.168.0.182
[root@Candy-2 oracle]# mount 192.168.0.181:/soft /soft


安装数据库软件
[root@Candy-2 oracle]# cd /soft/ora11g/
[root@Candy-2 ora11g]# ls
doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[root@Candy-2 ora11g]# xhost +
[root@Candy-2 ora11g]# su oracle
[oracle@Candy-2 ~]$ export DISPLAY=:0.0
[oracle@Candy-2 ~]$ ./runInstaller

修改环境变量
[oracle@Candy-2 ~]$ vi .bash_profile
PATH=$PATH:$HOME/bin

export ORACLE_BASE=/home/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH=${PATH}:$ORACLE_BASE/common/oracle/bin:$HOME/scripts
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS10=$ORACLE_HOME/nls/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$ORA_CRS_HOME/lib:$ORA_CRS_HOME/lib3
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/JRE
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp
export DISPLAY=:0.0
export ORACLE_SID=ora2
PATH=.:$JAVA_HOME/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin

创建初始化参数文件,并根据自身需求做出相应修改
[oracle@Candy-2 dbs]$ vi initora2.ora
ora2.__db_cache_size=121634816
ora2.__java_pool_size=4194304
ora2.__large_pool_size=4194304
ora2.__oracle_base='/home/oracle/app/oracle'#ORACLE_BASE set from environment
ora2.__pga_aggregate_target=146800640
ora2.__sga_target=276824064
ora2.__shared_io_pool_size=0
ora2.__shared_pool_size=134217728
ora2.__streams_pool_size=4194304
*.audit_file_dest='/home/oracle/app/oracle/admin/ora2/adump'
#*.audit_trail=db,extended  ----#这里注意,如果将来会转换成物理备库,这里就不能设置为db,否则将来物理备库没法打开read only模式
*.compatible='11.2.0.0.0'
*.control_files='/home/oracle/app/oracle/oradata/ora2/control01.ctl','/home/oracle/app/oracle/oradata/ora2/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ora2'
*.diagnostic_dest='/home/oracle/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ora1XDB)'
*.memory_target=422576128
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

创建密码文件
[oracle@Candy-2 dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwd$ORACLE_SID password=oracle entries=5 force=y
[oracle@Candy-2 dbs]$ ls
init.ora  initora2.ora  orapwdora2

建立需要的目录  注意:需要与初始化参数文件中路径一致
mkdir -p /home/oracle/app/oracle/admin/ora2/adump
mkdir -p /home/oracle/app/oracle/admin/ora2/bdump
mkdir -p /home/oracle/app/oracle/admin/ora2/cdump
mkdir -p /home/oracle/app/oracle/admin/ora2/udump

cd $ORACLE_BASE
mkdir -p oradata/ora2

创建pfile后启动实例并开始建库
[oracle@Candy-2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Mar 25 23:48:46 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile=$ORACLE_HOME/dbs/init$ORACLE_SID.ora      
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             293603712 bytes
Database Buffers          121634816 bytes
Redo Buffers                6094848 bytes
SQL> shutdown     

SQL> create database ora2
user sys identified by oracle
user system identified by oracle
logfile
group 1 ('/home/oracle/app/oracle/oradata/ora2/redo01.log') size 20m,
group 2 ('/home/oracle/app/oracle/oradata/ora2/redo02.log') size 20m,
group 3 ('/home/oracle/app/oracle/oradata/ora2/redo03.log') size 20m
maxlogfiles 5
maxlogmembers 5
maxloghistory 1
maxdatafiles 100
character set zhs16gbk
datafile '/home/oracle/app/oracle/oradata/ora2/system01.dbf' size 700m
sysaux datafile '/home/oracle/app/oracle/oradata/ora2/sysaux01.dbf' size 510m
undo tablespace UNDOTBS1 datafile '/home/oracle/app/oracle/oradata/ora2/UNDOTBS1.dbf' size 100m
default temporary tablespace temp tempfile '/home/oracle/app/oracle/oradata/ora2/temp01.dbf' size 50m

*注意:在创建数据库的过程中可以查看alert.log查看是否出现错误

运行数据字典脚本,其中catalog和catproc是必须的,其他可选
@$ORACLE_HOME/rdbms/admin/catalog.sql   --建数据字典视图
@$ORACLE_HOME/rdbms/admin/catproc.sql        --建存储过程报

@$ORACLE_HOME/rdbms/admin/catblock.sql    --建锁相关的几个视图
@$ORACLE_HOME/rdbms/admin/catoctk.sql        --建密码工具包dbms_crypto_toolkit
@$ORACLE_HOME/rdbms/admin/owminst.plb        --建工作空间管理相关对象,如 dbms_wm
 
创建sqlplus属性和帮助、users表空间
conn / as sysdba
@$ORACLE_HOME/sqlplus/admin/pupbld.sql

开启归档模式
startup mount
alter database archivelog;
alter database open;

重新编译所有失效对象
execute utl_recomp.reconp_serial();

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26825102/viewspace-719545/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2012-03-26

  • 博文量
    3
  • 访问量
    2533