参考:http://blog.csdn.net/huzia/article/details/7616717
创建环境变量,确定SID
$ vim rman.env export ORACLE_SID=rman export ORACLE_BASE=/opt/oracle export ORACLE_HOME=/opt/oracle/11g
加载环境变量
$ source rman.env
创建初始化文件
cp /opt/oracle/11g/dbs/init.ora /opt/oracle/11g/dbs/initrman.ora db_name='rman' memory_target=1G processes = 150 audit_file_dest='/opt/oracle/admin/rman/adump' audit_trail ='db' db_block_size=8192 db_domain='' db_recovery_file_dest='/opt/oracle/flash_recovery_area' db_recovery_file_dest_size=2G diagnostic_dest='/opt/oracle' dispatchers='(PROTOCOL=TCP) (SERVICE=RMANXDB)' open_cursors=300 remote_login_passwordfile='EXCLUSIVE' undo_tablespace='UNDOTBS1' # You may want to ensure that control files are created on separate physical # devices control_files = ('/opt/oracle/oradata/rman/control01.ctl', '/opt/oracle/flash_recovery_area/rman/control02.ctl') compatible ='11.2.0' 也可根据现有数据的spfile生成初始化文件 #strings /opt/oracle/11g/dbs/spfilezgw.ora > /opt/oracle/11g/dbs/initrman.ora
创建目录
mkdir -p /opt/oracle/admin/rman/adump mkdir -p /opt/oracle/oradata/rman mkdir -p /opt/oracle/flash_recovery_area/rman
登录sqlplus
sqlplus / as sysdba
创建DBSQL语句 CREATE DATABASE rman CONTROLFILE REUSE LOGFILE '/opt/oracle/oradata/rman/redo01.log' SIZE 10M REUSE, '/opt/oracle/oradata/rman/redo02.log' SIZE 10M REUSE, '/opt/oracle/oradata/rman/redo03.log' SIZE 10M REUSE, '/opt/oracle/oradata/rman/redo04.log' SIZE 10M REUSE, DATAFILE '/opt/oracle/oradata/rman/system01.dbf' SIZE 50M REUSE AUTOEXTEND ON NEXT 10M MAXSIZE 200M UNDO TABLESPACE UNDOTBS1 DATAFILE '/opt/oracle/oradata/rman/undo01.dbf' size 10m SYSAUX datafile '/opt/oracle/oradata/rman/sysaux.dbf' size 10M autoextend on next 50m maxsize 100m CHARACTER SET WE8ISO8859P1;
上面这段话的作用如下:
① 创建数据库的数据文件;
② 创建数据库的控制文件;
③ 创建数据库的重做日志文件;
④ 创建SYSTEM 表空间及回滚段;
⑤ 创建数据目录;
⑥ 创建用户SYS和SYSTEM;
⑦ 指定数据库中存储数据的字符集;
⑧ 装入、打开数据库
创建系统回滚段,创建一个临时的回滚段来支持数据库的创建,后来在删除掉。
CREATE ROLLBACK SEGMENT rb_temp STORAGE(INITIAL 100k NEXT 250k); ALTER ROLLBACK SEGMENT rb1 ONLINE; 为回滚段创建表空间 CREATE TABLESPACE rbs DATAFILE '/opt/oracle/oradata/rman/rbs01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 5M MAXSIZE 150M; 创建用户表空间 CREATE TABLESPACE users DATAFILE '/opt/oracle/oradata/rman/user01.dbf' SIZE 3M REUSE AUTOEXTEND ON NEXT 5M MAXSIZE 150M; 创建临时表空间 CREATE TABLESPACE temp DATAFILE '/opt/oracle/oradata/rman/temp01.dbf' SIZE 2M REUSE AUTOEXTEND ON NEXT 5M MAXSIZE 150M; 创建回滚段 CREATE ROLLBACK SEGMENT rb1 STORAGE (INITIAL 50k NEXT 250k) TABLESPACE rbs; CREATE ROLLBACK SEGMENT rb2 STORAGE (INITIAL 50k NEXT 250k) TABLESPACE rbs; CREATE ROLLBACK SEGMENT rb3 STORAGE (INITIAL 50k NEXT 250k) TABLESPACE rbs; CREATE ROLLBACK SEGMENT rb4 STORAGE (INITIAL 50k NEXT 250k) TABLESPACE rbs; 把刚创建的回滚段上线 ALTER ROLLBACK SEGMENT rb1 ONLINE; ALTER ROLLBACK SEGMENT rb2 ONLINE; ALTER ROLLBACK SEGMENT rb3 ONLINE; ALTER ROLLBACK SEGMENT rb4 ONLINE; ALTER ROLLBACK SEGMENT rb_temp OFFLINE; DROP ROLLBACK SEGMENT rb_temp;
在数据库OPEN状态下,执行数据字典创建和PLSQL支持
SQL>@/opt/oracle/11g/rdbms/admin/catalog.sql SQL>@/opt/oracle/11g/rdbms/admin/catproc.sql SQL>@/opt/oracle/11g/sqlplus/admin/pupbld.sql