HGDB HA with ISCSI
1、基础环境 vip(虚拟IP):192.168.100.222 iscsi(存储):192.168.100.200 node1(节点一):192.168.100.192 node2(节点二):192.168.100.195 新建highgo操作系统用户,要求三台机器highgo用户的uid、gid相同 2、三台机器均关闭防火墙和SELINUX (以n
1、基础环境
<code> vip(虚拟IP):192.168.100.222 iscsi(存储):192.168.100.200 node1(节点一):192.168.100.192 node2(节点二):192.168.100.195 新建highgo操作系统用户,要求三台机器highgo用户的uid、gid相同 </code>
2、三台机器均关闭防火墙和SELINUX (以node1为例)
3、三台机器均SSH互信 (以iscsi为例)
(1)修改/etc/hosts
(2)root用户执行
(3)highgo用户执行
4、ISCSI配置
(1)服务器端(iscsi)
<code class=" hljs lasso"><span class="hljs-subst">>>></span>首先安装scsi<span class="hljs-attribute">-target</span><span class="hljs-attribute">-utils</span>: yum <span class="hljs-attribute">-y</span> install scsi<span class="hljs-attribute">-target</span><span class="hljs-attribute">-utils</span> <span class="hljs-subst">>>></span>编辑/etc/tgt/targets<span class="hljs-built_in">.</span>conf,添加:(/dev/sda是新添加的用来共享的磁盘,为原生的未经过格式化的盘) <span class="hljs-subst"><</span>target iqn<span class="hljs-number">.201605</span><span class="hljs-built_in">.</span>dev:server<span class="hljs-built_in">.</span>target1<span class="hljs-subst">></span> backing<span class="hljs-attribute">-store</span> /dev/sda <span class="hljs-subst"><</span>/target<span class="hljs-subst">></span> <span class="hljs-subst">>>></span>启动服务,并配置开机自启动: service tgtd start chkconfig tgtd <span class="hljs-keyword">on</span></code>
(2)客户端(node1、node2)
<code class=" hljs lasso"><span class="hljs-subst">>>></span>首先安装iscsi<span class="hljs-attribute">-initiator</span><span class="hljs-attribute">-utils</span> yum <span class="hljs-attribute">-y</span> install iscsi<span class="hljs-attribute">-initiator</span><span class="hljs-attribute">-utils</span> <span class="hljs-subst">>>></span>编辑/etc/iscsi/initiatorname<span class="hljs-built_in">.</span>iscsi,添加: InitiatorName<span class="hljs-subst">=</span>iqn<span class="hljs-number">.201605</span><span class="hljs-built_in">.</span>dev:server<span class="hljs-built_in">.</span>target1 <span class="hljs-subst">>>></span>配置服务: chkconfig iscsi <span class="hljs-keyword">on</span> chkconfig iscsid <span class="hljs-keyword">on</span> service iscsi restart service iscsid restart</code>
启动服务时出现失败的情况,正常
5、安装数据库(node1、node2)
node1安装过程:
(1)创建目录(挂载点)
<code class=" hljs perl"><span class="hljs-keyword">mkdir</span> /install/hgdb -p</code>
(2)发现服务器端有磁盘共享,并登录
(3)查询本地多一块磁盘
(4)格式化磁盘并挂载
注意:若挂载时出现以下错误,即为没有格式化磁盘所致
(5)切换到highgo登录系统,执行安装
<code class=" hljs bash">>>>编辑.bash_profile,添加: <span class="hljs-keyword">export</span> HG_HOME=/home/highgo/hgdb</code>
注意:数据目录的选择,即将data目录置于共享磁盘中
(6)安装完成后,注销highgo,切换回root,执行关闭数据库服务、设置开机不自动启动数据库服务、卸载挂载的目录
<code class=" hljs vbnet">service hgdb-se2<span class="hljs-number">.0</span><span class="hljs-number">.4</span> <span class="hljs-keyword">stop</span> chkconfig hgdb-se2<span class="hljs-number">.0</span><span class="hljs-number">.4</span> <span class="hljs-keyword">off</span> umount /install/hgdb</code>
node2安装过程:
(1)创建目录(挂载点)
<code class=" hljs perl"><span class="hljs-keyword">mkdir</span> /install/hgdb -p</code>
(2)发现服务器端有磁盘共享,并登录
(3)挂载磁盘
注意:/dev/sdb为共享磁盘,在node1安装数据库时已经格式化并将data目录置于其下,此时只需要挂载即可看到data目录
(4)切换到highgo登录系统,执行安装
注意:不作为系统服务安装(这样安装时不会有data目录选项出现)
(5)注销highgo,切换回root,执行卸载挂载的目录
<code class=" hljs cmake">umount /<span class="hljs-keyword">install</span>/hgdb</code>
6、HA配置
(1)node1、node2安装
<code class=" hljs cmake">yum -y <span class="hljs-keyword">install</span> pacemaker corosync pcs</code>
(2)在一个节点配置文件,并将文件拷贝到另一节点(以node1为例)
<code class=" hljs ruby">密钥文件: corosync-keygen scp /etc/corosync/authkey root<span class="hljs-variable">@node1</span><span class="hljs-symbol">:/etc/corosync</span></code>
<code class=" hljs avrasm">corosync<span class="hljs-preprocessor">.conf</span>文件: cd /etc/corosync <span class="hljs-keyword">cp</span> corosync<span class="hljs-preprocessor">.conf</span><span class="hljs-preprocessor">.example</span> corosync<span class="hljs-preprocessor">.conf</span> vi corosync<span class="hljs-preprocessor">.conf</span></code>
<code class=" hljs bash">pacemaker服务启动脚本: <span class="hljs-built_in">cd</span> service.d vi pcmd</code>
<code class=" hljs vbnet">corosync、pacemaker服务启停: chkconfig corosync <span class="hljs-keyword">on</span> service corosync start chkcofig pacemaker <span class="hljs-keyword">off</span> servicepacemaker <span class="hljs-keyword">stop</span></code>
7、集群资源配置
<code class=" hljs sql">首先启动服务:service corosync <span class="hljs-operator"><span class="hljs-keyword">start</span> (node1、node2)</span></code>
查看集群状态:
在一个节点上完成资源的配置即可
<code class=" hljs lasso">任何情况集群资源继续运行 pcs property <span class="hljs-built_in">set</span> no<span class="hljs-attribute">-quorum</span><span class="hljs-attribute">-policy</span><span class="hljs-subst">=</span>ignore 禁用stonith pcs property <span class="hljs-built_in">set</span> stonith<span class="hljs-attribute">-enabled</span><span class="hljs-subst">=</span><span class="hljs-literal">false</span></code>
<code class=" hljs sql">配置vip pcs resource <span class="hljs-operator"><span class="hljs-keyword">create</span> vip ocf:heartbeat:IPaddr params ip=<span class="hljs-string">"192.168.100.222"</span> nic=<span class="hljs-string">"eth0"</span> cidr_netmask=<span class="hljs-string">"24"</span> op monitor <span class="hljs-keyword">interval</span>=<span class="hljs-number">20</span>s timeout=<span class="hljs-number">30</span>s</span></code>
查看集群状态
<code class=" hljs sql">配置sdisk(共享存储) pcs resource <span class="hljs-operator"><span class="hljs-keyword">create</span> sdisk ocf:heartbeat:Filesystem params device=<span class="hljs-string">"/dev/sdb"</span> directory=<span class="hljs-string">"/install/hgdb "</span> fstype=<span class="hljs-string">"ext4"</span> op <span class="hljs-keyword">start</span> timeout=<span class="hljs-number">60</span>s op stop timeout=<span class="hljs-number">60</span>s op monitor <span class="hljs-keyword">interval</span>=<span class="hljs-number">20</span>s timeout=<span class="hljs-number">60</span>s</span></code>
查看集群状态
<code class=" hljs sql">配置数据库服务 pcs resource <span class="hljs-operator"><span class="hljs-keyword">create</span> dbserver ocf:heartbeat:pgsql params pghost=<span class="hljs-number">192.168</span><span class="hljs-number">.100</span><span class="hljs-number">.222</span> pgport=<span class="hljs-number">5866</span> pgdba=highgo pgctl=/home/highgo/hgdb/bin/pg_ctl start_opt=<span class="hljs-string">"-D /install/hgdb/data"</span> psql=/home/highgo/hgdb/bin/psql pgdata=/install/hgdb/data monitor_user=highgo monitor_password=highgo123 op <span class="hljs-keyword">start</span> timeout=<span class="hljs-number">120</span>s <span class="hljs-keyword">interval</span>=<span class="hljs-number">120</span>s op stop timeout=<span class="hljs-number">120</span>s <span class="hljs-keyword">interval</span>=<span class="hljs-number">120</span>s op status timeout=<span class="hljs-number">60</span>s <span class="hljs-keyword">interval</span>=<span class="hljs-number">60</span>s</span></code>
<code class=" hljs oxygene">配置三个资源在一个组 pcs resource <span class="hljs-keyword">group</span> <span class="hljs-keyword">add</span> hgdb_group sdisk pcs resource <span class="hljs-keyword">group</span> <span class="hljs-keyword">add</span> hgdb_group vip pcs resource <span class="hljs-keyword">group</span> <span class="hljs-keyword">add</span> hgdb_group dbserver </code>
<code class=" hljs ocaml">配置资源在两节点中的优先级 pcs <span class="hljs-keyword">constraint</span> location sdisk prefers node1=<span class="hljs-number">50</span> pcs <span class="hljs-keyword">constraint</span> location sdisk prefers node2=<span class="hljs-number">40</span> pcs <span class="hljs-keyword">constraint</span> location vip prefers node1=<span class="hljs-number">50</span> pcs <span class="hljs-keyword">constraint</span> location vip prefers node2=<span class="hljs-number">40</span> pcs <span class="hljs-keyword">constraint</span> location dbserver prefers node1=<span class="hljs-number">50</span> pcs <span class="hljs-keyword">constraint</span> location dbserver prefers node2=<span class="hljs-number">40</span></code>
<code class=" hljs sql">配置资源在节点中的启动顺序 pcs constraint order <span class="hljs-operator"><span class="hljs-keyword">start</span> vip <span class="hljs-keyword">then</span> <span class="hljs-keyword">start</span> sdisk <span class="hljs-keyword">then</span> <span class="hljs-keyword">start</span> dbserver</span></code>
<code class=" hljs vbnet">配置psql文件(node1、node2) vi /usr/<span class="hljs-keyword">lib</span>/ocf/resource.d/heartbeat/pgsql</code>
需要确认的错误情况及解决方法:
node1重启corosync服务时,出现下面的状况,而node2可以重启
查看日志文件
切换到highgo用户重新启动停止了服务(之前安装完数据库停掉服务后有新修改postgresql.conf和pg_hba.conf文件,设置了远程访问),再重启corosync服务成功
查看集群状态
8、验证
(1)正常状态下
在node1用虚拟ip可访问数据库
查看共享盘挂载情况
(2)模拟node1崩溃
此时在node2能用虚拟ip访问数据库
集群状态
共享盘挂载
注意:
在配置前最好设置NetworkManager服务stop,更改system eth0为eth0因为配置vip时为eth0,怕会找不到设备,然后重启network服务

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Windows Recovery Environment (WinRE) is an environment used to repair Windows operating system errors. After entering WinRE, you can perform system restore, factory reset, uninstall updates, etc. If you are unable to boot into WinRE, this article will guide you through fixes to resolve the issue. Unable to boot into the Windows Recovery Environment If you cannot boot into the Windows Recovery Environment, use the fixes provided below: Check the status of the Windows Recovery Environment Use other methods to enter the Windows Recovery Environment Did you accidentally delete the Windows Recovery Partition? Perform an in-place upgrade or clean installation of Windows below, we have explained all these fixes in detail. 1] Check Wi

