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

时间:2022-06-08 16:58:03

Linux 6.5(oracle 11.2.0.4)1、解析主机、配置网络等/etc/hosts/etc/sysconfig/network

/etc/init.d/NetworkManager stopchkconfig NetworkManager offiptables -Fservice iptables savesed -ri 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux2、配置yumcd /etc/yum.repos.d/touch yum_oel5.repovi yum_oel5.repo

添加以下内容:[oel6]name=oel6baseurl=file:///mnt/Servergpgcheck=0enabled=1

yum clean allyum repolistyum 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.conffs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 4294967295kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576fs.aio-max-nr = 1048576

sysctl -p

#修改limits.conf

vi /etc/security/limits.conf#oracle settingsoracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240grid soft nproc 2047grid hard nproc 16384grid soft nofile 1024grid hard nofile 65536grid soft stack 1024

#修改/etc/pam.d/loginvi /etc/pam.d/loginsession required /lib/security/pam_limits.sosession required pam_limits.so

#修改/etc/profile

if [ $USER = "oracle" ]; thenif [ $SHELL = "/bin/ksh" ]; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fifi

#修改/etc/csh.login

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

groupadd -g 501 oinstallgroupadd -g 502 dbagroupadd -g 503 opergroupadd -g 504 asmadmingroupadd -g 505 asmdbagroupadd -g 506 asmoper

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

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

--修改grid和oracle用户密码

passwd oraclepasswd grid

--配置环境变量

grid:

export ORACLE_SID=+ASMexport ORACLE_BASE=/home/u01/gridexport ORACLE_HOME=$ORACLE_BASE/11.2.0export PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin/:export NLS_LANG=American_america.ZHS16GBKexport TEMP=/tmpexport TMP=/tmpexport TMPDIR=/tmpumask 022

oracle:

ORACLE_SID=ydasm; export ORACLE_SIDORACLE_BASE=/home/u01/oracle; export ORACLE_BASEORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOMEGRID_HOME=/home/u01/grid/11.2.0; export GRID_HOMENLS_DATE_FORMAT="YYYY:MM:DD HH24:MI:SS"; export NLS_DATE_FORMATNLS_LANG=american_america.ZHS16GBK; export NLS_LANGPATH=.:$:$HOME/bin:$ORACLE_HOME/bin:$GRID_HOME/bin export PATHexport NLS_LANG=American_america.ZHS16GBKexport TEMP=/tmpexport TMPDIR=/tmpumask 022

主要是配置红色字体的几个环境变量必须mkdir -p /home/u01/grid/11.2.0mkdir -p /home/u01/gridmkdir -p /home/u01/oracle/product/11.2.0/db_1chown -R oracle:oinstall /home/u01chmod -R 775 /home/u015、上传Oracle安装介质到/u01/tmp目录下mkdir -p /u01/tmp

p13390677_112040_Linux-x86-64_1of7.zipp13390677_112040_Linux-x86-64_2of7.zipp13390677_112040_Linux-x86-64_3of7.zip6、vi /etc/redhat-release

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

--利用udev绑定磁盘

for Linux 6.xfor i in b c d;doecho "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.xfor i in b c d;doecho "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这两个文件。2. 在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

chkconfig rawdevices on

service rawdevices start

1.4 绑定裸设备(用于创建ASM磁盘组,更详细的内容请参考:http://www.linuxidc.com/Linux/2013-06/85973.htm)

[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虚拟机加盘后 扫描盘

fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes255 heads, 63 sectors/track, 3916 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice 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.rulesACTION=="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

vi /etc/sysconfig/rawdevices

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

chmod +x /etc/rc.d/init.d/rawdevices

chkconfig --add rawdevices

chkconfig rawdevices on

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 8done

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身份执行以下命令:

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.olrSuccessfully configured Oracle Grid Infrastructure for a Standalone Server

AsmcaDbca

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 -tName 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的缺省状态为offlineora.ons主要用于中间件和数据库的相连

设置开机自动启动crs:

tail -n 1 /etc/inittab //安装完成默认会向inittab文件添加该记录

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

cat >> /etc/rc.local <<EOF

/etc/init.d/init.ohasd run >/dev/null 2>&1 </dev/null &

EOF

2.4 卸载、重装

如果grid安装失败,需要卸载干净才能重新安装,否则仍然安装不成功。

#rm -rf /etc/ora*

#vi /etc/inittab

h1:35:respawn:/etc/init.d/init.ohasdrun >/dev/null 2>&1 </dev/null //删除此行

#rm -rf /u01/app/oracle/product/11.2.0/grid/ //删除grid的安装文件

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