在之前曾经使用DBCA方式建立数据库,然而使用DBCA在使用裸设备时老是通不过,于是想通过手动建库的方式实现将数据库建立在裸设备上.通过手动建库了解ORACLE数据库的构造.
这里假设已经能独立在linux操作系统下安装ORACLE软件,因此不再详述软件的安装步骤.可以参考:
ORACLE 10G for RHEL AS 4 安装(http://blog.chinaunix.net/u/28641/showart_1087570.html)
, 在引用的文章中,注意这里
只安装软件,不建立数据库.
完成oracle软件安装后,开始手动基于裸设备的数据库.
相关环境:
ORACLE_BASE:/opt/oracle
ORACLE_HOME:/opt/oracle/product/10.2.0/ora10g
ORACLE_SID:ora10g
1.建立相关目录
--诊断目录
[oracle@rhel47 ~]$ mkdir -p $ORACLE_BASE/admin/ora10g/adump
[oracle@rhel47 ~]$ mkdir -p $ORACLE_BASE/admin/ora10g/bdump
[oracle@rhel47 ~]$ mkdir -p $ORACLE_BASE/admin/ora10g/cdump
[oracle@rhel47 ~]$ mkdir -p $ORACLE_BASE/admin/ora10g/udump
[oracle@rhel47 ~]$ mkdir -p $ORACLE_BASE/admin/ora10g/pfile
--数据文件存放目录
[oracle@rhel47 ~]$ mkdir -p $ORACLE_BASE/oradata/ora10g
2.创建数据文件裸设备
--创建逻辑卷.
[root@rhel47 ~]# lvcreate -L 608M -n lvsystem vg00
[root@rhel47 ~]# lvcreate -L 408M -n lvsysaux vg00
[root@rhel47 ~]# lvcreate -L 108M -n lvtemp vg00
[root@rhel47 ~]# lvcreate -L 108M -n lvundotbs vg00
[root@rhel47 ~]# lvcreate -L 60M -n lvredoa1 vg00
[root@rhel47 ~]# lvcreate -L 60M -n lvredoa2 vg00
[root@rhel47 ~]# lvcreate -L 60M -n lvredoa3 vg00
[root@rhel47 ~]# lvcreate -L 10M -n lvcontrol01 vg00
[root@rhel47 ~]# lvcreate -L 10M -n lvcontrol02 vg00
[root@rhel47 ~]# lvcreate -L 10M -n lvcontrol03 vg00
--裸设备化,若要重启系统后仍生效,需把以下命令加入到/etc/rc.local文件中.
[root@rhel47 vg00]# raw /dev/raw/raw1 /dev/mapper/vg00-lvsystem
[root@rhel47 vg00]# raw /dev/raw/raw2 /dev/mapper/vg00-lvsysaux
[root@rhel47 vg00]# raw /dev/raw/raw3 /dev/mapper/vg00-lvtemp
[root@rhel47 vg00]# raw /dev/raw/raw4 /dev/mapper/vg00-lvundotbs
[root@rhel47 vg00]# raw /dev/raw/raw5 /dev/mapper/vg00-lvredoa1
[root@rhel47 vg00]# raw /dev/raw/raw6 /dev/mapper/vg00-lvredoa2
[root@rhel47 vg00]# raw /dev/raw/raw7 /dev/mapper/vg00-lvredoa3
[root@rhel47 vg00]# raw /dev/raw/raw8 /dev/mapper/vg00-lvcontrol01
[root@rhel47 vg00]# raw /dev/raw/raw9 /dev/mapper/vg00-lvcontrol02
[root@rhel47 vg00]# raw /dev/raw/raw10 /dev/mapper/vg00-lvcontrol03
--更改裸设备的属主:属组,若要重启后仍生效,将以下命令加入到/etc/rc.local文件中.
[root@rhel47 raw]# chown oracle:dba /dev/raw/raw*
--在数据文件目录建立链接到裸设备上.
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw1 rlvsystem
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw2 rlvsysaux
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw3 rlvtemp
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw4 rlvundotbs
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw5 rlvredoa1
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw6 rlvredoa2
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw7 rlvredoa3
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw8 rlvcontrol01
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw9 rlvcontrol02
[oracle@rhel47 ora10g]$ ln -s /dev/raw/raw10 rlvcontrol03
3.创建ORACLE的参数文件$ORACLE_HOME/dbs/initora10g.ora
拷贝$ORACLE_HOME/dbs/init.ora为$ORACLE_HOME/dbs/initora10g.ora (即ora${ORACLE_SID}.ora).由于自带的init.ora的版本较低,建议使用其它在用的init.ora文件,如使用dbca建立数据库生成的init${ORACLE_SID}.ora文件做为模版.
修改如下参数.
db_name = ora10g
shared_pool_size = 100000000
control_files=(/opt/oracle/oradata/ora10g/rlvcontrol01, /opt/oracle/oradata/ora10g/rlvcontrol02, /opt/oracle/oradata/ora10g/rlvcontrol03)
undo_management = AUTO
undo_tablespace = UNDOTBS
4.创建密码文件
[oracle@rhel47 ~]$ orapwd file=$ORACLE_HOME/dbs/orapwora10g password=root123 entries=5 force=y
5.创建数据库脚本文件ora10g.sql
--注意reuse参数的使用,关闭自动扩展.
[oracle@rhel47 ~]$ cat >> ora10g.sql << EOF
CREATE DATABASE ora10g
CONTROLFILE REUSE
LOGFILE
GROUP 1 ('/opt/oracle/oradata/ora10g/rlvredoa1') SIZE 50M,
GROUP 2 ('/opt/oracle/oradata/ora10g/rlvredoa2') SIZE 50M,
GROUP 3 ('/opt/oracle/oradata/ora10g/rlvredoa3') SIZE 50M REUSE
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
NOARCHIVELOG
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/opt/oracle/oradata/ora10g/rlvsystem' SIZE 600M REUSE AUTOEXTEND OFF
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/opt/oracle/oradata/ora10g/rlvsysaux' SIZE 400M REUSE AUTOEXTEND OFF
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/opt/oracle/oradata/ora10g/rlvtemp' SIZE 100M REUSE AUTOEXTEND OFF
UNDO TABLESPACE "UNDOTBS"
DATAFILE '/opt/oracle/oradata/ora10g/rlvundotbs' SIZE 100M REUSE AUTOEXTEND OFF ;
EOF
6.执行建库
oracle@rhel47 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Feb 7 13:01:13 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect sys/root123 as sysdba
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 134217728 bytes
Fixed Size 1218100 bytes
Variable Size 125831628 bytes
Database Buffers 4194304 bytes
Redo Buffers 2973696 bytes
SQL> start ora10g.sql
Database created.
7.创建数据字典,PACKAGE包.
--仍在SYS用户下,两个语句都要花费较长的时间,需耐心等待.....................
SQL> start /opt/oracle/product/10.2.0/ora10g/rdbms/admin/catalog.sql
SQL> start /opt/oracle/product/10.2.0/ora10g/rdbms/admin/catproc.sql
做完这里,手动安装就基本上完成了.以下手动配置监听与DBCONSOLE
8.配置监听
拷贝${ORACLE_HOME}/network/admin/samples/tnsname.ora 到${ORACLE_HOME}/network/admin/下,增加/修改相关信息.
ORA10G =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.80.47)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ora10g)
(SERVER = DEDICATED)
)
)
拷贝${ORACLE_HOME}/network/admin/samples/sqlnet.ora 到${ORACLE_HOME}/network/admin/下,增加/修改相关信息.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES)
然后,通过命令启动监听.
[oracle@rhel47 ~]$ lsnrctl start
确认正常启动.
9.配置DBCONSOLE
配置DBCONSOLE需要用到emca这个工具..
建立库,这里需要的相关信息包括ORACLE_SID,监听端口号,SYS及SYSMAN用户密码等.
[oracle@rhel47 ~]$ emca -repos create
配置库,这里需要的相关信息包括ORACLE_SID,监听端口号,SYS,DBSNMP及SYSMAN用户密码等.
[oracle@rhel47 ~]$ emca -config dbcontrol db
这里也需要一点时间..完成后,dbconsole自动启动..使用以下命令检查.
[oracle@rhel47 ~]$ emctl status dbconsole
然后通过 方式(OEM)访问控制..
(OVER)