Linux 6.5(Oracle 11.2.0.4)单实例ASM安装

Linux 6.5(Oracle 11.2.0.4)单实例ASM安装

1、解析主机、配置网络等
/etc/hosts
 /etc/sysconfig/network

/etc/init.d/NetworkManager stop
 chkconfig NetworkManager off
 iptables -F
 service iptables save
 sed -ri 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
 2、配置yum
 cd /etc/yum.repos.d/
 touch yum_oel5.repo
 vi yum_oel5.repo

添加以下内容:
[oel6]
 name=oel6
 baseurl=file:///mnt/Server
 gpgcheck=0
 enabled=1

yum clean all
 yum repolist
 yum list

yum install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc- gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh ksh compat-libcap1

Pdksh 一定要先装,不然后面会报错的
3、修改系统参数
 调整内核参数,并使其生效
vi /etc/sysctl.conf
 fs.file-max = 6815744
 kernel.shmall = 2097152
 kernel.shmmax = 4294967295
 kernel.shmmni = 4096
 kernel.sem = 250 32000 100 128
 net.ipv4.ip_local_port_range = 9000 65500
 net.core.rmem_default = 262144
 net.core.rmem_max = 4194304
 net.core.wmem_default = 262144
 net.core.wmem_max = 1048576
 fs.aio-max-nr = 1048576

sysctl -p

修改limits.conf

vi /etc/security/limits.conf

oracle settings

oracle soft nproc 2047
 oracle hard nproc 16384
 oracle soft nofile 1024
 oracle hard nofile 65536
 oracle soft stack 10240
 grid soft nproc 2047
 grid hard nproc 16384
 grid soft nofile 1024
 grid hard nofile 65536
 grid soft stack 1024

修改/etc/pam.d/login
 vi /etc/pam.d/login
 session required /lib/security/pam_limits.so
 session required pam_limits.so

修改/etc/profile

if [ $USER = "oracle" ]; then
 if [ $SHELL = "/bin/ksh" ]; then
 ulimit -p 16384
 ulimit -n 65536
 else
 ulimit -u 16384 -n 65536
 fi
 fi

修改/etc/csh.login

if ( $USER == "oracle" ) then
 limit maxproc 16384
 limit deors 65536
 endif
 4、
--添加用户和组(非Oracle Linux环境配置)

groupadd -g 501 oinstall
 groupadd -g 502 dba
 groupadd -g 503 oper
 groupadd -g 504 asmadmin
 groupadd -g 505 asmdba
 groupadd -g 506 asmoper

useradd -u 500 -g oinstall -G dba,asmdba,asmadmin,oper oracle
 useradd -u 507 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid

注意,oper组不是必须的,dba,asmdba,asmadmin必须有

--修改grid和oracle用户密码

passwd oracle
 passwd grid

--配置环境变量

grid:

export ORACLE_SID=+ASM
 export ORACLE_BASE=/home/u01/grid
 export ORACLE_HOME=$ORACLE_BASE/11.2.0
 export PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin/:
 export NLS_LANG=American_america.ZHS16GBK
 export TEMP=/tmp
 export TMP=/tmp
 export TMPDIR=/tmp
 umask 022

oracle:

ORACLE_SID=ydasm; export ORACLE_SID
 ORACLE_BASE=/home/u01/oracle; export ORACLE_BASE
 ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
 GRID_HOME=/home/u01/grid/11.2.0; export GRID_HOME
 NLS_DATE_FORMAT="YYYY:MM:DD HH24:MI:SS"; export NLS_DATE_FORMAT
 NLS_LANG=american_america.ZHS16GBK; export NLS_LANG
 PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$GRID_HOME/bin export PATH
 export NLS_LANG=American_america.ZHS16GBK
 export TEMP=/tmp
 export TMPDIR=/tmp
 umask 022

主要是配置几个环境变量必须
mkdir -p /home/u01/grid/11.2.0
 mkdir -p /home/u01/grid
 mkdir -p /home/u01/oracle/product/11.2.0/db_1
 chown -R oracle:oinstall /home/u01
 chmod -R 775 /home/u01
 5、上传Oracle安装介质到/u01/tmp目录下
mkdir -p /u01/tmp

p13390677_112040_Linux-x86-64_1of7.zip
 p13390677_112040_Linux-x86-64_2of7.zip
 p13390677_112040_Linux-x86-64_3of7.zip
 6、vi /etc/RedHat-release

Red Hat Enterprise Linux Server release 4.0 (Santiago)
 7、安装grid组件

--利用udev绑定磁盘

for Linux 6.x
 for i in b c d;
 do
 echo "KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/\$name",
 RESULT=="/sbin/scsi_id -g -u /dev/sd$i", name="asm-disk$i", OWNER="grid",
 GROUP="asmadmin", MODE="0660""
 done

