本文主要是介绍1.双机热备软件pacemaker的应用之oracle,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 前言
- 一、环境规划
- 二、安装步骤
- 1.添加两个网络适配器,配置IP:
- 2.配置共享磁盘
- 3.安装oracle数据库
- 4.安装PCS
前言
一、环境规划
192.168.56.104 mlb01
192.168.56.105 mlb02
192.168.56.106 mlb-office-vip
10.10.10.1 mlb01-A
10.10.10.2 mlb01-B
二、安装步骤
1.添加两个网络适配器,配置IP:
两个节点都需要操作
(1)仅主机模式
(2)nat模式
vim /etc/hosts
192.168.56.104 mlb01
192.168.56.105 mlb02
192.168.56.106 mlb-office-vip10.10.10.1 mlb01-A
10.10.10.2 mlb01-B
[root@mlb01 network-scripts]# vim ifcfg-ens33TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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=9ae43283-7d3f-4788-9226-38820adcafaa
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.56.104
NETMASK=255.255.255.0
GATEWAY=192.168.56.2
[root@mlb01 network-scripts]# vim ifcfg-ens34TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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
DEVICE=ens34
ONBOOT=yes
IPADDR=10.10.10.1
NETMASK=255.255.255.0
GATEWAY=10.10.10.254
2.配置共享磁盘
添加共享磁盘规划
oggdata 50G
archlog 50G
oradata01 50G
oradata02 50G
mlb01节点添加磁盘:
mlb02节点使用现用磁盘就OK
修改两台虚拟机下的.vmx文件,添加以下内容:
disk.locking="FALSE"
scsi0:3.SharedBus = "Virtual"
scsi0:4.SharedBus = "Virtual"
scsi0:2.SharedBus = "Virtual"
scsi0:1.SharedBus = "Virtual"scsi0:3.shared = "TRUE"
scsi0:4.shared = "TRUE"
scsi0:2.shared = "TRUE"
scsi0:1.shared = "TRUE"
查询两个节点添加的共享磁盘
[root@mlb01 ~]# fdisk -lDisk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c6cc3Device Boot Start End Blocks Id System
/dev/sda1 * 2048 514047 256000 83 Linux
/dev/sda2 514048 209715199 104600576 8e Linux LVMDisk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sdc: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sdd: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sde: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-root: 105.0 GB, 104962457600 bytes, 205004800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/loop0: 4781 MB, 4781506560 bytes, 9338880 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x26065fedDevice Boot Start End Blocks Id System
/dev/loop0p1 * 0 9338879 4669440 0 Empty
/dev/loop0p2 2424 19831 8704 ef EFI (FAT-12/16/32)
[root@mlb01 ~]#
两台节点都要添加目录和赋权:
mkdir -p /oggdata
mkdir -p /archlog
mkdir -p /oradata01
mkdir -p /oradata02chown -R oracle:dba /oggdata
chown -R oracle:dba /archlog
chown -R oracle:dba /oradata01
chown -R oracle:dba /oradata02在一个节点执行即可:
pvcreate /dev/sdb1
vgcreate oradata01_vg /dev/sdb1
lvcreate -l 100%VG -n oradata01_lv oradata01_vg
mkfs -t ext4 /dev/oradata01_vg/oradata01_lv
chmod -R 775 /oradata01
mount /dev/oradata01_vg/oradata01_lv /oradata01pvcreate /dev/sdc1
vgcreate oradata02_vg /dev/sdc1
lvcreate -l 100%VG -n oradata02_lv oradata02_vg
mkfs -t ext4 /dev/oradata02_vg/oradata02_lv
chmod -R 775 /oradata02
mount /dev/oradata02_vg/oradata02_lv /oradata02pvcreate /dev/sdd1
vgcreate archlog_vg /dev/sdd1
lvcreate -l 100%VG -n archlog_lv archlog_vg
mkfs -t ext4 /dev/archlog_vg/archlog_lv
chmod -R 775 /archlog
mount /dev/archlog_vg/archlog_lv /archlogpvcreate /dev/sde1
vgcreate oggdata_vg /dev/sde1
lvcreate -l 100%VG -n oggdata_lv oggdata_vg
mkfs -t ext4 /dev/oggdata_vg/oggdata_lv
chmod -R 775 /oggdata
mount /dev/oggdata_vg/oggdata_lv /oggdata两台节点都要执行这个命令:
partprobe
独占启用集群中的lvm(各节点配置)#修改 /etc/lvm/lvm.conf中locking_type为1,且use_lvmetad为0.同时停用lvmetad程序
lvmconf --enable-halvm --services --startstopservices#在 /etc/lvm/lvm.conf修改volume_list配置(不受集群管控的lvm,比如你本地的root相关的lvm)
volume_list = [ "centos" ]
3.安装oracle数据库
配置数据库环境变量
su - oracle
vim ~/.bash_profile
unset USERNAME
export TMP=/tmp
export ORACLE_BASE=/oracle
export ORACLE_UNQNAME=mlbdb1
export ORACLE_HOME=$ORACLE_BASE/11204
export ORACLE_SID=mlbdb1
#export GGATE=/oggdata/ogg
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS10=$ORACLE_HOME/nls/data
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$GGATE:$ORACLE_HOME/srvm/lib:/lib:/usr/lib:/usr/openwin/lib:/usr/local/lib
export JAVA_HOME=$ORACLE_BASE/jre/1.4.2
export JAVA_BINDIR=$JAVA_HOME/bin
export SDK_HOME=$JAVA_HOME
export JDK_HOME=$JAVA_HOME
export PATH=$ORACLE_HOME/bin:$PATH:$GGATE:$ORACLE_HOME/OPatch
export ORACLE_HOSTNAME=mlb-office-vip
#export NLS_LANG='TRADITIONAL CHINESE_TAIWAN'.AL32UTF8
export THREADS_FLAG=native
export OH=$ORACLE_HOME
export OCM=$ORACLE_HOME/oracm
#export LD_ASSUME_KERNEL=2.4.21
#export LD_ASSUME_KERNEL=2.4.18
#alias rman='rlwrap rman'
#alias sqlplus='rlwrap sqlplus'
#alias ftp='rlwrap ftp'
#alias ggsci='rlwrap ggsci'
#export TERM=vt100
#export AGTCTL_ADMIN=$ORACLE_HOME/network/agent/config
umask 022使用dbca安装数据库
dbca开启归档
修改成归档模式
SQL> alter system set log_archive_dest_1='location=/archlog/mlbdb1' scope=spfile;
SQL> alter system set log_archive_format='mlbdb1_%t_%s_%r.dbf' scope=spfile;SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 1
SQL>shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
archive log list;SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /archlog/mlbdb1
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL>配置静态监听
[oracle@mlb01 admin]$ cat listener.ora
SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(SID_NAME = PLSExtProc)(ORACLE_HOME = /oracle/11204)(PROGRAM = extproc))(SID_DESC =(GLOBAL_DBNAME = mlbdb1)(ORACLE_HOME = /oracle/11204)(SID_NAME = mlbdb1))))LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.104)(PORT = 1526))(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))))ADR_BASE_LISTENER = /oracle配置tns
[oracle@mlb01 admin]$ cat tnsnames.ora
mlbdb1 =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.104)(PORT = 1526)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = mlbdb1)))
[oracle@mlb01 admin]$
scp listener.ora oracle@192.168.56.105:/oracle/11204/network/admin/
scp tnsnames.ora oracle@192.168.56.105:/oracle/11204/network/admin/cd /oracle/11204/dbs
scp * oracle@192.168.56.105:/oracle/11204/dbs/cd /oracle/
scp -r admin oracle@192.168.56.105:/oracle/
strings /oracle/11204/dbs/spfilemlbdb1.ora
4.安装PCS
(1)各节点安装HA软件:
yum install -y pcs fence-agents-all(2)各节点关闭防火墙及selinux
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
systemctl status NetworkManager.service(3)各节点设置hacluster用户密码(保持一样)
echo "********"|passwd --stdin hacluster[root@ha1 yum.repos.d]# passwd hacluster
Changing password for user hacluster.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.(4)各节点启用pcsd服务并开启自启动
systemctl start pcsd.service
systemctl enable pcsd.service
systemctl status pcsd.service(5)确认集群用户
pcs cluster auth mlb01-A mlb01-B -u hacluster -p ********[root@mlb01 ~]# pcs cluster auth mlb01-A mlb01-B -u hacluster -p ********
mlb01-B: Authorized
mlb01-A: Authorized
[root@mlb01 ~]# [root@mlb02 ~]# pcs cluster auth mlb01-A mlb01-B -u hacluster -p ********
mlb01-B: Authorized
mlb01-A: Authorized
[root@mlb02 ~]# (6)创建集群及查看状态
pcs cluster setup --start --name mlb_cluster mlb01-A mlb01-B[root@mlb01 ~]# pcs cluster setup --start --name mlb_cluster mlb01-A mlb01-B
Destroying cluster on nodes: mlb01-A, mlb01-B...
mlb01-A: Stopping Cluster (pacemaker)...
mlb01-B: Stopping Cluster (pacemaker)...
mlb01-B: Successfully destroyed cluster
mlb01-A: Successfully destroyed clusterSending 'pacemaker_remote authkey' to 'mlb01-A', 'mlb01-B'
mlb01-A: successful distribution of the file 'pacemaker_remote authkey'
mlb01-B: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
mlb01-A: Succeeded
mlb01-B: SucceededStarting cluster on nodes: mlb01-A, mlb01-B...
mlb01-A: Starting Cluster (corosync)...
mlb01-B: Starting Cluster (corosync)...
mlb01-B: Starting Cluster (pacemaker)...
mlb01-A: Starting Cluster (pacemaker)...Synchronizing pcsd certificates on nodes mlb01-A, mlb01-B...
mlb01-B: Success
mlb01-A: Success
Restarting pcsd on the nodes in order to reload the certificates...
mlb01-B: Success
mlb01-A: Success
[root@mlb01 ~]# [root@mlb01 ~]# pcs status
Cluster name: mlb_clusterWARNINGS:
No stonith devices and stonith-enabled is not falseStack: corosync
Current DC: mlb01-B (version 1.1.21-4.el7-f14e36fd43) - partition with quorum
Last updated: Sat Dec 4 21:43:14 2021
Last change: Sat Dec 4 20:05:49 2021 by hacluster via crmd on mlb01-A2 nodes configured
0 resources configuredOnline: [ mlb01-A mlb01-B ]No resourcesDaemon Status:corosync: active/disabledpacemaker: active/disabledpcsd: active/enabled
[root@mlb01 ~]# (7)隔离配置(生产环境加上隔离相关配置,防止其中某节点hang住的情况):
pcs property set stonith-enabled=false此时再检查就不会检查stoith设备了
crm_verify -L -V(8)独占启用集群中的lvm(各节点配置)
#修改 /etc/lvm/lvm.conf中locking_type为1,且use_lvmetad为0.同时停用lvmetad程序
lvmconf --enable-halvm --services --startstopservices#在 /etc/lvm/lvm.conf修改volume_list配置(不受集群管控的lvm,比如你本地的root相关的lvm)
volume_list = [ "centos" ](9)重建initramfs(各节点配置),重启节点
[root@ha1 yum.repos.d]# dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
[root@ha1 yum.repos.d]# reboot
[root@ha2 yum.repos.d]# dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
[root@ha2 yum.repos.d]# reboot查看集群状态
pcs cluster status(10)创建lvm、文件系统资源
pcs resource create lv-oradata01 LVM volgrpname=oradata01_vg exclusive=yes op monitor interval=10s
pcs resource create lv-oradata02 LVM volgrpname=oradata02_vg exclusive=yes op monitor interval=10s
pcs resource create lv-archlog LVM volgrpname=archlog_vg exclusive=yes op monitor interval=10s
pcs resource create lv-oggdata LVM volgrpname=oggdata_vg exclusive=yes op monitor interval=10spcs resource create fs-oradata01 ocf:heartbeat:Filesystem device="/dev/oradata01_vg/oradata01_lv" directory=/oradata01 fstype=ext4 op stop timeout=120s
pcs resource create fs-oradata02 ocf:heartbeat:Filesystem device="/dev/oradata02_vg/oradata02_lv" directory=/oradata02 fstype=ext4 op stop timeout=120s
pcs resource create fs-archlog ocf:heartbeat:Filesystem device="/dev/archlog_vg/archlog_lv" directory=/archlog fstype=ext4 op stop timeout=120s
pcs resource create fs-oggdata ocf:heartbeat:Filesystem device="/dev/oggdata_vg/oggdata_lv" directory=/oggdata fstype=ext4 op stop timeout=120s(11)创建vip资源、数据库、监听资源
pcs resource create mlb-office-vip ocf:heartbeat:IPaddr2 ip=192.168.56.106 nic=ens33 cidr_netmask=24 iflabel=0
pcs resource create mlb-db ocf:heartbeat:oracle sid=mlbdb1 home="/oracle/11204" user=oracle op stop timeout=180s
pcs resource create mlb-listener ocf:heartbeat:oralsnr sid=mlbdb1 home="/oracle/11204" user=oracle tns_admin="/oracle/11204/network/admin"(12)将资源捆绑到资源组防止资源不在一个节点上
pcs resource group add mlb-group lv-oradata01 lv-oradata02 lv-archlog lv-oggdata fs-oradata01 fs-oradata02 fs-archlog fs-oggdata mlb-office-vip mlb-db mlb-listener pcs resource group add mlb-group lv-archlog --before lv-oggdata
pcs resource group add mlb-group fs-archlog --before fs-oggdata
pcs resource group add mlb-group mlb-db --before mlb-listener
pcs resource group add mlb-group mlb-listener(13)单独启动各资源
pcs resource enable fs-oradata01
pcs resource enable fs-oradata02
pcs resource enable fs-archlog
pcs resource enable fs-oggdata
pcs resource enable mlb-office-vip
pcs resource enable mlb-db
pcs resource enable mlb-listener
这篇关于1.双机热备软件pacemaker的应用之oracle的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!