系统环境:
VMware Workstation14.5 +linux 7.6(64位)+Oracle 12.2.0.1.0
两个节点mnt1(节点1)和mnt2(节点2)
hosts:
10.0.3.211 mntdb1
10.0.3.212 mntdb2
10.0.3.213 mntdb1vip
10.0.3.214 mntdb2vip
10.0.3.215 mntdbscanip
192.168.211.211 mntdb1priv
192.168.211.212 mntdb2priv
节点1:
hostname:mnt1 ip:10.0.3.211 scanip:10.0.3.215 dbname=mntdb instance_name=mntdb1
节点2:
hostname:mnt1 ip:10.0.3.212 scanip:10.0.3.215 dbname=mntdb instance_name=mntdb2
0.安装部署前检查,
1.检查网络,有两个不同的网段。
2.检查linux系统版本。
3.检查安装所需的磁盘
4.调整好时区和时间
5.检查iso镜像是否挂上。
1、安装软件包
mount /dev/sr0 /mnt
cd /etc/yum.repos.d/
rm -rf *
vi /etc/yum.repos.d/ol.repo
[local-source]
name=ol
baseurl=file:///mnt/
ebabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
安装rpm依赖包
yum install xterm bc* binutils* compat-l* e2fsprog* glibc-2.* glibc-de* ksh* libgcc-4* libstdc+* libaio-0* libaio-d* libXtst-* libX11-1* libXau-1* libxcb-1* libXi-1.* make-3.8* net-tool* nfs-util* sysstat-* smartmontools*
2、创建用户、组、目录
groupadd -g 1005 oinstall
groupadd -g 1001 dba
groupadd -g 1002 asmadmin
groupadd -g 1003 asmdba
groupadd -g 1004 asmoper
useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
useradd -u 1101 -g oinstall -G dba,asmdba,asmadmin,asmoper oracle
passwd oracle
passwd grid
mkdir -p /u01/12.2.0/grid
mkdir -p /u01/app/grid
chown -R grid:oinstall /u01/12.2.0/grid
chown -R grid:oinstall /u01/app/grid
chmod -R 775 /u01/12.2.0/grid
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/cfgtoollogs
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
mkdir -p /u01/app/oracle/product/12.2.0/db_1
chown -R oracle:oinstall /u01/app/oracle/product/12.2.0/db_1
chmod -R 775 /u01/app/oracle/product/12.2.0/db_1
mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
作用 路径
grid_home /u01/12.2.0/grid
grid_base /u01/app/grid
oracle_base /u01/app/oracle
Oracle_home /u01/app/oracle/product/12.2.0/db_1
3、配置共享磁盘(多路径+udev)
配置multipath加udev
1.双节点安装multipath的包,先后顺序不能乱:
rpm -ivh device-mapper-multipath-libs-0.4.9-123.el7.x86_64.rpm
rpm -ivh device-mapper-multipath-0.4.9-123.el7.x86_64.rpm
2.启动multipath(rac1、rac2都跑)
modprobe dm-multipath
modprobe dm-round-robin
3.开机自启动
systemctl enable multipathd.service
systemctl list-unit-files | grep multi
multipathd.service enabled
multi-user.target static
4.启动multipath服务:
service multipathd start
5.多路径配置(mnt1、mnt2)
oracle RAC所需多路径配置要点是一个RAC节点一个RAC节点一次执行如下操作(如果需要再添加使用多路径的存储,也需遵循如下步骤):
service multipathd stop
multipath -F
获取wwid:
在 Linux 7下,可以使用如下命令:
# /usr/lib/udev/scsi_id -g -u /dev/sdb 360050768018187d15000000000000039
/usr/lib/udev/scsi_id -g -u /dev/sdc 360050768018187d1500000000000003a
/usr/lib/udev/scsi_id -g -u /dev/sdd 360050768018187d15000000000000038
先查看是否存在/etc/multipath.conf,不存在
方法1:创建配置文件:cp /etc/multipath_bak.conf /etc/multipath.conf
vi /etc/multipath.conf
defaults {
user_friendly_names yes
}
devices {
device {
vendor "(COMPAQ|HP)"
product "HSV1[01]1|HSV2[01]0|HSV300|HSV4[05]0"
#getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
features "0"
hardware_handler "0"
path_selector "round-robin 0"
path_grouping_policy group_by_prio
failback immediate
rr_weight uniform
no_path_retry 12
rr_min_io 1000
path_checker tur
prio alua
}
}
multipaths {
multipath {
wwid 360050768018187d15000000000000039
alias ARCH
path_grouping_policy multibus
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry queue
}
multipath {
wwid 360050768018187d1500000000000003a
alias OCR
path_grouping_policy multibus
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry queue
}
multipath {
wwid 360050768018187d15000000000000038
alias DATA
path_grouping_policy multibus
path_selector "round-robin 0"
failback immediate
rr_weight priorities
no_path_retry queue
}
}
blacklist {
devnode "^(sda|ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^hd[a-z]"
devnode "^asm/*" # Here
devnode "ofsctl" # Here
}
#启动多路径:
service multipathd restart
启动multipath配置后,会在/dev/mapper下生成多路径逻辑盘
cd /dev/mapper
ll
#查看多路径的状态:multipath -ll
---验证权限
ls -l /dev/dm-*
---验证命名结果
ls -l /dev/mapper/*
udev步骤:
1.查看磁盘UUID
lsscsi -i
2.编辑 UDEV Rules File
vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-360050768018187d15000000000000039",SYMLINK+="asm_ARCH",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-360050768018187d1500000000000003a",SYMLINK+="asm_OCR",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="dm-*",ENV{DM_UUID}=="mpath-360050768018187d15000000000000038",SYMLINK+="asm_DATA",OWNER="grid",GROUP="asmadmin",MODE="0660"
3.scp rules文件至其他节点
scp /etc/udev/rules.d/99-oracle-asmdevices.rules node2:/etc/udev/rules.d/
4. 重新加载rules文件
udevadm control --reload-rules
udevadm trigger
5.查看绑定后设备信息
[root@test1 rules.d]# ls -l /dev/asm*
lrwxrwxrwx 1 root root 4 Aug 20 14:42 /dev/asm_test1 -> dm-2
lrwxrwxrwx 1 root root 4 Aug 20 14:42 /dev/asm_test2 -> dm-3
lrwxrwxrwx 1 root root 4 Aug 20 14:42 /dev/asm_test3 -> dm-4
lrwxrwxrwx 1 root root 4 Aug 20 14:42 /dev/asm_test4 -> dm-5
lrwxrwxrwx 1 root root 4 Aug 20 14:42 /dev/asm_test5 -> dm-6
lrwxrwxrwx 1 root root 4 Aug 20 14:42 /dev/asm_test6 -> dm-7
[root@test1 rules.d]# ls -l /dev/dm-*
brw-rw---- 1 grid asmadmin 253, 2 Aug 20 14:42 /dev/dm-2
brw-rw---- 1 grid asmadmin 253, 3 Aug 20 14:42 /dev/dm-3
brw-rw---- 1 grid asmadmin 253, 4 Aug 20 14:42 /dev/dm-4
brw-rw---- 1 grid asmadmin 253, 5 Aug 20 14:42 /dev/dm-5
brw-rw---- 1 grid asmadmin 253, 6 Aug 20 14:42 /dev/dm-6
brw-rw---- 1 grid asmadmin 253, 7 Aug 20 14:42 /dev/dm-7
4、配置系统参数
4.1修改主机名
vi /etc/hosts
10.0.3.211 mntdb1
10.0.3.212 mntdb2
10.0.3.213 mntdb1vip
10.0.3.214 mntdb2vip
10.0.3.215 mntdbscanip
192.168.211.211 mntdb1priv
192.168.211.212 mntdb2priv
vi /etc/hostname
mntdb1 mntdb2
hostname mntdb1
hostname mntdb2
4.2配置系统文件
--/etc/security/limits.conf 是 Linux 资源使用配置文件,用来限制用户对系统资源的使用
--https://www.cnblogs.com/pzk7788/p/7250723.html
vi /etc/security/limits.conf
添加
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
grid soft nproc 2047
grid hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
root soft nproc 2047
vi /etc/pam.d/login 添加:
session required pam_limits.so
设置内核参数,编辑文件并使之生效,其值不小于如下设置。
以下是参考内容
vi /etc/sysctl.conf
# for oracle
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 16777216
kernel.shmmax = 41231686041
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
kernel.panic_on_oops = 1
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 = 1048586
vm.swappiness=10
配置生效,在全部节点操作
sysctl -p
vi /etc/profile添加:
if [ $USER = "oracle" ] || [ $USER = "grid" ] ; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -u 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
4.3、禁用SELinux、防火墙、NTP
建议禁用此功能。
vi /etc/selinux/config
SELINUX=disabled
需要重启。
systemctl stop firewalld
systemctl disable firewalld
service ntpd stop
chkconfig ntpd off
rm -rf /etc/ntpd.conf
rm -rf /var/run/ntpd.pid
4.4 oracle、grid用户环境变量配置
oracle用户,2个节点上配置:
vi ~/.bash_profile 编辑后source ~/.bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=test1 #节点2改为test2
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
grid用户,2个节点上配置:
vi ~/.bash_profile 编辑后source ~/.bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM1 # RAC1
#export ORACLE_SID=+ASM2 # RAC2
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/12.2.0/grid/
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
umask 022
4.5 配置zeroconf
vi /etc/sysconfig/network
NOZEROCONF=yes
4.6 取消透明大页(Transparent HugePages)
cat /sys/kernel/mm/transparent_hugepage/enabled //查看状态
vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"
执行生效命令 grub2-mkconfig -o /boot/grub2/grub.cfg
重启OS后确认是否生效
[root@test12c1 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
4.7、设置Disk I/O Scheduler deadline
vi /etc/udev/rules.d/60-oracle-schedulers.rules
添加如下内容
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
运行生效
udevadm control --reload-rules
5.上传软件包,建立互信、安装rpm包(单节点)
5.1.建立互信
mntdb1 root用户下执行
chown -R oracle:oinstall linuxx64_12201_database.zip
chmod 775 linuxx64_12201_database.zip
unzip linuxx64_12201_database.zip
解压database,解压后databse所有者为oracle用户,权限为775
cd /database/sshsetup
./sshUserSetup.sh -user grid -hosts "mntdb1 mntdb2 " -advanced -noPromptPassphrase
./sshUserSetup.sh -user oracle -hosts "mntdb1 mntdb2 " -advanced -noPromptPassphrase
测试互信:
oracle、grid用户都要测试,如下:
ssh 10.0.3.211
提示输入yes
exit
ssh 10.0.3.212
提3示输入yes
exit
5.2.安装grid内的rpm包
在节点1 grid安装目录下的rpm目录下有cvuqdisk-1.0.9-1.rpm的安装包。
chown -R grid:oinstall linuxx64_12201_grid_home.zip
chmod 775 linuxx64_12201_grid_home.zip
解压grid su - grid 这边GI软件要解压在GI HOME的位置下,即unzip GI软件 GI HOME. GI HOME内所有文件所有者为grid用户,权限为775
unzip linuxx64_12201_grid_home.zip -d /u01/12.2.0/grid
cd /u01/12.2.0/grid/cv/rpm
rpm -ivh cvuqdisk-1.0.10-1.rpm
拷贝cvuqdisk-1.0.10-1.rpm到节点2
scp cvuqdisk-1.0.10-1.rpm mntdb2:/tmp/
节点2安装
cd /u01
rpm -ivh cvuqdisk-1.0.10-1.rpm
5.3.grid安装前检查
su - grid cd /u01/12.2.0/grid
./runcluvfy.sh stage -pre crsinst -n mntdb1,mntdb2 -fixup -verbose
在两个节点下root用户下执行 /tmp/CVU_12.2.0.1.0_grid/runfixup.sh 然后点enter