此文接 部署笔记3 ,介绍mfs高可用中的keepalived的部署.
keepAlived 安装
1. 下载 http://www.keepalived.org/software/keepalived-1.2.23.tar.gz
2. tar -xzvf keepalived-1.2.23.tar.gz
3. 下载并安装一下包,根据自己的操作系统版本定。
可用命令查看相关组件的版本(rpm –qa| grep xxxx)。
rpm -ivh libcom_err-devel-1.41.12-11.el6.x86_64.rpm
rpm -ivh e2fsprogs-devel-1.41.12-11.el6.x86_64.rpm
rpm -ivh keyutils-libs-devel-1.4-3.el6.x86_64.rpm
rpm -ivh libsepol-devel-2.0.41-4.el6.x86_64.rpm
rpm -ivh libselinux-devel-2.0.94-5.2.el6.x86_64.rpm
rpm -ivh krb5-devel-1.9-22.el6.x86_64.rpm
rpm -ivh zlib-devel-1.2.3-27.el6.x86_64.rpm
rpm -ivh openssl-devel-1.0.0-20.el6.x86_64.rpm
4. 安装keepalived
cd keepalived-1.2.23
./configure --prefix=/usr/local/keepalived
make & make install
5. 注册服务
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
6. 配置
mkdir -p /etc/keepalived/
vi /etc/keepalived/keepalived.conf
chmod 755 /etc/keepalived/keepalived_drbd_mfs.sh
7. 启动
sudo /etc/init.d/keepalived start
8. 关闭防火墙和selinux策略
vi /etc/sysconfig/selinux
修改:
SELINUX=disabled
#setenforce 0
9. 配置iptables,添加VRRP通讯支持, 允许组播
iptables -A INPUT -d 224.0.0.18 -j ACCEPT
10. 验证
能ping到 /etc/keepalived/keepalived.conf 中配置的虚地址,可以用 ip a 查看虚地址绑定情况。
11. 修改keepalived 日志输出。
默认keepalived 的日志输出到 /var/log/messages , 问题很不好查,以下修改日志输出。
1) vi /etc/sysconfig/keepalived
修改最后一行 KEEPALIVED_OPTIONS="-D -d -S 0"
2) vi /etc/rsyslog.conf 添加
#keepalived -S 0
local0.* /var/log/keepalived.log
3) 重启日志服务
# /etc/init.d/rsyslog restart
4) 查看日志
tail -1000 /var/log/keepalived.log
12. 抓包分析keepalived 通讯
tcpdump -i eth1 -n vrrp
keepAlived 安装
1. 下载 http://www.keepalived.org/software/keepalived-1.2.23.tar.gz
2. tar -xzvf keepalived-1.2.23.tar.gz
3. 下载并安装一下包,根据自己的操作系统版本定。
可用命令查看相关组件的版本(rpm –qa| grep xxxx)。
rpm -ivh libcom_err-devel-1.41.12-11.el6.x86_64.rpm
rpm -ivh e2fsprogs-devel-1.41.12-11.el6.x86_64.rpm
rpm -ivh keyutils-libs-devel-1.4-3.el6.x86_64.rpm
rpm -ivh libsepol-devel-2.0.41-4.el6.x86_64.rpm
rpm -ivh libselinux-devel-2.0.94-5.2.el6.x86_64.rpm
rpm -ivh krb5-devel-1.9-22.el6.x86_64.rpm
rpm -ivh zlib-devel-1.2.3-27.el6.x86_64.rpm
rpm -ivh openssl-devel-1.0.0-20.el6.x86_64.rpm
4. 安装keepalived
cd keepalived-1.2.23
./configure --prefix=/usr/local/keepalived
make & make install
5. 注册服务
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
6. 配置
mkdir -p /etc/keepalived/
vi /etc/keepalived/keepalived.conf
chmod 755 /etc/keepalived/keepalived_drbd_mfs.sh
7. 启动
sudo /etc/init.d/keepalived start
8. 关闭防火墙和selinux策略
vi /etc/sysconfig/selinux
修改:
SELINUX=disabled
#setenforce 0
9. 配置iptables,添加VRRP通讯支持, 允许组播
iptables -A INPUT -d 224.0.0.18 -j ACCEPT
10. 验证
能ping到 /etc/keepalived/keepalived.conf 中配置的虚地址,可以用 ip a 查看虚地址绑定情况。
11. 修改keepalived 日志输出。
默认keepalived 的日志输出到 /var/log/messages , 问题很不好查,以下修改日志输出。
1) vi /etc/sysconfig/keepalived
修改最后一行 KEEPALIVED_OPTIONS="-D -d -S 0"
2) vi /etc/rsyslog.conf 添加
#keepalived -S 0
local0.* /var/log/keepalived.log
3) 重启日志服务
# /etc/init.d/rsyslog restart
4) 查看日志
tail -1000 /var/log/keepalived.log
12. 抓包分析keepalived 通讯
tcpdump -i eth1 -n vrrp