[App] rhel7 配置 RHCS

 

pcs+pacemaker+corosync 配置http主从高可用

 

mysql-01

192.168.1.153

mysql-02

192.168.1.154

vip

192.168.1.160

os

rhel 7.2

 

参考 http://www.361way.com/rhel7-pcsd-ha/5260.html

 

1、初始化系统 节点1&2

# systemctl disable firewalld

# vi /etc/selinux/config

SELINUX=disabled

 

# hostnamectl set-hostname mysql-01     #  mysql-02

# yum -y install chrony pacemaker pcs fence-agents-all httpd

# systemctl enable chronyd

# systemctl start chronyd

# vi /etc/hosts

192.168.1.153   mysql-01

192.168.1.154   mysql-02

# reboot

 

2pcs 配置

# echo"redhat" |passwd --stdin hacluster   # 节点1&2,修改 hacluster 密码

# systemctl start pcsd.service      # 节点1&2   

# systemctl status pcsd.service    # 节点1&2

# pcs clusterauth mysql-01 mysql-02 -u hacluster -p redhat   # 节点1    认证配置

# pcs clustersetup --name mycluster mysql-01 mysql-02         # 节点生成集群文件,另一节点会自动生成

# cat /etc/corosync/corosync.conf

 

3pcs集群服务启动

# pcs status

Error: cluster is not currently running on this node

 

# pcs clusterstart --all      # 启动集群服务

# pcs cluster enable --all   # 设置开机自启动

# pcs status                     

 # 查看状态,节点是否onlinedaemon是否都active enabled,若没有则手动 systemctl enable *

Cluster name: mycluster

Stack: corosync

Current DC: mysql-01 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum

Last updated: Fri Oct 27 08:05:10 2017

Last change: Thu Oct 26 15:39:23 2017 by root via cibadmin on mysql-01

 

2 nodes configured

2 resources configured

 

Online: [ mysql-01 mysql-02 ]

 

Daemon Status:

  corosync: active/enabled

  pacemaker: active/enabled

  pcsd: active/enabled

 

 

4resource 资源配置  节点1

# pcs resource create VirtIP IPAddr ip=192.168.1.160 cidr_netmask=24op monitor interval=30s

# pcs resource create Httpd apacheconfigfile="/etc/httpd/conf/httpd.conf"

# pcs constraint colocation add Httpd with VirtIP INFINITY               # 启用 resource 资源

# pcs property set stonith-enabled=false

# pcs property set no-quorum-policy=ignore

# pcs property set default-resource-stickiness="INFINITY"

# pcs statusresources        # 查看状态

VirtIP (ocf::heartbeat:IPaddr):        Started mysql-01

Httpd  (ocf::heartbeat:apache):        Started mysql-01

# ip a       # mysql-01 上查看vip

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

    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: eno16780032: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000

    link/ether 00:50:56:a7:26:00 brd ff:ff:ff:ff:ff:ff

    inet 192.168.1.153/24 brd 192.168.1.255 scope global eno16780032

       valid_lft forever preferred_lft forever

    inet 192.168.1.160/24 brd 192.168.1.255 scope global secondary eno16780032

       valid_lft forever preferred_lft forever

    inet6 fe80::250:56ff:fea7:2600/64 scope link

       valid_lft forever preferred_lft forever

 

# ps -ef | grep http  # 查看 http 进程是否启动

 

5、开启 web 管理页面 节点1&2

# vi /usr/lib/pcsd/ssl.rb

webrick_options = {

  :Port               => 2224,

  #:BindAddress        => primary_addr,

  #:Host               => primary_addr,

  :BindAddress        => '0.0.0.0',

  :Host               => '0.0.0.0',

  :SSLEnable          => true,

  :SSLVerifyClient    => OpenSSL::SSL::VERIFY_NONE,

  :SSLCertificate     => OpenSSL::X509::Certificate.new(crt),

  :SSLPrivateKey      => OpenSSL::PKey::RSA.new(key),

  :SSLCertName        => [[ "CN", server_name ]],

  :SSLOptions         => get_ssl_options(),

}

# systemctl restart pcsd

# netstat -tunlp     # 查看 2224 端口是否启用

# web 端登录  https://192.168.1.153:2224

# 输入账号密码  hacluster / redhat

# + ADDExisting


 


 


 

6、测试

# 手动shutdown 节点1,看vip是否漂移,http服务是否启用等(略)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值