In this article, we will learn about the differences between Python and Anaconda. What is Python? Python is an open source language that places great emphasis on making the code easy to read and understand by indenting lines and providing whitespace. Python's flexibility and ease of use make it ideal for a variety of applications, including but not limited to scientific computing, artificial intelligence, and data science, as well as creating and developing online applications. When Python is tested, it is immediately translated into machine language because it is an interpreted language. Some languages, such as C++, require compilation to be understood. Proficiency in Python is an important advantage because it is very easy to understand, develop, execute and read. This makes Python

You may be wondering what the Microsoft Wi-Fi Direct Virtual Adapter does on your PC. Better rest assured that this network adapter is Microsoft and completely secure. But if the adapter is messing up your activity and you're wondering if it's worth keeping, this guide will give you everything you need to know. What does the Microsoft Wi-Fi Direct virtual adapter do? As the name suggests, Microsoft Wi-Fi Direct Virtual Adapter helps make your PC a wireless hotspot. This way, other computers can connect to your PC to access the Internet. It does this by virtualizing wireless network adapters. This way, your single physical wireless adapter is converted into two virtual

Keepalived is a high-availability solution based on LVS (Linux Virtual Server), which is mainly used for load balancing and failover in Linux environments. Keepalived ensures service continuity and reliability by using virtual IP addresses (VIPs) and health check mechanisms. Among them, VIP automatic drift is a key feature of Keepalived, which allows the service to be seamlessly switched to the backup server when the main server fails. This article will briefly introduce the installation and configuration of Keepalived to achieve high availability clusters. It is designed to provide guidance for beginners to help them master this key technology and improve their Linux system management capabilities. Terminology explanation for a deeper understanding of Kee

