Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6664362
  • 博文数量: 1005
  • 博客积分: 8199
  • 博客等级: 中将
  • 技术积分: 13071
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-25 20:19
个人简介

脚踏实地、勇往直前!

文章分类

全部博文(1005)

文章存档

2020年(2)

2019年(93)

2018年(208)

2017年(81)

2016年(49)

2015年(50)

2014年(170)

2013年(52)

2012年(177)

2011年(93)

2010年(30)

分类: Oracle

2012-06-30 22:44:35

环境:
OS:Red Hat Linux As 5
DB:10.2.0.4
 
10G以后Oracle推出了使用ASM(Auto Storage Management)管理的存储方式,随着Oralce版本的不断变更,ASM存储管理方式也越来越稳定.下面介绍如何使用ASM的管理方式创建单实例数据库.
 
----------------------------------创建ASM磁盘部分---------------------------------
1.安装Asmlib
安装AsmlibB那个版本需要根据OS的内核版本来确定,这里我的操作系统内核版本如下:
[root@hxl asm]# uname -a
Linux hxl 2.6.18-8.el5xen #1 SMP Fri Jan 26 14:42:21 EST 2007 i686 i686 i386
GNU/Linux
选择安装的Asmlib包如下,在root用户下按照如下顺序执行,否则会报需要依赖的提示.
[root@hxl asm]#rpm -ivh oracleasm-support-2.1.7-1.el5.i386.rpm
[root@hxl asm]#rpm -ivh oracleasm-2.6.18-8.el5xen-2.0.4-1.el5.i686.rpm
[root@hxl asm]#rpm -ivh oracleasmlib-2.0.4-1.el5.i386.rpm
以上这些安装包可以到Oracle官网下载.
地址:

找到如下连接ASMLib: Linux Drivers for Automatic Storage Management
进去后找到 Red Hat Enterprise Linux 5 AS 即可下载了. 
 
安装过程遇到的问题:
1.安装这些包需要在root用户下执行,否则报如下错误
[oracle@hxl oracelasmlib]$ rpm -ivh oracleasm-support-2.1.7-1.el5.i386.rpm
warning: oracleasm-support-2.1.7-1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
error: can't create transaction lock on /var/lib/rpm/__db.000
 
2.从oracle官方下载oraclelib默认保存的文件名问题导致不能安装.
[root@hxl oracelasmlib]# rpm -ivh oracleasmlib-2[1].0.4-1.el5.i386.rpm
error: File not found by glob: oracleasmlib-2[1].0.4-1.el5.i386.rpm
[root@hxl oracelasmlib]# mv "oracleasmlib-2[1].0.4-1.el5.i386.rpm" oracleasmlib-2.0.4-1.el5.i386.rpm
 
自动保存的时候多了符号[1],需要将这个符号去掉.
 
 
 
2.添加裸设备
编辑/etc/udev/rules.d/60-raw.rules文件添加如下内容
ACTION=="add", KERNEL=="sdb1",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc1",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1",RUN+="/bin/raw /dev/raw/raw3 %N"
设置裸设备权限给oracle用户,需要添加如下内容
KERNEL=="raw[1-3]*", NAME="raw/%k" OWNER="oracle" GROUP="oinstall", MODE="0660"
 
这里的sdb1 sdc1 sdd1 是新加入的磁盘分区,添加硬盘后可以使用fdisk创建分区(具体步骤省略),这里不需要格式化.
 
将如上内容添加到/etc/udev/rules.d/60-raw.rules后,执行如下命令使其生效.
[root@hxl asm]#start_udev
 
查看映射
[root@hxl]# raw -qa
/dev/raw/raw1:  bound to major 8, minor 17
/dev/raw/raw2:  bound to major 8, minor 33
/dev/raw/raw3:  bound to major 8, minor 49
这个时候裸设备添加完成, 下面继续Asmlib的配置.
 
3.设置ASMlib驱动
[root@hxl oracle]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting without typing an
answer will keep that current value.  Ctrl-C will abort.
Default user to own the driver interface [oracle]:
Default group to own the driver interface [oinstall]:
Start Oracle ASM library driver on boot (y/n) [y]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [  OK  ]
Scanning the system for Oracle ASMLib disks:               [  OK  ]
 
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [FAILED]
在初始化ASMLIB的过程中有可能失败,原因之一是没有关闭SELINUX,需要将SELINUX设置成disabled,可以从/var/log/oracleasm日志中查看错误的原因.
 
[root@hxl log]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
 
4.设置自动启动和关闭
#cd /etc/rc5.d 默认进入的是图形界面
[root@hxl rc5.d]# ln -s /etc/rc.d/init.d/oracleasm S99oracleasm
[root@hxl rc5.d]# ln -s /etc/rc.d/init.d/oracleasm K01oracleasm
[root@hxl rc5.d]# lsmod |grep oracleasm
oracleasm              44692  1
[root@hxl rc5.d]# dmesg |grep oracleasm
ASM: oracleasmfs mounted with options:
 
5.创建ASM磁盘(说明:createdisk 是针对分区,不是针对磁盘,即:先应将磁盘分区)
[root@hxl oracle]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "VOL1" as an ASM disk:                        [  OK  ]
[root@hxl oracle]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk "VOL2" as an ASM disk:                        [  OK  ]
[root@hxl oracle]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "VOL3" as an ASM disk:                        [FAILED]
 
