官方文档参考:
本节实验主要是适应于单实例安装。(单实例并不是指服务器上只能安装一个实例,而是可以多个实例(和它们的数据库)运行在服务器上,但是只有一个数据库访问只允许访问一个实例。)
接上节实验环境,继续操作:
本节实验主要实施步骤,数据库名称以ocp1为例:
1.指定实例标识(SID)
[root@ocp ~]# su - oracle
[oracle@ocp ~]$ export ORACLE_SID=ocp1
[oracle@ocp ~]$ echo $ORACLE_SID
ocp1
2.创建新实例的相应目录
在$ORACLE_BASE/admin下创建$ORACLE_SID目录,并在此目录下创建相应子目录/adump(存储审计文件的目录),/bdump(后台进程跟踪文件),/cdump(存储核心堆积文件),/udump(存储用户进程跟踪文件)
[oracle@ocp ~]$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/{a,b,c,u}dump
[oracle@ocp ~]$ ls $ORACLE_BASE/admin
ocp ocp1
[oracle@ocp ~]$ ls $ORACLE_BASE/admin/$ORACLE_SID
adump bdump cdump udump
创建新实例的数据库目录
[oracle@ocp ~]$ mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID
[oracle@ocp ~]$ ls $ORACLE_BASE/oradata
ocp ocp1
3.创建初始化参数文件
官方初始化参数文件示例:
[oracle@ocp ~]$ cd $ORACLE_HOME/dbs
[oracle@ocp dbs]$ cat init.ora | grep -v ^$ | grep -v ^# >init$ORACLE_SID.ora
[oracle@ocp dbs]$ ls *.ora
initocp1.ora init.ora spfileocp.ora
[oracle@ocp dbs]$ vim initocp1.ora
(1)删除 xxxxpool_size xxxxbuffer之类的
(2)修改 db_name为$ORACLE_SID的值:如 db_name=ocp1
(3)增加以下内容
sga_max_size=300m
sga_target=300m
undo_tablespace=undotbs
undo_management=auto
#其中 undo_tablespace这行参数需修改
(4)修改控制文件参数,如下:
control_files = ('/u01/app/oracle/oradata/ocp1/control01.ctl',
'/u01/app/oracle/oradata/ocp1/control02.ctl'
'/u01/app/oracle/oradata/ocp1/control03.ctl')
(5)修改其它参数
audit_file_dest='/admin/orcl/adump'
修改为 audit_file_dest='/u01/app/oracle/admin/ocp1/adump'
db_recovery_file_dest='/flash_recovery_area'
修改为 db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
diagnostic_dest=''
修改为 diagnostic_dest='/u01/app/oracle'
4.创建密码文件 (oracle数据库密码有两种管理方式,一种是密码文件,一种是系统用户,具体信息查看官方文档)
[oracle@ocp dbs]$ orapwd file=orapw$ORACLE_SID password=oracle #其中的oracle是密码
5.启动实例(NOMOUNT状态)
[oracle@ocp dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 15 09:41:51 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 313159680 bytes
Fixed Size 2212936 bytes
Variable Size 104860600 bytes
Database Buffers 201326592 bytes
Redo Buffers 4759552 bytes
6.运行建库脚本
官方建库脚本示例mynewdb
CREATE DATABASE mynewdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.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/mynewdb/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/mynewdb/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/mynewdb/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/mynewdb/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/u01/app/oracle/oradata/mynewdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
正式操作,修改一下示例脚本并保存为/tmp/ocp1.sql
SQL> hos vim /tmp/ocp1.sql
:%s/mynewdb/ocp1/gc
a
LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log') SIZE 100M BLOCKSIZE 512
修改成
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/ocp1/redo01.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/ocp1/redo02.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/ocp1/redo03.log') SIZE 100M BLOCKSIZE 512
修改 sys_password 为 manager #修改成你自己的密码
修改 system_password 为 manager #修改成你自己的密码
wq
SQL> @/tmp/ocp1.sql
Database created.
7.创建额外表空间(可选)
官方文档中的示例脚本
CREATE TABLESPACE apps_tbs LOGGING
DATAFILE '/u01/app/oracle/oradata/mynewdb/apps01.dbf'
SIZE 500M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
-- create a tablespace for indexes, separate from user tablespace (optional)
CREATE TABLESPACE indx_tbs LOGGING
DATAFILE '/u01/app/oracle/oradata/mynewdb/indx01.dbf'
SIZE 100M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL;
SQL> host vim /tmp/addp.sql
把示例脚本复制过来,修改其中实例数据名即可
%s/mynewdb/ocp1/gc
a
wq
SQL> @/tmp/addp.sql
Tablespace created.
Tablespace created.
8.运行创建数据字典脚本
运行创建数据字典视图
SQL> @?/rdbms/admin/catalog.sql
运行PL/SQL的软件包和过程
SQL> @?/rdbms/admin/catproc.sql
阅读(766) | 评论(0) | 转发(0) |