1.双机热备软件pacemaker的应用之oracle

2023-10-22 05:11

本文主要是介绍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的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/259241

相关文章

Oracle的to_date()函数详解

《Oracle的to_date()函数详解》Oracle的to_date()函数用于日期格式转换,需要注意Oracle中不区分大小写的MM和mm格式代码,应使用mi代替分钟,此外,Oracle还支持毫... 目录oracle的to_date()函数一.在使用Oracle的to_date函数来做日期转换二.日

在Ubuntu上部署SpringBoot应用的操作步骤

《在Ubuntu上部署SpringBoot应用的操作步骤》随着云计算和容器化技术的普及,Linux服务器已成为部署Web应用程序的主流平台之一,Java作为一种跨平台的编程语言,具有广泛的应用场景,本... 目录一、部署准备二、安装 Java 环境1. 安装 JDK2. 验证 Java 安装三、安装 mys

oracle数据库索引失效的问题及解决

《oracle数据库索引失效的问题及解决》本文总结了在Oracle数据库中索引失效的一些常见场景,包括使用isnull、isnotnull、!=、、、函数处理、like前置%查询以及范围索引和等值索引... 目录oracle数据库索引失效问题场景环境索引失效情况及验证结论一结论二结论三结论四结论五总结ora

Python中构建终端应用界面利器Blessed模块的使用

《Python中构建终端应用界面利器Blessed模块的使用》Blessed库作为一个轻量级且功能强大的解决方案,开始在开发者中赢得口碑,今天,我们就一起来探索一下它是如何让终端UI开发变得轻松而高... 目录一、安装与配置:简单、快速、无障碍二、基本功能:从彩色文本到动态交互1. 显示基本内容2. 创建链

Oracle Expdp按条件导出指定表数据的方法实例

《OracleExpdp按条件导出指定表数据的方法实例》:本文主要介绍Oracle的expdp数据泵方式导出特定机构和时间范围的数据,并通过parfile文件进行条件限制和配置,文中通过代码介绍... 目录1.场景描述 2.方案分析3.实验验证 3.1 parfile文件3.2 expdp命令导出4.总结

Node.js 中 http 模块的深度剖析与实战应用小结

《Node.js中http模块的深度剖析与实战应用小结》本文详细介绍了Node.js中的http模块,从创建HTTP服务器、处理请求与响应,到获取请求参数,每个环节都通过代码示例进行解析,旨在帮... 目录Node.js 中 http 模块的深度剖析与实战应用一、引言二、创建 HTTP 服务器:基石搭建(一

java中VO PO DTO POJO BO DO对象的应用场景及使用方式

《java中VOPODTOPOJOBODO对象的应用场景及使用方式》文章介绍了Java开发中常用的几种对象类型及其应用场景,包括VO、PO、DTO、POJO、BO和DO等,并通过示例说明了它... 目录Java中VO PO DTO POJO BO DO对象的应用VO (View Object) - 视图对象

Ubuntu 怎么启用 Universe 和 Multiverse 软件源?

《Ubuntu怎么启用Universe和Multiverse软件源?》在Ubuntu中,软件源是用于获取和安装软件的服务器,通过设置和管理软件源,您可以确保系统能够从可靠的来源获取最新的软件... Ubuntu 是一款广受认可且声誉良好的开源操作系统,允许用户通过其庞大的软件包来定制和增强计算体验。这些软件

Go信号处理如何优雅地关闭你的应用

《Go信号处理如何优雅地关闭你的应用》Go中的优雅关闭机制使得在应用程序接收到终止信号时,能够进行平滑的资源清理,通过使用context来管理goroutine的生命周期,结合signal... 目录1. 什么是信号处理?2. 如何优雅地关闭 Go 应用?3. 代码实现3.1 基本的信号捕获和优雅关闭3.2

正则表达式高级应用与性能优化记录

《正则表达式高级应用与性能优化记录》本文介绍了正则表达式的高级应用和性能优化技巧,包括文本拆分、合并、XML/HTML解析、数据分析、以及性能优化方法,通过这些技巧,可以更高效地利用正则表达式进行复杂... 目录第6章:正则表达式的高级应用6.1 模式匹配与文本处理6.1.1 文本拆分6.1.2 文本合并6