000
环境:OEL6.5+Oracle 11g R2
前提:数据库软件已安装完毕
001 建立参数文件
1.1 进入init.ora所在目录
cd $ORACLE_HOME/dbs
1.2 利用init.ora生成init.ora文件,即所谓的pfile。
cat init.ora | grep -v ^# | grep -v ^$ > initPROD.ora
1.3 修改pfile
需要修改的参数:
db_name、audit_file_dest、db_recovery_file_dest、diagnostic_dest、control_files
修改后的initPRDO.ora:
[
oracle@hhu dbs]$ vi initPROD.ora
db_name='PROD'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/PROD/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
db_recovery_file_dest_size=4G
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=PRODXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (/u01/app/oracle/oradata/PROD/control01.ctl,/u01/app/oracle/fast_recovery_area/control02.ctl)
compatible ='11.2.0'
1.4 建立参数文件中提及的目录
mkdir -p /u01/app/oracle/admin/PROD/adump
mkdir -p /u01/app/oracle/admin/PROD/adump
mkdir -p
/u01/app/oracle/fast_recovery_area
mkdir -p
/u01/app/oracle/oradata/PROD
002 建立密码文件
orapwd file=orapwPROD password=oracle
用于远程登录之用,不配置也不影响手工建库
开启到nomount状态。
003 执行建立数据库的脚本
3.1 编辑建立数据库的脚本
直接用vi编辑器建立一个为createdb.sql的脚本
[oracle@PROD1 ~]$ vi createdb.sql
建立数据库的脚本内容可以从官方文档中的administrator's guide一书中找到。需要修改的内容有:sys和system用户密码、日志文件路径和数目、数据库名、undo表空间名由undotbs改为undotbs1。修改后的脚本内容为:
[
oracle@hhu ~]$ cat createdb.sql
CREATE DATABASE PROD
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/PROD/redo01.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/PROD/redo02.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/PROD/redo03.log') SIZE 100M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/PROD/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/PROD/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/PROD/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/PROD/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
3.2 将数据库开启到nomount状态:
export ORACLE_SID=PROD
sqlplus / as sysdba
startup nomount
在sqlplus中执行该脚本:
SQL> @createdb.sql
004 运行几个后续脚本
Script | Description |
---|---|
CATALOG.SQL | Creates the views of the data dictionary tables, the dynamic performance views, and public synonyms for many of the views. Grants PUBLIC access to the synonyms. |
CATPROC.SQL | Runs all scripts required for or used with PL/SQL. |
PUPBLD.SQL | Required for SQL*Plus. Enables SQL*Plus to disable commands by user. |
The at-sign (@) is shorthand for the command that runs a SQL*Plus script. The question mark (?) is a SQL*Plus variable indicating the Oracle home directory. 意即:“@”是运行一个SQL*Plus脚本的命令的速写形式,“?”则是SQL*Plus变量的简写,代表着Oracle home directory。
CATALOG.SQL、CATPROC.SQL以sysdba角色运行,PUPBLD.SQL则以system用户运行。
可以将这三个脚本的运行整合为一个脚本BDDV一次运行,如下:
[
oracle@hhu ~]$ vi BDDV
sqlplus / as sysdba <<EOF
@?/rdbms/admin/catalog.sql;
@?/rdbms/admin/catproc.sql;
conn system/oracle
@?/sqlplus/admin/pupbld.sql;
quit
EOF
运行该脚本,先给其赋予可执行权限:
[
oracle@hhu ~]$ chmod 744 BDDV
[
oracle@hhu ~]$ ./BDDV
验证数据库状态:
SQL> select status from v$instance;
STATUS
------------
OPEN
@760
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29067253/viewspace-2056297/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29067253/viewspace-2056297/