crm搭建流程整理
1、环境搭建
1.1 Asianux 4.4系统完全安装
-
镜像包 Asianux-4.4.iso(CentOS6.5)
-
安装包选择“Everything”,安装所有包
1.2 环境配置
# 1、配置eth1网卡
vim /etc/sysconfig/network-script/ifcfg-eth1
# 2、关闭防火墙
service iptables status
service iptables stop
service ip6tables stop
chkconfig iptables off
chkconfig ip6tables off
iptables -F
ip6tables -F
# 3、查看selinux状态
getenforce # 完全安装的4.4系统默认是disabled状态
# 4、配置/etc/hosts
# 更改主机名,追加IP地址与对应主机名到hosts文件
2、集群安装
2.1 挂载光盘
# 图形挂载,“设置”——“光驱”——勾选”已连接“(镜像选择HA7.2-tools-x86_64-20161208.iso)
# 命令行挂载
mount /dev/cdrom /media
[root@yangzonglan2 ~]# ls /media/RedFlag/
autorun cmdline Documents RedFlag TRANS.TBL
[root@yangzonglan2 ~]# df -h # 查看挂载结果
2.2 安装集群
cd /media/RedFlag
./cmdline # 执行安装
# 填写序列号界面,暂时不写,连接XShell后通过rfhareglic命令输入
2.3 部署corosync
# 修改corosync.conf配置文件
vim /etc/corosync/corosync.conf
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: off
threads: 0
rrp_mode: passive
interface {
ringnumber: 0
bindnetaddr: 192.168.113.0 # 修改到与eth1同网段
broadcast: yes
mcastport: 5546 # 如启动rfhaserver失败,尝试更换其他端口
}
# interface {
# ringnumber: 1
# bindnetaddr: 192.168.127.0
# broadcast: yes
# mcastport: 5547
# }
}
logging {
fileline: off
to_stderr: no
...
# 添加corosync认证,并同步到节点2
[root@yangzonglan1 RedFlag]# corosync-keygen
Corosync Cluster Engine Authentication key generator.
Gathering 1024 bits for key from /dev/random.
Press keys on your keyboard to generate entropy.
Writing corosync key to /etc/corosync/authkey.
[root@yangzonglan1 RedFlag]# scp /etc/corosync/authkey yangzonglan2:/etc/corosync/
3、集群配置
3.1 启动集群
- 集群启动前,再次确认防火墙状态,iptables status ,ip6tables status ,chkconfig iptables off,iptable -F
# 输入序列号
[root@yangzonglan1 RedFlag]# rfhareglic
Register HA License #L9...-T...IC-OWQ..U-M..JA-F..80
# 开启服务
[root@yangzonglan1 ~]# service rfhaserver start
# 设置开机启动
[root@yangzonglan1 ~]# chkconfig rfhaserver on
# 添加全局配置
crm(live)configure# rsc_defaults resource-stickiness=200 # 此参数为资源有多大程度倾向于停留在当前节
点。
crm(live)configure# property no-quorum-policy="ignore" # 此参数是通过分组机制判断集群节点的合法
crm(live)configure# property stonith-enabled="false" # 此参数是不开启防止脑裂服务
3.2 添加资源
crm(live)configure# primitive fip1 ocf:heartbeat:IPaddr2 params ip="192.168.126.1" cidr_netmask="24" nic="eth0" iflabel="fip1" op monitor interval="10"
#配置浮动IP 资源,参数:浮动IP地址为10.200.1.11,掩码为24,网口为eth0,标签为fip,监控间隔为10 秒。
crm(live)configure# primitive fip2 ocf:heartbeat:IPaddr2 params ip="192.167.126.2" cidr_netmask="24" nic="eth0" iflabel="fip2" op monitor interval="10"
crm(live)configure# primitive weblogic ocf:redflag:template params rcname="template-weblogic" startcmd="/home/web_scripts/startWeb.sh" stopcmd="/home/web_scripts/stopWeb.sh" pname="java" pnamepara="home=/weblogic/wlserver_10.3/server"
op monitor interval="30" timeout="30" op start interval="0" timeout="90" op stop interval="0" timeout="90"
#配置weblogic资源,参数:weblogic启动命令/home/web_scripts/startWeb.sh,weblogic停止命令/home/web_scripts/stopWeb.sh,监控进程关键字为java,监控进程关键字详细参数为home=/weblogic/wlserver_10.3/server(详细参数可以不设置),监控间隔30秒、监控超时30秒,启动间隔0秒、启动超时90秒,停止间隔0秒、停止超时90秒。
3.3 添加管理组
crm(live)configure# group 组名字 资源名字 meta target-role="Started"
3.3 添加资源约束
crm(live)configure# location 约束名字 组名字 rule inf: #uname eq 主机名 //添加约束
3.4 停止/清除/删除资源
crm(live)resource# stop httpd # 停止httpd服务
crm(live)resource# cleanup httpd # 清除httpd状态
crm(live)# resource status # 查看资源列表
crm(live)# configure delete httpd # 删除httpd资源
crm(live)# configure commit # 提交更改,命令生效
4、问题手机
4.1 序列号漏输
[root@yangzonglan1 RedFlag]# service rfhaserver start
Starting Redflag Cluster Manager: [FAILED]
[root@yangzonglan1 RedFlag]# rfhareglic # rfhareglic输入序列号即可
4.2 集群连接不上
集群启动成功,但是显示连接失败
[root@yangzonglan1 RedFlag]# service rfhaserver start
Starting Redflag Cluster Manager: [ OK ]
[root@yangzonglan1 RedFlag]# rfhastat
Connection to cluster failed: connection failed
- 再次检查防火墙状态,关闭防火墙,关闭服务,修改corosync端口,确认防火墙状态,重启服务
29 service iptables status
30 iptables -F
31 service rfhaserver stop
32 service rfhaserver status
33 vim /etc/corosync/corosync.conf
34 service iptables status
36 service iptables stop
48 chkconfig iptables off
49 chkconfig ip6tables off
57 service iptables status
59 service ip6tables status
64 service rfhaserver start
65 rfhastat
[root@yangzonglan2 ~]# rfhastat
============
Last updated: Thu Apr 16 06:44:27 2020
Last change: Thu Apr 16 06:43:55 2020 via crmd on yangzonglan1
Stack: openais
Current DC: yangzonglan1 - partition with quorum
Version: 1.1.7-6.0.8.AXS4-148fccfd5985c5590cc601123c6c16e966b85d14
2 Nodes configured, 2 expected votes
0 Resources configured.
============
Online: [ yangzonglan1 yangzonglan2 ]