centos7搭建高可用负载均衡服务器及常见错误解决方案

本文章基于centos7版本安装nginx+keepalived高可用服务器,在yum命令可用情况下安装:

1.安装编译环境 yum install gcc-c++;

2.安装PCRE库:yum install -y pcre pcre-devel;

3.安装zlib库:yum install -y zlib zlib-devel;

4.安装OpenSSL:yum install -y openssl openssl-devel;

5.下载nginx安装包:wget -c https://nginx.org/download/nginx-1.10.1.tar.gz;

6.解压nginx:tar -zxvf nginx-1.10.1.tar.gz;

7.cd nginx-1.10.1;

8. ./configure --prefix=/usr/local/nginx (./configure --prefix=安装路径);

9.make && make install( 编译并安装);

10./usr/local/nginx/sbin/nginx启动nginx;

11.ps aux | grep 'nginx'查看nginx是否启动;

12.若防火墙没有关闭,记得关闭防火墙 :service iptables stop关闭虚拟机防火墙;

keepalived安装:

1.下载keepalived:wget -c http://www.keepalived.org/software/keepalived-1.2.22.tar.gz

2.解压 tar -zxvf keepalived-1.2.22.tar.gz
3.cd keepalived-1.2.22
4../configure --prefix=/usr/local/keepalived
5.make编译
6.make install 安装

7.mkdir -p /etc/keepalived/

//配置keepalived为系统服务,开机重启

8. cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
9. cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d
10. cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
11. cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
12. chkconfig keepalived on设置开机启动

13.systemctl start keepalived.service启动服务或service keepalived start

在安装过程中出现一个问题:Unregistered Authentication Agent for unix-process:8932:1523243 (system bus name :1.128, object path /org/freedesktop/PolicyKit1/AuthenticationAge

这个问题的原因通过查看keepalived的启动日志,日志目录在/usr/log/messages里面,发现有一个命令没有找到的错误,原因是/usr/local/keepalived/sbin/keepalived没有拷贝到/usr/sbin/目录下,拷贝过去,问题解决!

 

 

 

你可能感兴趣的:(centos7搭建高可用负载均衡服务器及常见错误解决方案)