博客园  :: 首页  :: 管理

1、安装 pacemaker 相关的软件及可能会用到的软件,两台主机都需要安装

[root@app01 qq-5201351]# yum install nmap-ncat -y
[root@app01 qq-5201351]# yum install pcs -y
[root@app01 qq-5201351]# yum install resource-agents-sap -y

nmap-ncat 软件包是因为可以提供nc命令,只是方便做一些测试,这个也不是必须的

其中:安装了 pcs 时,也会安装很多依赖,完成后会创建 hacluster 用户

[root@app01 ~]# chage -l hacluster
Last password change                                    : Nov 22, 2023
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : -1
Maximum number of days between password change          : -1
Number of days of warning before password expires       : -1
[root@app01 ~]#

2、为 hacluster 用户设置密码,两台主机的密码都要设置成一致

[root@app01 ~]# passwd hacluster 
        sV5"sY#932T0*kP6)rF3!qS5@

3、在两台APP上创建: /etc/corosync/corosync.conf  配置文件

totem {
    version: 2
    cluster_name: AppProdCluster
    transport: knet
    crypto_cipher: aes256
    crypto_hash: sha256
}

nodelist {
    node {
        ring0_addr: app01
        name: app01
        nodeid: 1
    }

    node {
        ring0_addr: app02
        name: app02
        nodeid: 2
    }
}

quorum {
    provider: corosync_votequorum
    two_node: 1
}

logging {
    to_logfile: yes
    logfile: /var/log/cluster/corosync.log
    to_syslog: yes
    timestamp: on
}

4、启动pcsd,及加入到开机启动项中

systemctl start pcsd
systemctl enable pcsd

5、先建立认证(一定需要先将两个主机名写到/etc/hosts文件),需要输入hacluster用户的的密码:

pcs host auth app01 app02

6、生成corosync 用到的key文件,corosync-keygen 命令会直接将文件生成到 /etc/corosync/ 目录,需要保证两台主机的key文件一致

[root@app01 tmp]# corosync-keygen
Corosync Cluster Engine Authentication key generator.
Gathering 2048 bits for key from /dev/urandom.
Writing corosync key to /etc/corosync/authkey.

7、重启 pcsd 及 corosync 两个服务

systemctl restart pcsd
systemctl enable pcsd
systemctl restart corosync  
systemctl enable corosync

8、最后启动cluster集群

pcs cluster start --all 

 

 

 

尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/17899446.html