ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 安装ASM数据库 ASMLib方式

安装ASM数据库 ASMLib方式

原创 Linux操作系统 作者:hjianping 时间:2011-04-24 12:33:02 0 删除 编辑

一、安装oracleasmlib程序包。从OTN下载ASM库,并以root用户身份安装ASM RPM。
http://www.oracle.com/technology/software/tech/linux/asmlib/rhel4.html
查看Linux版本
# uname -a

kernel-hugemem-2.6.9-42.0.0.0.1.EL.i686.rpm
kernel-smp-2.6.9-42.0.0.0.1.EL.i686.rpm
sysstat-5.0.5-1
libaio-0.3.105-2.i386.rpm
oracleasm-support-2.0.3-2.i386.rpm
oracleasm-2.6.9-42.0.0.0.1.EL-2.0.3-2.i686.rpm
oracleasmlib-2.0.4-1.el4.i386.rpm

查询一个包是否被安装
# rpm -qa | grep < rpm package name >

安装包
# rpm -ivh *.rpm
# rpm -ivh < rpm package name >

查询一个包是否被安装
# rpm -qa | grep < rpm package name >


二、配置ORACLE环境参数

1、配置网络
vi /etc/hosts
127.0.0.1               redhat localhost.localdomain localhost
变成
127.0.0.1               localhost.localdomain localhost
192.168.1.120           localhost.localdomain redhat


2、创建ORACLE用户及目录
==================================================
groupadd oinstall
groupadd dba

mkdir -p /u01/oracle

useradd -g oinstall -G dba -d /u01/oracle oracle
passwd oracle

chown -R oracle:oinstall /u01
==================================================

4、设置环境变量(oracle用户)
vi .bash_profile
===============================================================================
ORACLE_SID=ora10
ORACLE_BASE=/u01
ORACLE_HOME=/u01/oracle
PATH=$ORACLE_HOME/bin:$PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

export ORACLE_SID ORACLE_BASE ORACLE_HOME PATH LD_ASSUME_KERNEL LD_LIBRARY_PATH
================================================================================
检验环境变量设置是否成功,ORACLE用户登陆
env | grep ORA

5、配置内核参数(root用户)
vi /etc/sysctl.conf
===========================================
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
===========================================
/sbin/sysctl -p (要执行)

6、To increase the shell limits(root用户):

Add the following lines to the vi /etc/security/limits.conf file:
============================================
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536
============================================

Add or edit the following line in the vi /etc/pam.d/login file, if it does not already exist(root用户):
===================================================
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so
===================================================

For the Bourne, Bash, or Korn shell,add the following lines to the vi /etc/profile file (or the file on SUSE systems)/etc/profile.local(root用户):
===================================================
if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
              ulimit -p 16384
              ulimit -n 65536
        else
              ulimit -u 16384 -n 65536
        fi
fi
===================================================


三、添加磁盘,以root用户身份
# fdisk /dev/sdb

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-512, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-512, default 512):
Using default value 512

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde


四、配置Oracle自动存储管理(ASM)

以root用户身份配置ASMLib。

# /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 []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration:           [  OK  ]
Loading module "oracleasm":                                [  OK  ]
Mounting ASMlib driver filesystem:                         [  OK  ]
Scanning system for ASM disks:                             [  OK  ]

确认ASMLib驱动被加载
# lsmod | grep asm

确认系统内存在oracleasmfs文件系统
# cat /proc/filesystems

确认oracleasm文件被系统挂载
# df -ha

创建ASM磁盘。以root用户身份在任何一个节点上创建ASM磁盘。

# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk:                   [  OK  ]
# /etc/init.d/oracleasm createdisk VOL4 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk:                   [  OK  ]

# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:                      [  OK  ]

# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4


五、安装Oracle数据库和实例
1、安装Oracle数据库(以Oracle用户身份安装,先不安装实例)
解压ZIP文件
unzip *.zip

安装
./runInstaller
选择高级安装,添加中文支持。

以root用户身份运行
./u01/oraInventory/orainstRoot.sh
./u01/oracle/root.sh
(回车取默认)

2、安装ASM
a、以root用户身份运行
# /u01/oracle/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.
        redhat
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
==============================================================

b、以Oracle用户身份安装ASM
$ dbca
选择Configure Automatic Storage Management

3、以Oracle用户身份安装实例
$ dbca
选择Create a Database

$ netca

启动ASM
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> startup

启动实例
$ export ORACLE_SID=ora10
$ sqlplus / as sysdba
SQL> startup


六、ASM相关故障处理

1、ORA-29701: unable to connect to Cluster Manager
# ps -axu |grep cssd
# /etc/init.d/init.cssd stop
# /etc/init.d/init.cssd start

2、没有挂载ASM磁盘
SQL> startup;
ORA-01078: failure in processing system parameters
ORA-01565: error in identifying file '+date1/ora10/spfileora10.ora'
ORA-17503: ksfdopn:2 Failed to open file +date1/ora10/spfileora10.ora
ORA-15077: could not locate ASM instance serving a required diskgroup
可以看出diskgroup没有mount,所以先把diskgroup mount

$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> shutdown immediate;
ORA-15100: invalid or missing diskgroup name
ASM instance shutdown

SQL> startup;
ASM instance started
Total System Global Area   92274688 bytes
Fixed Size                  1217884 bytes
Variable Size              65890980 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted

SQL> select name,state from v$asm_diskgroup;

SQL> alter diskgroup DATE1 mount;

SQL> alter diskgroup DATA2 mount;

SQL> exit

$ export ORACLE_SID=ora10
$ sqlplus / as sysdba
SQL> startup


七、测试ASM数据库
1、添加磁盘
alter diskgroup dg1 add
failgroup fg1 disk '/dev/raw/raw7'
failgroup fg2 disk '/dev/raw/raw8';

alter diskgroup dg2 add disk '/dev/raw/raw9';

select group_number,operation,state,est_work,sofar,est_minutes from v$asm_operation;
(no rows selected 即自动数据平衡完成)

select name,allocation_unit_size,total_mb from v$asm_diskgroup;

2、删除磁盘
alter diskgroup dgroup1 drop disk '/dev/raw/raw9';

select group_number,operation,state,est_work,sofar,est_minutes from v$asm_operation;
(no rows selected 即自动数据平衡完成)

select name,allocation_unit_size,total_mb from v$asm_diskgroup;
alter diskgroup dgroup1 rebalance;
select label,failgroup,state from v$asm_disk;

3、相关视图
V$asm_operation

V$asm_diskgroup

V$asm_disk

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17012874/viewspace-693281/,如需转载,请注明出处,否则将追究法律责任。

下一篇: Solaris上安装Oracle
请登录后发表评论 登录
全部评论

注册时间:2011-04-24

  • 博文量
    80
  • 访问量
    72823