手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

HA高可用集群部署(ricci+luci+fence_virtd) 双机热备

[日期:2016-10-13] 来源:Linux社区  作者:firelowrie [字体: ]

HA高可用集群部署(ricci+luci+fence_virtd) 双机热备

主机环境 RedHat6.5 64位
实验环境 服务端1 ip 172.25.29.1  主机名:server1.example.com  ricci
    服务端2 ip 172.25.29.2    主机名:server2.example.com  ricci
    管理端1 ip 172.25.29.3    主机名:server3.example.com  luci
    管理端2 ip 172.25.29.250    fence_virtd
防火墙状态:关闭
 
1. 安装ricci、luci及创建节点
1.安装、开启ricci(服务端1)
[root@server1yum.repos.d]# vim dvd.repo      #安装之前,修改yum源
#repos on instructor for classroom use
#Main rhel6.5 server
[base]
name=InstructorServer Repository
baseurl=http://172.25.29.250/rhel6.5
gpgcheck=0
 
#HighAvailability rhel6.5
[HighAvailability]
name=InstructorHighAvailability Repository
baseurl=http://172.25.29.250/rhel6.5/HighAvailability
gpgcheck=0
 
#LoadBalancer packages
[LoadBalancer]
name=InstructorLoadBalancer Repository
baseurl=http://172.25.29.250/rhel6.5/LoadBalancer
gpgcheck=0
 
#ResilientStorage
[ResilientStorage]
name=InstructorResilientStorage Repository
baseurl=http://172.25.29.250/rhel6.5/ResilientStorage
gpgcheck=0
 
#ScalableFileSystem
[ScalableFileSystem]
name=InstructorScalableFileSystem Repository
baseurl=http://172.25.29.250/rhel6.5/ScalableFileSystem
gpgcheck=0
[root@server1yum.repos.d]# yum clean all        #清除缓存
Loadedplugins: product-id, subscription-manager
Thissystem is not registered to Red Hat Subscription Management. You can usesubscription-manager to register.
Cleaningrepos: HighAvailability LoadBalancer ResilientStorage
              : ScalableFileSystem base
Cleaningup Everything
 
[root@server1yum.repos.d]# yum install ricci -y    #安装ricci
[root@server1yum.repos.d]# passwd ricci      #修改ricci密码
Changingpassword for user ricci.
Newpassword:
BADPASSWORD: it is based on a dictionary word
BADPASSWORD: is too simple
Retypenew password:
passwd:all authentication tokens updated successfully.
[root@server1yum.repos.d]# /etc/init.d/ricci start      #开启ricci
Startingsystem message bus:                              [  OK  ]
Startingoddjobd:                                        [  OK  ]
generatingSSL certificates...  done
GeneratingNSS database...  done
Startingricci:                                          [  OK  ]
[root@server1yum.repos.d]# chkconfig ricci  on    #开机自动开启
服务端2和服务端1做相同的操作
 
2.安装、开启luci (管理端1)
安装之前,与服务端1一样修改yum源
[root@server3yum.repos.d]# yum install luci -y      #安装luci
[root@server3yum.repos.d]# /etc/init.d/luci start    #开启ruci
Startluci...                                            [  OK  ]
Pointyour web browser to https://server3.example.com:8084 (or equivalent) to accessluci
 
在登陆之前,必须有DNS解析,也就是在/etc/hosts添加
例如: 172.25.29.3        server3.example.com
 
3.创建节点
登陆 https://server3.example.com:8084      #luci开放的是8084端口
安全证书,选I Understand Risks

点击Confirm Security Excepton

进入到管理服务器的luci界面,登陆时的密码是安装luci虚拟机的root密码

选择Manage Clusters,之后点击Create创建集群

如图,Cluster Name创建集群的名称,勾选Use the Same Passwordfor All Nodes,指的是所有结点所用的是相同的密码,填写要创建的结点名称和密码,名称是服务端的主机名,密码是上面提到的passwd ricci的修改的密码。勾选Download PackagesReboot和Enable,选择Create Cluster

正在创建节点,如图

创建完成,如图