for Linux 5.x
 for i in b c d;
 do
 echo "KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="scsi_id -g -u -s /block/sd$i", name="asm-disk$i", OWNER="grid", GROUP="asmadmin", MODE="0660""
 done

使用的时候要注意在不同版本上脚本的区别,否则获取不到磁盘的scsi_id

[root@rac1 ]# /sbin/service ntpd stop
关闭 ntpd: [失败][root@rac1 ]# chkconfig ntpd off
 [root@rac1 ]# mv /etc/ntp.conf /etc/ntp.conf.original
直接使用裸设备的方法:
1.在RHEL6以前的可以直接通过rawdevices的管理方法,系统安装后默认已存在/etc/init.d/rawdevices和/etc/sysconfig/rawdevices这两个文件。
1.在RHEL6中,系统里面虽然已经不存在/etc/sysconfig/rawdevices和/etc/init.d/rawdevices文件了,但是依然支持rawdevices的方式,可以通过如下方法来管理raw文件。
a.手动创建/etc/sysconfig/rawdevices和/etc/init.d/rawdevices文件,然后依然以rawdevices的方式
b.通过udev来管理raw,同样也可以通过udev固定磁盘对应的设备名
 采用新建的方法

vi /etc/init.d/rawdevices

!/bin/bash


rawdevices This shell script assignes rawdevices to block devices


chkconfig: 345 56 44

description: This scripts assignes raw devices to block devices \

(such as hard drive partitions). This is for the use \

of applications such as Oracle. You can set up the \

raw device to block device mapping by editing \

the file /etc/sysconfig/rawdevices.

config: /etc/sysconfig/rawdevices

[ -f /bin/raw ] || exit 0
 [ -f /etc/sysconfig/rawdevices ] || exit 0

Exit if the file just has the default comments.

