编译安装LVS和Keepalived-2.0.9

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编译安装LVS和Keepalived-2.0.9相关的知识,希望对你有一定的参考价值。

操作系统Centos7,关闭selinux,关闭防火墙

1、备份和修改基础仓库到163
yum install wget -y && cd /etc/yum.repos.d/ && mv CentOS-Base.repo CentOS-Base.repo.back
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

2、安装epel仓库和修改epel仓库地址到阿里云
yum install epel-release -y
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3、安装开发环境
yum group list
yum group install Development Tools -y

4、下载lvs源码包
wget -O /usr/local/src/ipvsadm-1.26.tar.gz http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
yum install ipvsadm -y #(推荐安装方法,这种方法版本比较高)

5、下载keepalived源码包
wget -O /usr/local/src/keepalived-2.0.19.tar.gz https://www.keepalived.org/software/keepalived-2.0.19.tar.gz

6、安装依赖环境
yum -y install libnl-devel popt-devel popt-static openssl-devel libnfnetlink-devel

7、编译安装lvs
tar zxf /usr/local/src/ipvsadm-1.26.tar.gz -C /usr/local/src
cd /usr/local/src/ipvsadm-1.26
make && make install
(yum 安装不需要编译)

8、测试ipvsadm 和检测lvs 的ip_vs
ipvsadm -L -n
lsmod | grep ip_vs

9、编译安装keepalived
tar zxf /usr/local/src/keepalived-2.0.19.tar.gz -C /usr/local/src
cd /usr/local/src/keepalived-2.0.19
./configure --prefix=/usr/local/keepalived
make && make install
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/src/keepalived-2.0.19/keepalived/etc/init.d/keepalived /etc/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

测试keepalived
/etc/init.d/keepalived start
ps axu|grep keepalived
tail -f /var/log/message

以上是关于编译安装LVS和Keepalived-2.0.9的主要内容,如果未能解决你的问题,请参考以下文章

LVS_DR模式构建配置

LVS_DR模式构建配置

LVS安装使用详解

lvs fullnat+ECMP内核编译

LVS-Fullnat之编译内核 将fullnat模块添加到内核

作业十一