Linux 下裸设备创建Oracle数据库

1.增加一块硬盘,以root登陆OS
[root@rac1 oracle]# fdisk -l
Disk /dev/sda: 255 heads, 63 sectors, 652 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 38 200812 82 Linux swap
/dev/sda3 39 652 4931955 83 Linux
Disk /dev/sdh: 128 heads, 32 sectors, 512 cylinders
Units = cylinders of 4096 * 512 bytes
Disk /dev/sdh doesn't contain a valid partition table
2.对Disk /dev/sdh分区成LVM格式(8e的分区类型)
Disk /dev/sdh: 128 heads, 32 sectors, 512 cylinders
Units = cylinders of 4096 * 512 bytes
Device Boot Start End Blocks Id System
/dev/sdh1 1 512 1048560 8e Linux LVM
3.创建物理卷,逻辑卷(组)
执行如下shell:
pvcreate /dev/sdh1
vgcreate oravg /dev/sdh1
lvcreate -L8M -nlv_spfile oravg
lvcreate -L20M -nlv_control1 oravg
lvcreate -L20M -nlv_control2 oravg
lvcreate -L20M -nlv_control3 oravg
lvcreate -L20M -nlv_redo1_1 oravg
lvcreate -L20M -nlv_redo1_2 oravg
lvcreate -L20M -nlv_redo1_3 oravg
lvcreate -L500M -nlv_system oravg
lvcreate -L20M -nlv_temp oravg
lvcreate -L20M -nlv_users oravg
lvcreate -L20M -nlv_undo oravg
lvcreate -L20M -nlv_users oravg
lvcreate -L20M -nlv_tools oravg
lvcreate -L20M -nlv_indx oravg
vgchange -a y
[root@rac1 oracle]# lvscan
lvscan -- ACTIVE "/dev/oravg/lv_spfile" [8 MB]
lvscan -- ACTIVE "/dev/oravg/lv_control1" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_control2" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_control3" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_redo1_1" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_redo1_2" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_redo1_3" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_system" [500 MB]
lvscan -- ACTIVE "/dev/oravg/lv_temp" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_users" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_undo" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_tools" [20 MB]
lvscan -- ACTIVE "/dev/oravg/lv_indx" [20 MB]
lvscan -- 14 logical volumes with 4.62 GB total in 2 volume groups
lvscan -- 14 active logical volumes
补充下vi命令:替换字符串
:%s#/usr/bin#/bin#g
:set (no)nu (不)显示行号
4.绑定到裸设备上
执行如下shell
raw /dev/raw/raw1 /dev/oravg/lv_spfile
raw /dev/raw/raw2 /dev/oravg/lv_control1
raw /dev/raw/raw3 /dev/oravg/lv_control2
raw /dev/raw/raw4 /dev/oravg/lv_control3
raw /dev/raw/raw5 /dev/oravg/lv_redo1_1
raw /dev/raw/raw6 /dev/oravg/lv_redo1_2
raw /dev/raw/raw7 /dev/oravg/lv_redo1_3
raw /dev/raw/raw8 /dev/oravg/lv_system
raw /dev/raw/raw9 /dev/oravg/lv_temp
raw /dev/raw/raw10 /dev/oravg/lv_users
raw /dev/raw/raw11 /dev/oravg/lv_undo
raw /dev/raw/raw12 /dev/oravg/lv_tools
raw /dev/raw/raw13 /dev/oravg/lv_indx
raw –qa
5.修改/etc/sysconfig/rawdevices文件如下,以开机时自动加载裸设备
# raw device bindings
# format:
#
# example: /dev/raw/raw1 /dev/sda1
# /dev/raw/raw2 8 5
/dev/raw/raw1 /dev/oravg/lv_spfile
/dev/raw/raw2 /dev/oravg/lv_control1
/dev/raw/raw3 /dev/oravg/lv_control2
/dev/raw/raw4 /dev/oravg/lv_control3
/dev/raw/raw5 /dev/oravg/lv_redo1_1
/dev/raw/raw6 /dev/oravg/lv_redo1_2
/dev/raw/raw7 /dev/oravg/lv_redo1_3
/dev/raw/raw8 /dev/oravg/lv_system
/dev/raw/raw9 /dev/oravg/lv_temp
/dev/raw/raw10 /dev/oravg/lv_users
/dev/raw/raw11 /dev/oravg/lv_undo
/dev/raw/raw12 /dev/oravg/lv_tools
/dev/raw/raw13 /dev/oravg/lv_indx
6.将卷组及设备属主
chown oracle:oinstall /dev/oravg
chmod xwr /dev/raw/*
chmod xrw /dev/raw/
7.创建裸设备映射文件DBCA_RAW_CONFIG.txt并加入环境变量如下:
spfile=/dev/raw/raw1
control1=/dev/raw/raw2
control2=/dev/raw/raw3
control3=/dev/raw/raw4
redo1_1=/dev/raw/raw5
redo1_2=/dev/raw/raw6
redo1_3=/dev/raw/raw7
system=/dev/raw/raw8
temp=/dev/raw/raw9
users=/dev/raw/raw10
undotbs1=/dev/raw/raw11
tools=/dev/raw/raw12
indx=/dev/raw/raw13
export DBCA_RAW_CONFIG=/home/oracle/DBCA_RAW_CONFIG.txt
export LANG=zh_CN
8.运行DBCA创建数据库(注意选择裸设备创建数据库及数据文件略小于裸设备定义大小)
9.将vgchange -a y加到/etc/rc.local中,启动是自动激活所有卷组
文档上说7.0以后自动激活,可我的8.0就是不激活 ?,不知道为什么
10.扩大数据文件大小
a)扩大逻辑卷
lvextend -L100M /dev/oravg/lv_undo
b)扩大数据文件
SQL> alter database datafile '/dev/raw/raw11' resize 90m;

 

你可能感兴趣的:(oracle,sql,linux,OS)