创建完成之后,在服务端1和服务端2的/etc/cluster/下会生成cluster.conf文件,查看如下
[root@server1~]# cd /etc/cluster/
[root@server1cluster]# ls
cluster.conf  cman-notify.d
[root@server1cluster]# cat cluster.conf  #查看文件内容
<?xmlversion="1.0"?>
<clusterconfig_version="1" name="wen">        #集群名称
    <clusternodes>
      <clusternodename="server1.example.com" nodeid="1"/>    #结点1
      <clusternodename="server2.example.com" nodeid="2"/>    #结点2
    </clusternodes>
    <cman expected_votes="1"two_node="1"/>
    <fencedevices/>
    <rm/>
</cluster>
 
2.安装fence_virtd、创建fence设备
1.安装、开启fence_virtd(管理端2)
[root@foundation29Desktop]# yum install fence-virtd* -y
[root@foundation29Desktop]# fence_virtd -c    #设置
Modulesearch path [/usr/lib64/fence-virt]: 
 
Availablebackends:
    libvirt 0.1
Availablelisteners:
    multicast 1.2
    serial 0.4
 
Listenermodules are responsible for accepting requests
fromfencing clients.
 
Listenermodule [multicast]:        #多播
 
Themulticast listener module is designed for use environments
wherethe guests and hosts may communicate over a network using
multicast.
 
Themulticast address is the address that a client will use to
sendfencing requests to fence_virtd.
 
MulticastIP Address [225.0.0.12]:            #多播ip
 
Usingipv4 as family.
 
MulticastIP Port [1229]:      #多播端口号
 
Settinga preferred interface causes fence_virtd to listen only
onthat interface.  Normally, it listens onall interfaces.
Inenvironments where the virtual machines are using the host
machineas a gateway, this *must* be set (typically to virbr0).
Setto 'none' for no interface.
 
Interface[br0]: 
 
Thekey file is the shared key information which is used to
authenticatefencing requests.  The contents of thisfile must
bedistributed to each physical host and virtual machine within
acluster.
 
KeyFile [/etc/cluster/fence_xvm.key]:    #key文件的路径
 
Backendmodules are responsible for routing requests to
theappropriate hypervisor or management layer.
 
Backendmodule [libvirt]:
 
Configurationcomplete.
 
===Begin Configuration ===
backends{
    libvirt {
      uri = "qemu:///system";
    }
 
}
listeners{
    multicast {
      port = "1229";
      family = "ipv4";
      interface = "br0";
      address = "225.0.0.12";
      key_file ="/etc/cluster/fence_xvm.key";
    }
 
}
fence_virtd{
    module_path ="/usr/lib64/fence-virt";
    backend = "libvirt";
    listener = "multicast";
}
 
===End Configuration ===
Replace/etc/fence_virt.conf with the above [y/N]? y
[root@foundation29Desktop]# mkdir /etc/cluster    #创建cluster目录
[root@foundation29Desktop]# cd /etc/cluster/
[root@foundation29cluster]# dd if=/dev/urandom of=fence_xvm.key bs=128 count=1    #生成文件
1+0records in
1+0records out
128bytes (128 B) copied, 0.000167107 s, 766 kB/s
[root@foundation29Desktop]# scp fence_xvm.key root@172.25.29.1:/etc/cluster/  #将文件传给服务端1
root@172.25.29.2'spassword:
fence_xvm.key                                100%  512    0.5KB/s  00:00 
 
测试
[root@server1cluster]# ls    #查看
cluster.conf  cman-notify.d fence_xvm.key
以同样的方法传送给服务端2
[root@foundation29Desktop]# systemctl start fence_fence_virtd.service    #开启fence(由于管理端2是7.1的系统,开启时的命令不太一。如果是6.5系统,则用/etc/init.d/fence_virtd start即可)
 
2.创建fence设备

选择Fance Devices

选择Add,如下图,Name指的是添加fence设备的名称,写完之后选择Submit

结果

选择server1.example.com

点击Add Fence Method ,添加Method Name

如图,选择Add Tence Instance

填写Domin,选择Submit

完成之后,服务端2和服务端1的配置相同

测试
[root@server1cluster]# fence_node server2.example.com  #测试server2的结点
fenceserver2.example.com success
[root@server2cluster]# fence_node server1.example.com  #测试server1的结点
fenceserver1.example.com success

至此,高可用集群(HA)搭建完毕,可以根据自己的需要在上面铺设自己所需要的业务。

本文永久更新链接地址http://www.linuxidc.com/Linux/2016-10/135979.htm

linux
相关资讯       HA高可用  HA高可用集群 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款