一、环境设置
1.1、Oracle网络规划
Oracle RAC 每个节点需要占用四个 IP
PUBLIC IP:主机对外的通信 IP #公用IP
PRIVATE IP:RAC 节点之间的通信 IP #专用和asm IP
VIP:节点的虚拟 IP,可以飘移 #虚拟IP
SCAN IP:RAC 的集群服务 IP,调节集群服务的 IP
公用IP | 专用IP(和asm公用) | 虚拟IP | scan ip | |
rac1 | 192.168.117.176 | 192.168.3.176 | 192.168.117.178 | 192.168.117.180 |
rac2 | 192.168.117.177 | 192.168.3.177 | 192.168.117.179 |
PUBLIC IP、VIP、SCAN IP 同段,PRICATE IP 与其他三个 IP 不同段
节点共用 SCAN IP
1.2、ASM磁盘规划
ASM磁盘组名 | 用途 | 大小 | 冗余 |
OCR | ocr、voting file、19c grid 管理库 | 20G | EXTERNAL |
DATA | 数据文件 | 25G | EXTERNAL |
1.3、修改两台服务器的主机名
[root@rac1 ~]# hostnamectl set-hostname rac1
[root@rac2 ~]# hostnamectl set-hostname rac2
运行完之后执行su -就可以看到修改后的主机名了
[root@rac1 ~]# su -
1.4、网络环境配置
两台机器都要配置,需要两个网卡,分别配置公用IP和专用IP
RAC1服务器网络配置
[root@rac1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=30d5a6f3-3ffc-45ff-baa6-d3fe7835ffca DEVICE=ens33 ONBOOT=yes IPADDR=192.168.117.176 PREFIX=24 GATEWAY=192.168.117.2 DNS1=192.168.117.2 IPV6_PRIVACY=n
[root@rac1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens34 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens34 UUID=c00a799d-8164-4c68-9c18-bd503317cbd0 DEVICE=ens34 ONBOOT=no IPADDR=192.168.3.176 PREFIX=24 GATEWAY=192.168.3.2 IPV6_PRIVACY=no
运行ip a查看一下ip
[root@rac1 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:4a:71:87 brd ff:ff:ff:ff:ff:ff inet 192.168.117.176/24 brd 192.168.117.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::5f4b:75e6:eba:1c36/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:4a:71:91 brd ff:ff:ff:ff:ff:ff 4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:ec:a2:10 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:ec:a2:10 brd ff:ff:ff:ff:ff:ff
RAC2服务器网络配置
[root@rac2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=1ebeae4b-53a0-4433-829f-903c62c70c8e DEVICE=ens33 ONBOOT=yes IPADDR=192.168.117.177 PREFIX=24 GATEWAY=192.168.117.2 DNS1=192.168.117.2 IPV6_PRIVACY=no
[root@rac2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens34 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens34 UUID=d2c1fc8f-63cb-4b93-9df5-c102d2a359a7 DEVICE=ens34 ONBOOT=yes IPADDR=192.168.3.177 PREFIX=24 GATEWAY=192.168.3.2 IPV6_PRIVACY=no
运行ip a查看ip配置
[root@rac2 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:f6:c9:5b brd ff:ff:ff:ff:ff:ff inet 192.168.117.177/24 brd 192.168.117.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::9284:845f:3373:e4c6/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:f6:c9:65 brd ff:ff:ff:ff:ff:ff inet 192.168.3.177/24 brd 192.168.3.255 scope global noprefixroute ens34 valid_lft forever preferred_lft forever inet6 fe80::ad0f:fb79:21cc:fc14/64 scope link noprefixroute valid_lft forever preferred_lft forever 4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:38:c1:79 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:38:c1:79 brd ff:ff:ff:ff:ff:ff
如果没生效可以重启网路服务或者直接重启
1.5、配置主机解析
一般rac需要配置dns解析,这里为了方便,我们直接把ip和主机名写到hosts文件里,使两台主机可以使用主机名互相通信
rac1主机配置
[root@rac1 ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.117.176 rac1
192.168.117.177 rac2
192.168.117.178 rac1-vip
192.168.117.179 rac2-vip
192.168.3.176 rac1-priv
192.168.3.177 rac2-priv
192.168.117.180 rac-scan
rac2主机配置
[root@rac2 ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.117.176 rac1
192.168.117.177 rac2
192.168.117.178 rac1-vip
192.168.117.179 rac2-vip
192.168.3.176 rac1-priv
192.168.3.177 rac2-priv
192.168.117.180 rac-scan
其实rac2主机配置可以直接把rac1的hosts文件用scp复制过去,为了直观一点,我就没用
1.6、关闭防火墙和selinux
两台服务器都要配置
rac1
[root@rac1 ~]# systemctl disable --now firewalld #设置防火墙开机不自动启动并关闭防火墙
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@rac1 ~]# vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #禁用selinux
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
rac2
[root@rac2 ~]# systemctl disable --now firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@rac2 ~]# vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
设置完重启一下,selinux才会生效
1.7、设置yum源和安装依赖
我是用本地虚拟机搭建了一个网络yum源,不会自己搭建可以用网上的清华阿里源
rac1
[root@rac1 ~]# vim /etc/yum.repos.d/bendi.repo
[bendi]
name=bendi
baseurl=http://192.168.117.156/yum/redhat7/
enabled=1
gpgcheck=0
rac2
[root@rac2 ~]# vim /etc/yum.repos.d/bendi.repo
[name]
name=bendi
baseurl=http://192.168.117.156/yum/redhat7/
enabled=1
gpgcheck=0
这里我建议在添加一个epel的扩展源
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
这样基本上就不会缺依赖了,但是还会缺一个依赖,我贴一下安装方法
yum -y install http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
安装依赖
需要安装的依赖
yum install -y binutils
yum install -y compat-libcap1
yum install -y compat-libstdc++-33
yum install -y compat-libstdc++-33.i686
yum install -y gcc
yum install -y gcc-c++
yum install -y glibc
yum install -y glibc.i686
yum install -y glibc-devel
yum install -y glibc-devel.i686
yum install -y ksh
yum install -y libgcc
yum install -y libgcc.i686
yum install -y libstdc++
yum install -y libstdc++.i686
yum install -y libstdc++-devel
yum install -y libstdc++-devel.i686
yum install -y libaio
yum install -y libaio.i686
yum install -y libaio-devel
yum install -y libaio-devel.i686
yum install -y libXext
yum install -y libXext.i686
yum install -y libXtst
yum install -y libXtst.i686
yum install -y libX11
yum install -y libX11.i686
yum install -y libXau
yum install -y libXau.i686
yum install -y libxcb
yum install -y libxcb.i686
yum install -y libXi
yum install -y libXi.i686
yum install -y make
yum install -y sysstat
yum install -y unixODBC
yum install -y unixODBC-devel
yum install -y readline
yum install -y libtermcap-devel
yum install -y bc
yum install -y compat-libstdc++
yum install -y elfutils-libelf
yum install -y elfutils-libelf-devel
yum install -y fontconfig-devel
yum install -y libXi
yum install -y libXtst
yum install -y libXrender
yum install -y libXrender-devel
yum install -y libgcc
yum install -y librdmacm-devel
yum install -y libstdc++
yum install -y libstdc++-devel
yum install -y net-tools
yum install -y nfs-utils
yum install -y python
yum install -y python-configshell
yum install -y python-rtslib
yum install -y python-six
yum install -y targetcli
yum install -y smartmontools
yum -y install http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
具体细节我就不贴了,太长了,两台服务器都需要安装
1.8、创建grid、oracle用户和需要的组和目录
创建用户 两台服务器都要运行
groupadd -g 11001 oinstall
groupadd -g 11002 dba
groupadd -g 11003 oper
groupadd -g 11004 backupdba
groupadd -g 11005 dgdba
groupadd -g 11006 kmdba
groupadd -g 11007 asmdba
groupadd -g 11008 asmoper
groupadd -g 11009 asmadmin
groupadd -g 11010 racdba
useradd -u 11011 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper oracle
useradd -u 11012 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
mkdir -p /u01/app/19.0.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/product/19.0.0/db_1
mkdir -p /u01/app/oraInventory
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/19.0.0/grid
chown -R oracle:oinstall /u01/app/oracle
chown -R grid:oinstall /u01/app/oraInventory
chmod -R 775 /u01/
为创建的用户设置密码
1.9、调整内核参数
两台都要改
vim /etc/security/limits.d/20-nproc.conf
# Change this
#注释这行* soft nproc 4096
# To this 增加下面一行
* - nproc 16384
如果内存够大就可以不用改
vim /etc/security/limits.conf
#ORACLE SETTING
grid soft nproc 16384
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 4194304
oracle soft memlock 4194304
##memlock 这个值还是应该比内存配置略小,也就是要配置的足够大。单位:k
##4194304 表示 4G
[root@rac2 ~]# vim /etc/sysconfig/network #两台都要配置
# Created by anaconda
NOZEROCONF=yes
关闭avahi-daemon
两台都要配置
[root@rac2 ~]# systemctl disable --now avahi-daemon.service
Removed symlink /etc/systemd/system/multi-user.target.wants/avahi-daemon.service.
Removed symlink /etc/systemd/system/sockets.target.wants/avahi-daemon.socket.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.Avahi.service.
Warning: Stopping avahi-daemon.service, but it can still be activated by:
avahi-daemon.socket
[root@rac2 ~]# systemctl stop avahi-daemon.socket
[root@rac2 ~]#
vim /etc/pam.d/login
#ORACLE SETTING
session required pam_limits.so
vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 18446744073692774399
kernel.shmmax = 18446744073692774399
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
配置swap空间,swap空间小于8G会报警,所以我们设置一下,两台都要配置
[root@rac1 ~]# mkdir /swap&&
> dd if=/dev/zero of=/swap/mySwap bs=1M count=8192&&
> mkswap /swap/mySwap&&
> swapon /swap/mySwap&&
> sed -i '$a /swap/mySwap swap swap default 0 0' /etc/fstab
记录了8192+0 的读入
记录了8192+0 的写出
8589934592字节(8.6 GB)已复制,29.394 秒,292 MB/秒
正在设置交换空间版本 1,大小 = 8388604 KiB
无标签,UUID=b03a662a-16c8-4707-892d-f7595fbfd878
swapon: /swap/mySwap:不安全的权限 0644,建议使用 0600。
[root@rac1 ~]# free -h
total used free shared buff/cache available
Mem: 7.6G 474M 139M 12M 7.0G 6.8G
Swap: 9G 0B 9G
[root@rac1 ~]#
修改profile
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
修改环境变量
grid环境变量
cat /home/grid/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
#PATH=$PATH:$HOME/.local/bin:$HOME/bin
#export PATH
export ORACLE_SID=+ASM1; 二节点为+ASM2
export ORACLE_BASE=/u01/app/grid;
export ORACLE_HOME=/u01/app/19.0.0/grid;
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS";
export PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
Oracle环境变量
cat /home/oracle/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
#PATH=$PATH:$HOME/.local/bin:$HOME/bin
#export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/db_1
export ORACLE_SID=ORCL1 二节点为ORCL2
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
1.10、配置共享磁盘
通过iSCSI配置共享磁盘并配置多路径
[root@rac1 ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.1994-05.com.redhat:bdb31eaaa22f [root@rac1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.117.14 iscsiadm: cannot make connection to 192.168.117.14: No route to host ^Ciscsiadm: caught SIGINT, exiting... [root@rac1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.117.146 192.168.117.146:3260,1 iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target 192.168.3.146:3260,1 iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target 192.168.4.146:3260,1 iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target [root@rac1 ~]# iscsiadm -m node -l Logging in to [iface: default, target: iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target, portal: 192.168.117.146,3260] (multiple) Logging in to [iface: default, target: iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target, portal: 192.168.3.146,3260] (multiple) Logging in to [iface: default, target: iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target, portal: 192.168.4.146,3260] (multiple) Login to [iface: default, target: iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target, portal: 192.168.117.146,3260] successful. Login to [iface: default, target: iqn.1991-05.com.microsoft:win-3qb2jj1g5dr-redhatrac-target, portal: 192.168.3.146,3260] successful. ^Ciscsiadm: caught SIGINT, exiting... [root@rac1 ~]# fdisk -l
运行cat /etc/iscsi/initiatorname.iscsi查看设备的IQN,在iscsi服务端添加iSCSI硬盘,然后通过iscsiadm命令添加硬盘。两台服务器都要运行,命令一样。因为192.168.4段IP这两台服务器上没有,会连接超时不用管他
然后运行fdisk -l会发现多了四块硬盘,这时候我们就需要配置多路径了
运行multipath会提示没有配置文件,运行cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/multipath.conf把配置文件复制到etc目录,两台服务器都要运行
如果没有配置多路径就没有这么麻烦,直接用sdc和sdd直接配置udev就可以了
[root@rac1 ~]# multipath
Jun 14 11:15:42 | DM multipath kernel driver not loaded
Jun 14 11:15:42 | /etc/multipath.conf does not exist, blacklisting all devices.
Jun 14 11:15:42 | A default multipath.conf file is located at
Jun 14 11:15:42 | /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
Jun 14 11:15:42 | You can run /sbin/mpathconf to create or modify /etc/multipath.conf
Jun 14 11:15:42 | DM multipath kernel driver not loaded
[root@rac1 ~]# /sbin/mpathconf
multipath is enabled
find_multipaths is enabled
user_friendly_names is enabled
dm_multipath module is not loaded
multipathd is not running
[root@rac1 ~]# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/multipath.conf
[root@rac1 ~]#
然后重启multipathd服务,运行fdisk -l就看到/dev/mapper/下的两块硬盘,我这里已经把磁盘别名改了,显示的是ocr和data实际应该是mpatha和mpathb
修改磁盘别名的操作如下
[root@rac2 ~]# vim /etc/multipath.conf # } # device { # vendor "COMPAQ " # product "MSA1000 " # path_grouping_policy multibus # } #} multipaths { multipath { wwid 360003ff44dc75adca98e3b9dbd6e1d08 alias ocr } multipath { wwid 360003ff44dc75adc9b48fb605fd50284 alias data } }
然后运行如下命令
RESULT==\"`/lib/udev/scsi_id -g -u -d /dev/mapper/ocr`\",SYMLINK+=\"mapper/asm-diska\", OWNER=\"grid\", GROUP=\"asmadmin\"
解释一下/dev/mapper/ocr,是硬盘的路径,asm-diska是做的快捷方式,所属用户是grid用户组asmadmin,权限0660
[root@rac2 ~]# echo "ENV{DEVTYPE}==\"disk\", SUBSYSTEM==\"block\",PROGRAM==\"/lib/udev/scsi_id -g -u -d \$devnode\",RESULT==\"`/lib/udev/scsi_id -g -u -d /dev/mapper/ocr`\",SYMLINK+=\"mapper/asm-diska\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules
[root@rac2 ~]# echo "ENV{DEVTYPE}==\"disk\", SUBSYSTEM==\"block\",PROGRAM==\"/lib/udev/scsi_id -g -u -d \$devnode\",RESULT==\"`/lib/udev/scsi_id -g -u -d /dev/mapper/data`\",SYMLINK+=\"mapper/asm-diskb\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules
[root@rac2 ~]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",PROGRAM=="/lib/udev/scsi_id -g -u -d $devnode",RESULT=="360003ff44dc75adca98e3b9dbd6e1d08",SYMLINK+="mapper/asm-diska", OWNER="grid", GROUP="asmadmin", MODE="0660"
ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",PROGRAM=="/lib/udev/scsi_id -g -u -d $devnode",RESULT=="360003ff44dc75adc9b48fb605fd50284",SYMLINK+="mapper/asm-diskb", OWNER="grid", GROUP="asmadmin", MODE="0660"
[root@rac2 ~]#
重新加载 udev rule
/sbin/udevadm control --reload-rules
检查新的设备名称
www.vinchin.com | partner@vinchin.com 11
/sbin/udevadm trigger --type=devices --action=change
ll -l /dev/asm*
也可以直接重启
1.11、配置主机之间ssh免密钥登录,两台主机都要配置
如果不想登陆的时候确认可以关闭密钥验证
ssh免密钥登录设置如下,两台主机四个用户都要做互相之间的免密钥
[grid@rac1 ~]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/grid/.ssh/id_rsa): 回车 Created directory '/home/grid/.ssh'. Enter passphrase (empty for no passphrase): 回车 Enter same passphrase again: 回车 Your identification has been saved in /home/grid/.ssh/id_rsa. Your public key has been saved in /home/grid/.ssh/id_rsa.pub. The key fingerprint is: SHA256:2SRGq3baPlZRaq80mebga0zUYIUMa3Plj3rXTuVS3KM grid@rac1 The key's randomart image is: +---[RSA 2048]----+ | .o.oo | | o=+ . | | +.=ooo | | . =.==o ..| | o.S.o=. .=| | . +o.B ...+.| | .+o*.o.E+ .| | .*.o. o . | | ooo . | +----[SHA256]-----+ [grid@rac1 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub grid@rac2 /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/grid/.ssh/id_rsa.pub" /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys grid@rac2's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'grid@rac2'" and check to make sure that only the key(s) you wanted were added. [grid@rac1 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub oracle@rac2 /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/grid/.ssh/id_rsa.pub" /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys oracle@rac2's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'oracle@rac2'" and check to make sure that only the key(s) you wanted were added. [grid@rac1 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub oracle@rac1 /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/grid/.ssh/id_rsa.pub" /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys oracle@rac1's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'oracle@rac1'" and check to make sure that only the key(s) you wanted were added. [grid@rac1 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub grid@rac1 /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/grid/.ssh/id_rsa.pub" /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys grid@rac1's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'grid@rac1'" and check to make sure that only the key(s) you wanted were added.
二、安装grid,只需要在一台主机上安装
2.1、 上传软件包并解压
把安装包解压到grid用户的家目录下
解压完之后安装cvuqdisk,在解压之后的cv/rpm目录下,要用root用户或者sudo权限
2.2、进入执行目录安装GI
执行gridSetup.sh
scan名称填hosts里设置的scan名
口令要求有大小写和数字
运行root脚本,也可以选择安装过程中手动运行
检查环境
dns后期会报错,忽略就行了
等一会,执行root脚本
安装完成,运行crsctl stat res -t,查看集群状态,可以看到scanip在rac2上
2.2、以oracle用户登录图形化界面,安装oracle程序
首先上传oracle安装文件到服务器上并解压到cd /u01/app/oracle/product/19.0.0/db_1/
执行./runInstaller
[oracle@rac1 db_1]$ ./runInstaller
选择仅设置软件
选择RAC安装
两个节点都选择
这里也可以选择让他自动运行脚本
这几个警告都可以忽略掉
分别在两个节点执行root.sh脚本
好了,oracle程序安装完成了
2.3、创建asm磁盘
启动asmca,看到两个实例都启动了
选择磁盘组,点击创建
设置磁盘名为DATA然后点击确定
完事
2.4、建立数据库
以oracle用户登录,执行dbca
容器数据库可以按需开启
开启归档模式,省得以后再开启
临时决定要开启归档,写一下设置方法,在u01/app/目录下创建archiving目录,给775的权限,两台都要运行
[root@rac2 ~]# mkdir /u01/app/archiving
[root@rac2 ~]# chmod -R 775 /u01/app/archiving/
基本上保持默认就可以了
设置口令
然后就安装完成了,忘了截图了
发表评论