nginx离线安装及nginx高可用服务搭建(keepalived)

一、nginx离线安装方式1:安装包安装

先下载nginx安装包及其依赖包 下载地址

  • 将nginx.rar解压出来,上传到服务器上的 /opt/soft/目录;
  • 进入到你放的nginx整个文件夹所在的位置,
cd /opt/soft/nginx/gcc 

1. 安装gcc

先检查当前系统有无gcc环境,如果出来以下内容,说明已经有了gcc环境,可跳过步骤1:

gcc -v

[root@node03 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat
.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linuxThread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 


  • 进入gcc文件夹,执行以下命令安装gcc:
rpm -Uvh *.rpm --nodeps --force

2. 安装gcc-c++

先检查当前系统有无gcc-c++环境,如果出来以下内容,说明已经有gcc-c++环境,可跳过步骤2:

[root@node03 ~]# g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat
.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linuxThread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) 
  • 进入到gcc-c++目录
cd /opt/soft/nginx/gcc-c++
  • 然后执行以下命令安装gcc-c++
rpm -Uvh *.rpm --nodeps --force

3. 安装PCRE

先检查当前系统有无PCRE环境,如果出来以下内容,说明已经有PCRE环境,可跳过步骤3:

[root@node03 ~]# rpm -qa |grep pcre

pcre-8.32-17.el7.x86_64
pcre-devel-8.32-17.el7.x86_64

  • 进入nginx目录
cd /opt/soft/nginx
  • 先把pcre解压出来
tar -zxvf pcre-8.35.tar.gz
  • 解压出来之后就要开始安装了
cd pcre-8.35

./configure

make && make install

4. 安装libtool

cd /opt/soft/nginx
tar -zxvf libtool-2.4.2.tar.gz

cd libtool-2.4.2

./configure

make && make install

5. 安装nginx

cd /opt/soft/nginx
tar -zxvf nginx-1.18.0.tar.gz

cd nginx-1.18.0

./configure --prefix=/opt/nginx

# --with-openssl=/opt/soft/nginx-all/openssl-fips-2.0.16

其中./configure --prefix=/usr/local/nginx 为指定目录安装,如不指定,则默认安装在/usr/local/nginx路径下

make && make install

6. nginx常用命令

- nginx -m 显示所有加载的模块
- nginx -l 显示所有可以使用的指令
- nginx -t 检查nginx的配置文件是否正确
- nginx -s 启动nginx
- nginx -s reload 重新加载配置文件
- nginx -s stop 停止nginx

7. nginx配置

vi /opt/nginx/conf/nginx.conf



# user  root;            #运行用户
worker_processes  1;        #启动进程,通常设置成和cpu的数量相等

#全局错误日志及PID文件
error_log  /opt/nginx/logs/error.log;
pid        /opt/nginx/logs/nginx.pid;

# 工作模式及连接数上线
events {
    use epoll;            #epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以大大提高nginx的性能

    worker_connections  1024;    #单个后台worker process进程的最大并发链接数
}