小插曲,在创建VOL3的时候提示失败,查看日志信息发现该设备在使用
[root@hxl oracle]#less /var/log/oracleasm
Instantiating disk: done
Unable to open device "/dev/sdd1": Device or resource busy
Unable to open device "/dev/sdd1": Device or resource busy
 
查看/etc/fstab发现/dev/sdd1 mount到了/u02,将该行注释掉,问题解决.
[root@hxl /]# more /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
sysfs                   /sys                    sysfs   defaults        0 0
LABEL=/u01              /u01                    ext3    defaults        1 2
/dev/sdd1               /u02                    ext3    defaults        1 2
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
 
[root@hxl oracle]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "VOL3" as an ASM disk:                        [  OK  ]
 
[root@hxl oracle]# /etc/init.d/oracleasm listdisks //列出ASM磁盘
VOL1
VOL2
VOL3
到这里ASM磁盘已经创建好了,下面开始创建ASM实例.
 
----------------------------------创建ASM实例部分------------------------------
1.Configuring Oracle Cluster Synchronization Services (CSS)
用于同步ASM实例与RDBMS实例,使用root帐户进行配置,配置程序位于$ORACLE_HOME/bin
$ echo $ORACLE_HOME
/u01/app/oracle/product/10.2.0/db_1
$su
# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
        hxl
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
 
2.创建目录
mkdir -p $ORACLE_BASE/admin/+ASM/bdump
mkdir -p $ORACLE_BASE/admin/+ASM/cdump
mkdir -p $ORACLE_BASE/admin/+ASM/hdump
mkdir -p $ORACLE_BASE/admin/+ASM/pfile
mkdir -p $ORACLE_BASE/admin/+ASM/udump
 
3.创建实例参数
vi $ORACLE_BASE/admin/+ASM/pfile/init.ora
输入如下内容
###########################################
# Automatic Storage Management
###########################################
# _asm_allow_only_raw_disks=false
# Default asm_diskstring values for supported platforms:
#     Solaris (32/64 bit)   /dev/rdsk/*
#     Windows NT/XP        
*
#     Linux (32/64 bit)     /dev/raw/*
#     HPUX                  /dev/rdsk/*
#     HPUX(Tru 64)          /dev/rdisk/*
#     AIX                   /dev/rhdisk/*
###########################################
# Diagnostics and Statistics
###########################################
background_dump_dest=/u01/app/oracle/admin/+ASM/bdump
core_dump_dest=/u01/app/oracle/admin/+ASM/cdump
user_dump_dest=/u01/app/oracle/admin/+ASM/udump
###########################################
# Miscellaneous
###########################################
instance_type=asm
###########################################
# Pools
###########################################
large_pool_size=12M
###########################################
# Security and Auditing
###########################################
remote_login_passwordfile=exclusive
 
4.创建符号连接
ln -s $ORACLE_BASE/admin/+ASM/pfile/init.ora $ORACLE_HOME/dbs/init+ASM.ora
 
5.启动ASM实例
Starting the ASM Instance
[oracle@hxl pfile]$ ORACLE_SID=+ASM; export ORACLE_SID
[oracle@hxl pfile]$
[oracle@hxl pfile]$ echo $ORACLE_SID
+ASM
[oracle@hxl pfile]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jun 30 20:38:37 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ASM instance started
Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted
这里报错误是因为我们还没有创建Diskgroup,这个错误可以先不管,下面的步骤会创建Diskgroup.
 
SQL> create spfile from pfile='/u01/app/oracle/admin/+ASM/pfile/init.ora';

File created.
SQL> shutdown
ASM instance shutdown
SQL> startup
ASM instance started
 
SQL>alter system set asm_diskstring='ORCL:VOL*' scope=spfile;
 
注意这里的前缀VOL是根据前面创建的ASM磁盘名字定义的.
6.创建Diskgroup(这里采用外部冗余的方式)
Create Diskgroup DATA Normal EXTERNAL Disk 'ORCL:VOL1','ORCL:VOL2','ORCL:VOL3';
 
7.重启动ASM实例
SQL> shutdown
ASM instance shutdown
SQL> startup
ASM instance started
 
----------------------------------创建数据库部分--------------------------------
创建使用ASM管理的数据库跟普通创建数据库没什么差别,使用DBCA创建,只是在选择存储方式的时候选择ASM,其他步骤省略.
 
创建完数据库侯,我们创建表空间.
create tablespace tps_hxl
datafile '+DATA' size 100m;
这里的datafile只要制定具体某个Diskgroup即可,可以通过v$datafile查看.
SQL>select a.name
      from v$datafile a, v$tablespace b
     where a.ts# = b.ts#
       and b.name = 'TPS_HXL'
NAME
--------------------  
+DATA/oracl/datafile/tps_hxl.270.787354193
 
可以看出,ASM会自动会创建文件,这是ASM管理的好处之一,不用具体制定文件.
 
 
-- The End --
阅读(6948) | 评论(0) | 转发(2) |
0

上一篇:Linux下安装裸设备

下一篇:impdp

给主人留下些什么吧!~~