一、安装oracle软件,
设置系统内核参数等
设置oracle环境变量
[oracle@localhost oradata]$ vi /home/oracle/.bash_profile
export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.1/db_1
export ORACLE_SID=ora10
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:$PATH:/usr/sbin:$HOME/bin
unset USERNAME
二、配置raw存储
AS4u5默认内核支持lvm2裸设备,模块需要动态加载
1.动态加载模块
编辑rc.local文件
[root@localhost ~]# vi /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
#mount lvm2 module
modprobe dm-mod
2.列出加载的模块
[root@localhost ~]# lsmod|grep dm_mod
dm_mod 65001 1 dm_mirror
3.fdisk分区
[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): help
h: unknown command
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
4.显示分区大小
[root@localhost ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 286 2096482+ 82 Linux swap
/dev/sda3 287 388 819315 83 Linux
/dev/sda4 389 2610 17848215 5 Extended
/dev/sda5 389 2610 17848183+ 83 Linux
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 83 Linux
[root@localhost ~]#
5、lvm使用
建立pv
[root@localhost ~]# pvcreate /dev/sdb1 -ff
/dev/cdrom: open failed: Read-only file system
Really INITIALIZE physical volume "/dev/sdb1" of volume group "oravg" [y/n]? y
WARNING: Forcing physical volume creation on /dev/sdb1 of volume group "oravg"
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvdisplay
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 10.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID OO5Na5-7nzB-O4ze-JaId-GQr2-GEMb-zqHK5b
6.建立vg oradata
[root@localhost ~]# vgcreate oradata /dev/sdb1
Volume group "oradata" successfully created
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name oradata
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 10.00 GB
PE Size 4.00 MB
Total PE 2559
Alloc PE / Size 0 / 0
Free PE / Size 2559 / 10.00 GB
VG UUID 1VkwE5-N1Kz-2dNj-X0s3-B1ex-AsXA-VGBSM7
[root@localhost ~]#
7.建立lv
[root@localhost /]# lvcreate -L 500M -n system01.dbf oradata
[root@localhost /]# lvcreate -L 500M -n sysaux01.dbf oradata
[root@localhost /]# lvcreate -L 500M -n undotbs01.dbf oradata
[root@localhost /]# lvcreate -L 500M -n redo01.dbf oradata
[root@localhost /]# lvcreate -L 500M -n redo02.dbf oradata
[root@localhost /]# lvcreate -L 500M -n control01.ctl oradata
[root@localhost /]# lvcreate -L 500M -n control02.ctl oradata
[root@localhost /]# lvcreate -L 500M -n temp01.dbf oradata
[root@localhost /]# lvcreate -L 500M -n spfileora10.ora oradata
[root@localhost /]# lvcreate -L 500M -n orapwdora10 oradata
[root@localhost /]# lvcreate -L 2048M -n users01.dbf oradata
知识点:
删除lv命令
lvremove /dev/oradata/system01.dbf
删除vg时要,先删除上面的lv
vgremove
8.将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.ctl
/dev/raw/raw7 /dev/oradata/control02.ctl
/dev/raw/raw8 /dev/oradata/temp01.dbf
/dev/raw/raw9 /dev/oradata/spfileora10.ora
/dev/raw/raw10 /dev/oradata/orapwdora10
/dev/raw/raw11 /dev/oradata/users01.dbf
9.使用raw设备绑定生效:
/sbin/service rawdevices restart
查看裸设备
[root@oraDBServer ~]# raw -qa
/dev/raw/raw1: bound to major 253, minor 0
/dev/raw/raw2: bound to major 253, minor 1
/dev/raw/raw3: bound to major 253, minor 2
/dev/raw/raw4: bound to major 253, minor 3
/dev/raw/raw5: bound to major 253, minor 4
/dev/raw/raw6: bound to major 253, minor 5
/dev/raw/raw7: bound to major 253, minor 6
/dev/raw/raw8: bound to major 253, minor 7
/dev/raw/raw9: bound to major 253, minor 8
/dev/raw/raw10: bound to major 253, minor 9
/dev/raw/raw11: bound to major 253, minor 10
[root@oraDBServer ~]#
7.修改raw文件属性:
# /sbin/service rawdevices restart
# chown oracle:dba /dev/raw/raw[1-9]
# chmod 0660 /dev/raw/raw[1-9]
ls -al /dev/raw/*
crw-rw---- 1 oracle dba 162, 1 Jul 22 08:25 /dev/raw/raw1
crw-rw---- 1 oracle dba 162, 10 Jul 22 08:25 /dev/raw/raw10
crw-rw---- 1 oracle dba 162, 11 Jul 22 08:25 /dev/raw/raw11
crw-rw---- 1 oracle dba 162, 2 Jul 22 08:25 /dev/raw/raw2
crw-rw---- 1 oracle dba 162, 3 Jul 22 08:25 /dev/raw/raw3
crw-rw---- 1 oracle dba 162, 4 Jul 22 08:25 /dev/raw/raw4
crw-rw---- 1 oracle dba 162, 5 Jul 22 08:25 /dev/raw/raw5
crw-rw---- 1 oracle dba 162, 6 Jul 22 08:31 /dev/raw/raw6
crw-rw---- 1 oracle dba 162, 7 Jul 22 08:25 /dev/raw/raw7
crw-rw---- 1 oracle dba 162, 8 Jul 22 08:25 /dev/raw/raw8
crw-rw---- 1 oracle dba 162, 9 Jul 22 08:25 /dev/raw/raw9
[root@localhost /]# vi /etc/udev/permissions.d/50-udev.permissions
# raw devices
ram*:root:disk:0660
raw/*:oracle:dba:0660 #113 line
查看相前raw的信息
[root@localhost /]# raw -qa
/dev/raw/raw1: bound to major 253, minor 0
/dev/raw/raw2: bound to major 253, minor 1
/dev/raw/raw3: bound to major 253, minor 2
/dev/raw/raw4: bound to major 253, minor 3
/dev/raw/raw5: bound to major 253, minor 4
/dev/raw/raw6: bound to major 253, minor 5
/dev/raw/raw7: bound to major 253, minor 6
/dev/raw/raw8: bound to major 253, minor 7
/dev/raw/raw9: bound to major 253, minor 8
/dev/raw/raw10: bound to major 253, minor 9
/dev/raw/raw11: bound to major 253, minor 11
10.使用oracle用户创建链接文件: (/oradata目录下在创建连接前内容为空)
[root@localhost /]#mkdir /oradata
[root@localhost /]# chown -R oracle.dba oradata/
[root@localhost /]# chmod 775 /oradata/
[root@localhost /]# ll
total 166
...............
drwxr-xr-x 5 oracle oinstall 4096 Jul 20 13:45 opt
drwxrwxr-x 2 oracle dba 4096 Jul 22 08:32 oradata
.........................
[root@localhost /]# su - oracle
[oracle@localhost ~]$ cd /oradata/
[oracle@localhost oradata]$ ln -s /dev/raw/raw1 /oradata/system01.dbf
[oracle@localhost oradata]$ ln -s /dev/raw/raw2 /oradata/sysaux01.dbf [oracle@localhost oradata]$ ln -s /dev/raw/raw3 /oradata/undotbs01.dbf
[oracle@localhost oradata]$ ln -s /dev/raw/raw4 /oradata/redo01.dbf
[oracle@localhost oradata]$ ln -s /dev/raw/raw5 /oradata/redo02.dbf
[oracle@localhost oradata]$ ln -s /dev/raw/raw6 /oradata/control01.ctl
[oracle@localhost oradata]$ ln -s /dev/raw/raw7 /oradata/control02.ctl
[oracle@localhost oradata]$ ln -s /dev/raw/raw8 /oradata/temp01.dbf
[oracle@localhost oradata]$ ln -s /dev/raw/raw9 /oradata/spfileora10.ora
[oracle@localhost oradata]$ ln -s /dev/raw/raw10 /oradata/orapwdora10
[oracle@localhost oradata]$ ln -s /dev/raw/raw11 /oradata/users01.dbf
[oracle@localhost oradata]$ ll
total 0
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:30 control01.ctl -> /dev/raw/raw6
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:30 control02.ctl -> /dev/raw/raw7
lrwxrwxrwx 1 oracle oinstall 14 Jul 22 08:31 orapwdora10 -> /dev/raw/raw10
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:30 redo01.dbf -> /dev/raw/raw4
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:30 redo02.dbf -> /dev/raw/raw5
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:30 spfileora10.ora -> /dev/raw/raw9
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:29 sysaux01.dbf -> /dev/raw/raw2
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:28 system01.dbf -> /dev/raw/raw1
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:30 temp01.dbf -> /dev/raw/raw8
lrwxrwxrwx 1 oracle oinstall 13 Jul 22 08:29 undotbs01.dbf -> /dev/raw/raw3
lrwxrwxrwx 1 oracle oinstall 14 Jul 22 08:31 users01.dbf -> /dev/raw/raw11
可以用touch control01.ctl测试权限是否设定正确
11.建立raw映射文件(运行DBCA向导使用裸设备,会选择这个配置文件)
/home/oracle/raw.conf
system=/oradata/system01.dbf
sysaux=/oradata/sysaux01.dbf
undotbs1=/oradata/undotbs01.dbf
redo1_1=/oradata/redo01.dbf
redo1_2=/oradata/redo02.dbf
control1=/oradata/control01.ctl
control2=/oradata/control02.ctl
temp=/oradata/temp01.dbf
users=/oradata/users01.dbf
spfile=/oradata/spfileora10.ora
orapwd=/oradata/orapwdora10
注释:
以下没有试验,仅供参考
创建archive log 目录,
lvcreate -L 2048m -n arch oradata
mkfs.ext3 /dev/oradata/arch
ln -s /dev/oradata/arch /arch
chown -R oracle.oinstall /arch
chmod -R 775 /arch
.将数据库改为归档模式:
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;