#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
    include       mime.types;   #文件扩展名与类型映射表
    default_type  application/octet-stream; #默认文件类型
    
    #设置日志模式
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    #设定请求缓冲
    server_names_hash_bucket_size  128;
    client_header_buffer_size   32K;
    large_client_header_buffers  4 32k;
    # client_max_body_size   8m;
    
    #sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,对于普通应用,
    #必须设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,以平衡磁盘与网络I/O处理速度,降低系统的uptime.
    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay    on;

    #连接超时时间
    #keepalive_timeout  0;
    keepalive_timeout  65;

    #开启gzip压缩,降低传输流量
    gzip  on;
    #设置允许压缩的页面最小字节数,页面字节数从header头的Content-Length中获取。默认值是0,表示不管页面多大都进行压缩。建议设置成大于1K。如果小于1K可能会越压越大。
    gzip_min_length    1k;
    #压缩缓冲区大小。表示申请4个单位为16K的内存作为压缩结果流缓存,默认值是申请与原始数据大小相同的内存空间来存储gzip压缩结果。
    gzip_buffers    4 16k;
    #压缩版本(默认1.1)用于设置识别HTTP协议版本,目前大部分浏览器已经支持GZIP解压,使用默认即可。
    gzip_http_version  1.1;
    #压缩比率。用来指定GZIP压缩比,1压缩比最小,处理速度最快;9压缩比最大,传输速度快,但处理最慢,也比较消耗cpu资源。
    gzip_comp_level  2;
    #用来指定压缩的类型,“text/html”类型总是会被压缩
    gzip_types  text/plain application/x-javascript text/css  application/xml;
    gzip_vary on;

    #反向代理负载均衡设定部分
    proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;

    #upstream表示负载服务器池,切记,这个名称不能使用下划线,否则无法识别导致负载不过去
    upstream serverpool {
        #server tomcat地址:端口号 weight表示权值,权值越大,被分配的几率越大;
        server 192.168.33.101:80 weight=4 max_fails=2 fail_timeout=30s;
      server 192.168.33.102:80 weight=4 max_fails=2 fail_timeout=30s;
    }

    server {
        listen       80;        #监听端口    
        server_name  www.test.com; #对外提供服务的网址(域名或者ip)
    
        #默认请求设置
        location / {
            index index.jsp index.html index.htm;   #设定访问的默认首页
            #root /usr/local/apache7/webapps;    #站点根目录,此目录下存放我们的web项目
            proxy_pass http://serverpool;
        }
        
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

    
        #所有的api均由tomcat处理
        location /api {
            proxy_pass http://localhost:8200;
        }
        
        #所有的静态文件直接读取不经过tomcat,nginx自己处理
        location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$ 
        {
            client_max_body_size	100m;
            proxy_connect_timeout	3;
    		proxy_send_timeout		30;
    		proxy_read_timeout		30;
    		root /html
        }
        
        location ~ .*\.(js|css)?$
        {
               expires  1h;
        }
        #log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '$status $body_bytes_sent "$http_referer"' '"$http_user_agent" $http_x_forwarded_for';
        #access_log  /usr/local/nginx/logs/ubitechtest.log access;#设定访问日志的存放路径     

        # redirect server error pages to the static page /50x.html
        #定义错误提示页面
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /html;
        }

    }
}

二、nginx离线安装方式2:配置本地yum源安装

此方式类似于在线安装,在无法联网的服务器上,通过配置本地yum源,可以很方便的通过yum 命令来安装nginx所需的依赖。

1. 挂载iso镜像文件作为本地yum源

  • 上传linux系统镜像文件到服务器,然后将其挂载到文件系统 /mnt/local-repo
mkdir /mnt/local-repo

mount -o  loop /opt/soft/CentOS-6.7-x86_64-DVD.iso   /mnt/local-repo
  • 创建yum的本地库repo文件
# 先备份
cd /etc/yum.repos.d
mkdir bak
mv *.repo /etc/yum.repos.d/bak

# 再创建新的repo文件
vi local-repo.repo

# 文件内容如下
[local-repo]
name=local-repo
baseurl=file:///mnt/local-repo
enabled=1
gpgcheck=0

# gpgcheck=0这是和验证包的安全信息的,最好设置成0,表示关闭安全验证,否则还需要准备安全验证文件,因为是光盘安装,不需要检查。
# enabled=1,表示启用本仓库,1启用,0关闭
  • 清空缓存并重新刷新缓存
yum clean all

yum makecache

2. 安装nginx依赖

# 配置完本地yum源后即可一键安装这些依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

3. 安装nginx

nginx安装如上一节的步骤5.

三、nginx https配置

1. 查看nginx原有的模块

nginx -V

输入该命令后如果出现
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
则说明原nginx中已经配了ssl模块,则可跳过步骤2

2. 配置SSL模块

  • 进入nginx解压出来的源码包路径下运行配置
cd /opt/soft/nginx/nginx-1.18.0

./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module
  • 配置完成后,运行make,注意:此处不能进行make install,否则就是覆盖安装
make
  • 替换已安装好的nginx运行文件
cp /opt/soft/nginx/nginx-1.18.0/objs/nginx /opt/nginx/sbin/
  • 然后通过nginx -V 命令查看ssl模块是否已加入成功

  • 准备好证书,配置ssl,https的配置如:

server {
        listen       443 ssl;
        server_name  aa.abc.com;

        ssl_certificate      cert/2643408_xxx.pem;
        ssl_certificate_key  cert/2643408_xxx.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            proxy_pass http://127.0.0.1:8886;
        }
    }

四、nginx开机自启配置

1. centos7

  • 切换到/lib/systemd/system/目录,创建nginx.service文件
cd /lib/systemd/system/
vi nginx.service

