日期:2014-05-16 浏览次数:20564 次
linux lvm 创建lv 并映射成裸设备---建立oracle 10g数据库
1.fdisk /dev/sdb
n ---创建一个分区
p
fdisk /dev/sdb
t
8e ---将分区置为lvm方式对/dev/sdb1进行管理
2.创建一个pv
pvcreate /dev/sdb1
3.创建一个vg
vgcreate oradata /dev/sdb1
4.创建db所需的lv
lvcreate -L 500M -n system01.dbf oradata
lvcreate -L 900M -n sysaux01.dbf oradata
.....
lvcreate -L 12M -n spfile.ora oradata
5.将lv关联成raw
vi /etc/sysconfig/rawdevices 加入以下内容:
/dev/raw/raw1 /dev/oradata/system01.dbf
/dev/raw/raw2 /dev/oradata/sysaux01.dbf
/dev/raw/raw3 /dev/oradata/undotbs01.dbf
/dev/raw/raw4 /dev/oradata/redo01.dbf
/dev/raw/raw5 /dev/oradata/redo02.dbf
/dev/raw/raw6 /dev/oradata/control01.dbf
/dev/raw/raw7 /dev/oradata/control02.dbf
/dev/raw/raw8 /dev/oradata/temp01.dbf
/dev/raw/raw9 /dev/oradata/spfile.ora
6.使用raw设备生效:
/sbin/service rawdevices restart
7.修改raw文件属性:
# /sbin/service rawdevices restart
# chown oracle:dba /dev/raw/raw[1-9]
# chmod 660 /dev/raw/raw[1-9]
/etc/udev/permissions.d/50-udev.permissions 中为原始行“raw/*:root:disk:0660”添加注释,
#raw/*:root:disk:0660
查看相前raw的信息
raw -qa
8.创建链接文件:
ln -s /dev/raw/raw1 /app/oracle/testdb/system01.dbf
ln -s /dev/raw/raw2 /app/oracle/testdb/sysaux01.dbf
ln -s /dev/raw/raw3 /app/oracle/testdb/undotbs01.dbf
ln -s /dev/raw/raw4 /app/oracle/testdb/redo01.dbf
ln -s /dev/raw/raw5 /app/oracle/testdb/redo02.dbf
ln -s /dev/raw/raw6 /app/oracle/testdb/control01.dbf
ln -s /dev/raw/raw7 /app/oracle/testdb/control02.dbf
ln -s /dev/raw/raw8 /app/oracle/testdb/temp01.dbf
ln -s /dev/raw/raw9 /app/oracle/testdb/spfile.ora
ln -s /dev/raw/raw10 /app/oracle/testdb/orapwdtestdb
9.建立raw映射文件
/home/oracle/raw.txt
system=/app/oracle/testdb/system01.dbf
sysaux=/app/oracle/testdb/sysaux01.dbf
undotbs01=/app/oracle/testdb/undotbs01.dbf
redo01=/app/oracle/testdb/redo01.dbf
redo02=/app/oracle/testdb/redo02.dbf
control01=/app/oracle/testdb/control01.dbf
control02=/app/oracle/testdb/control02.dbf
temp=/app/oracle/testdb/temp01.dbf
spfile=/app/oracle/testdb/spfile.ora
ora/app/oracle/testdb/orapwdtestdb
10.dbca 选择raw来创建DB,使用映射文件:/home/oracle/raw.txt 在表空间和数据文件确定文件的大小,接下来就和一般建库一样了
11.创建archive log 目录,
lvcreate -L 500m -n arch oradata
mkfx.ext3 /dev/oradata/arch
chown -R oracle:install /arch
chmod -R 755 /arch
12.将数据库改为归档模式:
create pfile from spfile
alter system set log_archivelog_dest_1='LOCATION=/arch' scope=both;
shutdown immediate;
startup nomount
alter database archivelog;
alter database open;
alter system switch logfile;