LC_ALL=C /bin/egrep -q -v "^ #" /etc/sysconfig/rawdevices 2>/dev/null || exit 0
 . /etc/init.d/functions
 function assign_raw()
 {
 LC_ALL=C egrep -v '^ #' /etc/sysconfig/rawdevices |
 while read RAW BLOCK; do
 if [ -n "$RAW" -a -n "$BLOCK" ]; then
 rawdirname=${RAW%/*}
 if [ "$rawdirname" = "/dev" -a -d /dev/raw ]; then
 echo $" Please correct your /etc/sysconfig/rawdevices:"
 echo $" rawdevices are now located in the directory /dev/raw/ "
 echo $" If the command 'raw' still refers to /dev/raw as a file."
 echo $" you'll have to upgrade your util-linux package"
 exit 0
 fi
 if [ "$rawdirname" = "/dev/raw" -a -f /dev/raw ]; then
 echo $" Please correct your /etc/sysconfig/rawdevices:"
 echo $" rawdevices are now located in the directory /dev/raw/ "
 echo $" If the command 'raw' still refers to /dev/raw as a file."
 echo $" you'll have to upgrade your util-linux package"
 exit 0
 fi
 echo " $RAW --> $BLOCK";
 raw $RAW $BLOCK
 fi
 done
 }

See how we were called.

case "$1" in
 start)
 # Assign devices
 echo $"Assigning devices: "
 assign_raw

添加以下两行(默认不存在),即默认情况下生成的裸设备为root所有,

所以必须修改属主,否则oracle用户无法使用裸设备
    sleep 5
    chown -R grid:asmadmin /dev/raw/
  echo $"done"
    ;;

stop)
 # No action to be taken here
 ;;
 status)
 ID=id -u
 if [ $ID -eq 0 ]; then
 raw -qa
 else
 echo $"You need to be root to use this command ! "
 fi
 ;;
 restart|reload)
 $0 start
 ;;
 *)
 echo $"Usage: $0 {start|stop|status|restart}"
 exit 1
 esac
 exit 0

--------------------------------------------------------------------------------

vi /etc/sysconfig/rawdevices //映射将要绑定的裸设备

/dev/raw/raw5 /dev/sdb
 /dev/raw/raw6 /dev/sdc
 /dev/raw/raw7 /dev/sdd
 /dev/raw/raw8 /dev/sde

[root@rac1]# chkconfig rawdevices on
 [root@rac1]# service rawdevices start

[root@ydtest host2]# pwd
 /sys/class/scsi_host/host2
 [root@ydtest host2]# echo '- - -' > scan
 [root@ydtest host2]#
 [root@ydtest host2]# cd ../host0
 [root@ydtest host0]# echo '- - -' > scan
虚拟机加盘后 扫描盘

[root@rac1]# fdisk -l
 Disk /dev/sda: 32.2 GB, 32212254720 bytes
 255 heads, 63 sectors/track, 3916 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Device Boot Start End Blocks Id System
 /dev/sda1 * 1 5 40131 83 Linux
 /dev/sda2 6 2172 17406427+ 8e Linux LVM
 /dev/sda3 2173 2237 522112+ 82 Linux swap / Solaris
 /dev/sda4 2238 3916 13486567+ 5 Extended
 /dev/sda5 2238 2542 2449881 83 Linux
 /dev/sda6 2543 2847 2449881 83 Linux
 /dev/sda7 2848 3152 2449881 83 Linux
 /dev/sda8 3153 3457 2449881 83 Linux
 /dev/sda9 3458 3916 3686886 83 Linux
 [root@rac1 rules.d]# cd /etc/udev/rules.d/
 [root@rac1 rules.d]# vi 99-oracle.rules
 ACTION=="add",KERNEL=="sdb",RUN+="/bin/raw /dev/raw/raw5 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
 ACTION=="add",KERNEL=="sdc",RUN+="/bin/raw /dev/raw/raw6 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
 ACTION=="add",KERNEL=="sdd",RUN+="/bin/raw /dev/raw/raw7 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
 ACTION=="add",KERNEL=="sde",RUN+="/bin/raw /dev/raw/raw8 %N",OWNER="grid", GROUP="asmadmin", MODE="660"

--重启udev,使配置生效

/sbin/start_udev

[root@rac1]# vi /etc/sysconfig/rawdevices
 /dev/raw/raw5 /dev/sdb
 /dev/raw/raw6 /dev/sdc
 /dev/raw/raw7 /dev/sdd
 /dev/raw/raw8 /dev/sde

[root@rac1]# chmod +x /etc/rc.d/init.d/rawdevices
 [root@rac1]# chkconfig --add rawdevices
 [root@rac1]# chkconfig rawdevices on
 [root@rac1]# service rawdevices start
 Assigning devices:
 /dev/raw/raw5 --> /dev/sdb
 /dev/raw/raw5: bound to major 8, minor 5
 /dev/raw/raw6 --> /dev/sdc
 /dev/raw/raw6: bound to major 8, minor 6
 /dev/raw/raw7 --> /dev/sdd
 /dev/raw/raw7: bound to major 8, minor 7
 /dev/raw/raw8 --> /dev/sde
 /dev/raw/raw8: bound to major 8, minor 8
 done
 [root@rac1]# raw -qa
 /dev/raw/raw5: bound to major 8, minor 5
 /dev/raw/raw6: bound to major 8, minor 6
 /dev/raw/raw7: bound to major 8, minor 7
 /dev/raw/raw8: bound to major 8, minor 8

如果执行脚本的时候停在Adding daemon to inittab,这是 11.2.0.1和11.2.0.2 在RHEL6上的bug,可以以root身份执行以下命令:

[root@rac1]# dd if=/var/tmp/.oracle/npohasdof=/dev/null bs=1024 count=1

ydasm 2016/11/22 11:21:57 /home/u01/grid/11.2.0/cdata/ydasm/backup_20161122_112157.olr
 Successfully configured Oracle Grid Infrastructure for a Standalone Server

Asmca
 Dbca

2.3 安装后的检查、配置

检查是否正确安装:

$ oraenv

ORACLE_SID=+ASM

The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle

$ echo $ORACLE_SID

+ASM

$ crsctl check has

CRS-4638: Oracle High Availability Services is online

$ crs_stat -t
 Name Type Target State Host
 ------------------------------------------------------------
 ora.DATA.dg ora....up.type ONLINE ONLINE ydasm
 ora....ER.lsnr ora....er.type ONLINE ONLINE ydasm
 ora.VOTE.dg ora....up.type ONLINE ONLINE ydasm
 ora.asm ora.asm.type ONLINE ONLINE ydasm
 ora.cssd ora.cssd.type ONLINE ONLINE ydasm
 ora.diskmon ora....on.type OFFLINE OFFLINE
 ora.evmd ora.evm.type ONLINE ONLINE ydasm
 ora.ons ora.ons.type OFFLINE OFFLINE

从11.2.0.3以后,在非Exadata上, ora.diskmon的缺省状态为offline
 ora.ons主要用于中间件和数据库的相连

设置开机自动启动crs:

[root@rac1]# tail -n 1 /etc/inittab //安装完成默认会向inittab文件添加该记录

h1:35:respawn:/etc/init.d/init.ohasd run >/dev/null 2>&1 > /etc/rc.local <

[root@rac1]#rm -rf /u01/app/oracle/product/11.2.0/grid/ //删除grid的安装文件

[root@rac1]# for i in {5..8} ;do dd if=/dev/zero of=/dev/raw/raw$i bs=1024 count=10 ;done //低格裸设备(清除ASM磁盘组信息)

相关推荐