[Unit]
Description=nginx 
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx reload
ExecStop=/opt/nginx/sbin/nginx quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target




[Unit]:服务的说明
Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3

  • 退出并保存文件,执行systemctl enable nginx.service使nginx开机启动
systemctl enable nginx.service
systemctl start nginx.service    启动nginx

systemctl stop nginx.service    结束nginx

systemctl restart nginx.service    重启nginx

2. centos6.9

  • 在linux系统的/etc/init.d/目录下创建nginx文件
vim /etc/init.d/nginx

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  NGINX is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
   # make required directories
   user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   if [ -z "`grep $user /etc/passwd`" ]; then
       useradd -M -s /bin/nologin $user
   fi
   options=`$nginx -V 2>&1 | grep 'configure arguments:'`
   for opt in $options; do
       if [ `echo $opt | grep '.*-temp-path'` ]; then
           value=`echo $opt | cut -d "=" -f 2`
           if [ ! -d "$value" ]; then
               # echo "creating" $value
               mkdir -p $value && chown -R $user $value
           fi
       fi
   done
}
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
force_reload() {
    restart
}
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
    status $prog
}
rh_status_q() {
    rh_status >/dev/null 2>&1
}
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

这个脚本来自nginx官方,脚本地址:http://wiki.nginx.org/RedHatNginxInitScript ,不过要注意,如果你是自定义编译安装的nginx,需要根据您的安装路径修改下面这两项配置:

  • nginx=”/usr/sbin/nginx” 修改成nginx执行程序的路径。
  • NGINX_CONF_FILE=”/etc/nginx/nginx.conf” 修改成配置文件的路径。
  • 保存脚本文件后设置文件的执行权限:
chmod a+x /etc/init.d/nginx
  • 然后,就可以通过该脚本对nginx服务进行管理了:
/etc/init.d/nginx start
/etc/init.d/nginx stop
  • 使用chkconfig进行管理

    • 先将nginx服务加入chkconfig管理列表:
    chkconfig --add /etc/init.d/nginx
    
    • 加完这个之后,就可以使用service对nginx进行启动,重启等操作了。
    service nginx start
    service nginx stop
    
    • 设置终端模式开机启动:
    chkconfig nginx on
    

五、lvs

LVS提供虚拟服务,采用直接路由模式DR;nginx作为反向代理服务器来实现负载均衡;keepalived实现主从热备,检查RealServer的健康状态以及主机与备机之间失效转移。本文选用Tenengine作为反向代理和负载均衡服务,Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性;Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验。

1.直接路由模式DR (Direct Routing)模式

  • 相关术语
    • 1.DS:Director Server。指的是前端负载均衡器节点
    • 2.RS:Real Server。后端真实的工作服务器
    • 3.VIP:向外部直接面向用户请求,作为用户请求的目标的ip地址
    • 4.DIP:Director Server IP,主要用于和内部主机通讯的IP地址
    • 5.RIP:Real Server IP,后端服务器的IP地址
    • 6.CIP:Client IP,访问客户端的IP地址
  • 原理:负载均衡器和RS都使用同一个IP对外服务。但只有DR对ARP请求进行响应,所有RS对本身这个IP的ARP请求保持静默。也就是说,网关会把对这个服务IP的请求全部定向给DR,而DR收到数据包后根据调度算法,找出对应的RS,把目的MAC地址改为RS的MAC(因为IP一致)并将请求分发给这台RS。这时RS收到这个数据包,处理完成之后,由于IP一致,可以直接将数据返给客户,则等于直接从客户端收到这个数据包无异,处理后直接返回给客户端。由于负载均衡器要对二层包头进行改换,所以负载均衡器和RS之间必须在一个广播域,也可以简单的理解为在同一台交换机上。

优点:负载均衡器只是分发请求,应答包通过单独的路由方法返回给客户端。

缺点:要求负载均衡器的网卡必须与物理网卡在一个物理段上。

六、keepalived实现nginx高可用(HA)

参考文章

1. 安装

  • 编译安装方式与nginx类似。
# 先解压
tar -zxvf /opt/soft/keepalived-2.0.13.tar.gz

cd /opt/soft/keepalived-2.0.13/
./configure --prefix=/opt/keepalived
make && make install
  • 建立服务启动脚本,以便使用service命令控制,将解压后路径/opt/soft/keepalived-2.0.13/keepalived/etc/init.d的文件keepalived拷贝到/etc/init.d下