After downloading iQiyi videos, can I still watch them if my VIP expires? iQiyi Video is the first choice platform for many users to play film and television dramas. For some film and television drama resources, users need to top up VIP to watch them. So can I still watch the videos I downloaded after my VIP has expired? Let this site carefully introduce to users the analysis of the problem of whether videos downloaded by iQiyi members can be watched after their membership expires. Can I watch videos downloaded by iQiyi members if my membership expires? Answer: You cannot watch them. This is mainly for copyright protection. After the membership expires, the downloaded VIP movies and TV series cannot be watched. And if you want to synchronize your downloaded offline videos to other devices, this is not supported. List of other privileges for iQiyi members

NetEase Cloud Music has rich song copyrights. You can open this software every day and listen to all the good songs you want to listen to. You can always immerse yourself in it every day and enjoy high-quality content to relieve boredom. There are massive song resources and a lot of There are free songs, and some are VIP songs, which can only be listened to if you are a VIP, but you need to spend money to open a VIP. Many friends are very unhappy and want to know if there is a way to get whoring for free without spending any money. If you want to enjoy these songs for free, the editor here provides you with several methods. If you need it, you can take a look and learn more about it, so that you can enjoy the VIP songs you want to listen to for free. Don’t miss it if you are interested! In NetEase Cloud Music, you can earn a certain number of music beans by signing in every day. These music beans can

Audiences familiar with "Westworld" know that this show is set in a huge high-tech adult theme park in the future world. The robots have similar behavioral capabilities to humans, and can remember what they see and hear, and repeat the core storyline. Every day, these robots will be reset and returned to their initial state. After the release of the Stanford paper "Generative Agents: Interactive Simulacra of Human Behavior", this scenario is no longer limited to movies and TV series. AI has successfully reproduced this scene in Smallville's "Virtual Town" 》Overview map paper address: https://arxiv.org/pdf/2304.03442v1.pdf

Today, as digital reading becomes increasingly popular, Tomato novels have attracted a large number of book fans with their rich content and high-quality reading experience. For many users who love reading, becoming a VIP or SVIP member of Tomato Novel can enjoy more exclusive rights. However, since the prices of the two are not the same, many users still do not understand what Tomato Novel VIP and SVIP are. If there is any difference, then this article will give you a detailed analysis of the difference in rights between the two, hoping to bring you a better membership activation experience! The answer to the difference between svip and vip in Tomato Novels: The difference lies in membership level, rights and prices. 1. svip1. Spokesperson’s rights: Members can obtain Yang Zi’s electronic photo album and member center exclusive skin; 2. Advertising-free privileges: listening to books,
