ASM安装基本环境配置

ASM安装基本环境配置

1)安装rpm

[root@oracle ~]# yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686  compat-libstdc++-33 gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel  libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel  libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686 elfutils-libelf-devel unzip

[root@oracle ~]# rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel

2)创建用户及用户组

[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# groupadd asmadmin
[root@localhost ~]# groupadd asmoper
[root@localhost ~]# groupadd asmdba
[root@localhost ~]# useradd -g oinstall -G asmdba,asmadmin,asmoper,dba grid
[root@localhost ~]# useradd -g oinstall -G dba,asmdba oracle
[root@localhost ~]# passwd grid    ##Grid_1
Changing password for user grid.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# passwd oracle      ##Oracle_1
Changing password for user oracle.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# id grid
uid=1000(grid) gid=1000(oinstall) groups=1000(oinstall),1001(dba),1002(asmadmin),1003(asmdba)
[root@localhost ~]# id oracle
uid=1001(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba),1003(asmdba)
[root@localhost ~]#

3)修改内核参数

[root@oracle ~]# vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
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

[root@oracle ~]# sysctl -p
fs.aio-max-nr = 1048576
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

4)设置oracle、grid用户shell限制

[root@oracle ~]# vim /etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
grid soft nofile 1024
grid hard nofile 65536
grid soft nproc 16384
grid hard nproc 16384
grid soft stack 10240
grid hard stack 32768

5)修改vim /etc/pam.d/login文件

[root@oracle ~]# vim /etc/pam.d/login
session required  /lib64/security/pam_limits.so
session required pam_limits.so

6)修改主机名及hosts文件

[root@localhost ~]# vim /etc/hostname
oracle

[root@oracle ~]# vim /etc/hosts
10.10.10.103 oracle

##不要有非常规字符,如"-" "~"等,可以有“_”“#”“$”“.”

7)配置/etc/profile

[root@oracle ~]# vim /etc/profile
if [ $USER = "oracle" ] || [ $USER = "grid" ] ; then
    if [ $SHELL = "/bin/ksh" ]; then
        ulimit -p 16384
        ulimit -n 65536
    else
        ulimit -u 16384 -n 65536
    fi
umask 022
fi

[root@oracle ~]# source /etc/profile

8)创建安装目录

[root@oracle ~]# mkdir -p /oracle/11g
[root@oracle ~]# mkdir -p /oracle/11g/oraInventory
[root@oracle ~]# chown -R oracle:oinstall /oracle/11g
[root@oracle ~]# chmod -R 775 /oracle/11g

[root@oracle ~]# mkdir -p /oracle/grid
[root@oracle ~]# mkdir -p /oracle/grid/oraInventory
[root@oracle ~]# chown -R grid:oinstall /oracle/grid
[root@oracle ~]# chmod -R 775 /oracle/grid

9)配置oracle、grid用户环境变量

##oracle
vim /home/oracle/.bash_profile
ORACLE_BASE=/oracle/11g; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH; export PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;export LD_LIBRARY_PATH
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_TERM=xterm; export ORACLE_TERM.
NLS_LANG="AMERICAN_AMERICA.AL32UTF8";export NLS_LANG
umask 022

##grid
vim /home/grid/.bash_profile
ORACLE_BASE=/oracle/grid; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/grid_home; export ORACLE_HOME
ORACLE_SID=+ASM; export ORACLE_SID
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH; export PATH
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

10)配置ASM磁盘

ASM一般使用的是共享存储,那么就会有一个问题就是,每次重启,磁盘的盘符就可能会变化,会导致数据混乱,因此我们需要固定设备名,让其每次重启找到的都是正确的磁盘

查看磁盘,其中sdb、sdc、sdd是新增的,每块5G

[root@oracle ~]# fdisk -l |grep dev/sd
Disk /dev/sdd: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   104857599    51915776   8e  Linux LVM
Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 sectors
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 sectors

查看scsi_id,如果使用的vmware虚拟机,会返回什么都没有,需要再虚拟机配置文件xxxx.vmx里面加上 disk.EnableUUID =”TRUE”

[root@oracle ~]# /usr/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/sdb
36000c291d5874c3016f6b765844b5228
[root@oracle ~]# /usr/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/sdc
36000c2977ba75cc607a20a729cc7fde3
[root@oracle ~]# /usr/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/sdd
36000c29c3a13498e34697ea5388c88f7
for i in b c d e f g h
do
echo "KERNEL==\"sd?\", SUBSYSTEM==\"block\",PROGRAM=\"/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/\$name\", RESULT==\"`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/sd$i`\", SYMLINK+=\"asm-disk-sd$i\",OWNER=\"grid\",GROUP=\"asmadmin\",MODE=\"0660\""
done

配置udev策略

[root@oracle ~]# vim /usr/lib/udev/rules.d/99-oracle-asm-disk.rules

KERNEL=="sd?", SUBSYSTEM=="block", PROGRAM="/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/$name", RESULT=="36000c291d5874c3016f6b765844b5228", SYMLINK+="asm-disk-1", OWNER=="grid", GROUP=="asmadmin", MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block", PROGRAM="/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/$name", RESULT=="36000c2977ba75cc607a20a729cc7fde3", SYMLINK+="asm-disk-2", OWNER=="grid", GROUP=="asmadmin", MODE="0660"
KERNEL=="sd?", SUBSYSTEM=="block", PROGRAM="/lib/udev/scsi_id --whitelisted --replace-whitespace /dev/$name", RESULT=="36000c29c3a13498e34697ea5388c88f7", SYMLINK+="asm-disk-3", OWNER=="grid", GROUP=="asmadmin", MODE="0660"

加载udev策略

[root@oracle ~]# /sbin/udevadm control --reload
[root@oracle ~]# /sbin/udevadm trigger --type=devices --action=change

查看是否生效及权限是否正确

[root@oracle ~]# ll /dev/asm-disk-*
lrwxrwxrwx. 1 root root 3 May 25 17:32 /dev/asm-disk-1 -> sdb
lrwxrwxrwx. 1 root root 3 May 25 17:32 /dev/asm-disk-2 -> sdc
lrwxrwxrwx. 1 root root 3 May 25 17:32 /dev/asm-disk-3 -> sdd

[root@oracle ~]# ll /dev/sd[b,c,d]
brw-rw----. 1 grid asmadmin 8, 16 May 25 17:32 /dev/sdb
brw-rw----. 1 grid asmadmin 8, 32 May 25 17:32 /dev/sdc
brw-rw----. 1 grid asmadmin 8, 48 May 25 17:32 /dev/sdd

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 289211569@qq.com