cp /home/soft/keepalived-2.0.13/keepalived/etc/init.d/keepalived /etc/init.d/
  • 由于安装使用非默认路径(本教程中使用的/opt/keepalived)故需修改相关路径,保证keepalived能正常启动
vi /etc/init.d/keepalived
大约15行
将. /etc/sysconfig/keepalived 修改为
. /opt/keepalived/etc/sysconfig/keepalived
  • 设置正确启动参数命令,并将修改好的keepalived拷贝到/etc/sysconfig 目录下
vi /opt/keepalived/etc/sysconfig/keepalived

修改的路径为安装路径下的配置文件,如果不修改,则默认会去找/etc/keepalived/keepalived.conf文件。
KEEPALIVED_OPTIONS="-D -f /opt/keepalived/etc/keepalived/keepalived.conf"

将修改好的keepalived拷贝到/etc/etc/sysconfig 目录下
cp /opt/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

2. 配置keepalived

vi /opt/keepalived/etc/keepalived/keepalived.conf



! Configuration File for keepalived
global_defs {
    router_id LVS_MASTER         # 设置lvs的id,在一个网络应该是唯一的
}
vrrp_instance VI_1 {
    state MASTER            # 指定keepalived的角色,备用服务器上为 BACKUP
    interface ens33            # 当前进行vrrp通讯的网络接口卡(当前centos的网卡),根据自己的服务器来设置
    virtual_router_id 66        # 虚拟路由编号,主从要一直
    priority 100            # 优先级,数值越大,获取处理请求的优先级越高,备用服务器上数值要小点
    advert_int 1            # 检查间隔,默认为1s(vrrp组播周期秒数)
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.33.200        # 定义虚拟ip(VIP),可多设,每行一个
    }
}

# 定义对外提供的LVS的VIP以及port
virtual_server 192.168.33.200 80 {
    delay_loop 6             # 设置健康检查时间,每隔6秒查询realserver状态
    lb_algo rr            # lvs 算法
    lb_kind DR            # 设置lvs实现负载的机制,有NAT、TUN、DR三个模式
    persistence_timeout 0        # 同一IP的连接60秒内被分配到同一台realserver
    protocol TCP
    
    #真实服务器(nginx) 
    real_server 192.168.33.101 8088 {
        weight 3        # 配置节点权值,数值越大权重越高
        TCP_CHECK {
            connect_timeout 10
            nb_get_retry 3
            delay_before_retry 3
            connect_port 8088
        }
        
    }
    real_server 192.168.33.102 8088 {
        weight 3
        TCP_CHECK {
            connect_timeout 10
            nb_get_retry 3
            delay_before_retry 3
            connect_port 8088
        }
    }
}
  • 这里在keepalived的配置文件中定义的LVS模式为DR模式,还需要在两台rs上执行lvs_dr_rs.sh脚本
vi /opt/keepalived-2.0.13/lvs_dr_rs.sh

#/bin/bash
vip=192.168.33.200
#把vip绑定在lo上,是为了实现rs直接把结果返回给客户端
ifconfig lo:0 $vip broadcast $vip netmask 255.255.255.255 up
route add -host $vip lo:0
#以下操作为更改arp内核参数,目的是为了让rs顺利发送mac地址给客户端
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce

  • 执行:sh /opt/keepalived/lvs_dr_rs.sh
  • 在两台真实服务器上面执行完毕之后,执行ip addr就能看到两台服务器的lo都绑定好了虚拟ip.
  • 服务器重启之后绑定的这个虚拟ip就没有了,需要再执行一下脚本,所以可以把对这个脚本的执行放到开机自启中。
执行命令:vi /etc/rc.d/rc.local
将以下内容添加至该文件中:sh /opt/keepalived/lvs_dr_rs.sh
保存退出,然后添加执行权限:chmod +x rc.local

  • 启动keepalived服务: service keepalived start
  • 在keepalived端执行命令ipvsadm -ln查看连接数,如果报错,先安装ipvsadm,yum install -y ipvsadm
[root@chenhao keepalived]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.33.200:80 rr
  -> 192.168.33.101:80            Route   3      0          1         
  -> 192.168.33.102:80            Route   3      0          2

3. 出现的问题

1、启动过程中提示keepalived command not found
启动方式为:/etc/init.d/keepalived start
原因:keepalived命令没有在/usr/sbin目录下
解决方法:cp /opt/keepalived/sbin/keepalived /usr/sbin
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值