首页 文章 精选 留言 我的

精选列表

搜索[图形后端],共10000篇文章
优秀的个人博客,低调大师

Node.js 后端框架 star 排名(2020年3月更新),Fastify 超越 Loopback

发布时间以首个版本发布(0.x)为准。 排名 框架名称 star数 语言 首个版本发布时间 github地址 备注 1 express 47.5k js 2010年1月 https://github.com/expressjs/express star和下载量最高的老牌框架 2 koa 28.6k js 2013年11月 https://github.com/koajs/koa 3 nest 24.7k ts 2017年11月 https://github.com/nestjs/nest 增长最快的框架 4 sails 21.2k js 2012年7月 https://github.com/balderdashy/sails 最早的类ror框架 5 egg 14.9k js 2016年7月 https://github.com/eggjs/egg 阿里开源的node.js框架 6 fastify 13.7k js 2016年10月 https://github.com/fastify/fastify 性能最好的node.js 框架 7 loopback 13.1k js/ts 2013年6月 https://github.com/strongloop/loopback&https://github.com/strongloop/loopback-next 8 hapi 12.7k js 2012年8月 https://github.com/hapijs/hapi 9 pomelo 10.7k js 2012年12月 https://github.com/NetEase/pomelo 游戏框架 10 node-restify 9.7k js 2011年5月 https://github.com/restify/node-restify 11 adonis 7.8k ts 2015年10月 https://github.com/adonisjs/adonis-framework 类似laravel的框架 nest.js 增长了 0.6k 成为增长最快的框架

优秀的个人博客,低调大师

node.js 后端框架 star 排名(12月更新) nest.js 增长显著

排名 框架名称 star数 语言 首个版本发布时间 github地址 备注 1 express 46.3k js 2010年1月 https://github.com/expressjs/express star和下载量最高的老牌框架 2 koa 28k js 2013年11月 https://github.com/koajs/koa 3 nest 21.8k ts 2017年11月 https://github.com/nestjs/nest 增长最快的框架 4 sails 21k js 2012年7月 https://github.com/balderdashy/sails 最早的类ror框架 5 egg 14.3k js 2016年7月 https://github.com/eggjs/egg 阿里开源的node.js框架 6 loopback 12.9k js/ts 2013年6月 https://github.com/strongloop/loopback&https://github.com/strongloop/loopback-next 7 fastify 12.6k js 2016年10月 https://github.com/fastify/fastify 性能最好的node.js 框架 8 hapi 11.8k js 2012年8月 https://github.com/hapijs/hapi 9 pomelo 10.6k js 2012年12月 https://github.com/NetEase/pomelo 游戏框架 10 node-restify 9.6k js 2011年5月 https://github.com/restify/node-restify 11 adonis 7.3k ts 2015年10月 https://github.com/adonisjs/adonis-framework 类似laravel的框架 nest.js 增长了0.8k 成为增长最快的框架

优秀的个人博客,低调大师

Java面经 面试经验 互联网公司面试经验 后端面试经验

应聘相关 声明: 1,程序员相关的哈 2,万事无定论,比如说,就算你小学毕业,但是java基础却扎实到变态,我相信open的公司还是会给你机会的。 3,心态很重要,虽然日常的心态不容易控制,面试那俩小时的心态,只要你想,就能控制。 1,先来一份前辈的劝戒 1,坚持三年 ,不管在哪干,有一个好的平台,坚持三年以上才能出效果。 2,如果跳的话,新公司需要稳定,最少过了B轮融资,,五万比一是创业型公司的失败率 3,不要着急,不要比较为了5000块的工资差价跳,不值得跳,从一万到三万,并且有一个好的平台的话,才值得跳。 4,长期的看普华挺好的,从平台上讲,除了BAT华为,基本没有更好的 5,每天要多投些简历,每天投个几十份,别着急,多面面。 2,再来一份傲骄的互联网公司的不收标准 符合以下条件的不要 1,二本以下,特别是学校名XXX学院 2,应届或者未毕业 3,在职并且不打算换工作 4,目标非北京 5,纯 windows / asp / c# / c sharp / .net / dot net 6,纯嵌入式 7,纯移动端 android / iOS 8,特别底层,比如操作系统内核裁剪 9,非计算机专业,计算机工作经验在一年以下 10,最近的项目,空白超过半年,比如现在8月份,项目经历只写到2月 11,87 年以前,除非背景特别牛 12,有基础培训经历的,比如达内 13,硕士学校比本科差的 说到这,如果小哥你已经不想着跳了。就不用往下看了(你往下看,我写的也不一定能看,哈哈) 面试的心态很重要 如果可以的话,**建议以一个和面试官交流的心态去面试**。而且普通面试大部分问答都是有一些套路的。 一般公司的笔试、面试(以java说) **java** java基础必考,线程、集合(list、map、linklist、array,什么无key遍历map啊,链表倒置啊,这几个东西的数据结构和插入查询特性啊,线程创建方式和同步啊)相关必问。最好能说清楚常见的设计模式、要能手写一个单列模式。 傲骄公司的笔试、面试(不知道什么样的公司骄傲?那算了,如果你不是刚毕业那就转行吧,哈哈) 总括 这样的公司,一般算法和数据结构是必考的,操作系统也经常被问。如果是校招的话,笔试中还会有一些排列组合啊,语文表达啊,思维拓展啊(你咋不去高中招?高中刚毕业的时候比较符合需求!!),其次,笔试过了还会有好几轮面试,不管你说你扣过源码,还是跟过还可以的项目,都会被往深里问,再往深里问,再再往深里问! 比如说:你说你看过springMVC的源码,描述一遍请求处理流程肯定是必需的,然后你说完了,就会被挑一个点,接着往深里问!比如说:你说根据request找到handler,然后用handlerMapping找到对应的handlerAdapter,那么这一步具体是怎么实习的???问的我一脸蒙蔽啊,虽然还知道点,但是这种问题根本不会提前想到,只能现场组织语言。 再比如说:说说,你在这个项目里做的得意的东西是什么?然后你就说,说完了会问细节,怎么实现的?然后你再说,再说完了就让你优化,然后你墨迹半天终于优化完了,重点来了,让你重构!!如果让你从新设计这个系统,你会有哪些改进的地方??,,想想都心酸 ,,哈哈哈哈。 下边是一个简单的面试记录 问:说说你的突出点 答:java基础扎实(这个慌说的次数多了,现在说起来都没感觉了,哈哈),框架使用熟练(这个慌说了你们也发现不了,所以也没啥感觉),熟悉Tomcat源码,springMVC源码和结构。 问:如果想要统计springMVC每一个访问时长,放到log文件里,你在哪里做这个统计?为什么? 答:在preHandle拦截器里记录访问开始的时间,在postHandle里判断是哪个访问,计算访问时间并存储。 问:在posthandler里计算,并存储是吧。答:是。 问:为什么? 答了一个错误答案,然后又是一顿鄙视。,, 再问:用一个什么变量存?ThreadLocal?还是一个函数内部局部变量,? 答:线程内,(其实是在猜)。 问:为什么? 你不要猜,也不用在乎我的反应,无论你答什么我都会问你为什么。 答:函数内变量可能会不能覆盖整个访问的历程,,一顿鄙视,然后突然反应过来,不对,我说的有问题,外层函数是可以的,那就放在函数内局部变量里,节省资源。 问:如果我想把计算结果存到log里,在哪里做这个事情? 答:(悠长的停顿) 在posthandler处理结束,返回请求之前 问:为什么? 答:不占用处理请求的资源,(错误答案,已经慌乱) 问:确定? 答:不确定,,,停顿,,不对 ,还是会占用资源。 问:然后呢 答:(不说话了,,,)(后来想想,这事儿应该另起一个线程去做) (鄙视状,,,) 问:恩,说说Tomcat 答:(内心:幸亏没问tomcat优化,JVM优化,,不过,说说?说啥啊?难道说说这个干啥用的?还是说说哪个公司出的?说这些会不会直接赶人啊,,,就这样过了最少一分钟,哈哈)然后我就说了下tomcat的结构,和启动过程。 接着问:Tomcat和里面的Servlet是一个进程还是多个进程, 答:一个进程内 一顿鄙视,再问:为什么,,,?? 答:因为我觉得进程是分配资源的基本单位,一般来讲,一个应用就是一个进程。 问:你确定? (内心:大爷的,估计已经挂了,那我还怕个球,,,于是乎,坐直,平视,语气和神态突然就平静了) 答:确定。 问:你大学什么专业?学过操作系统吗? 答:计算机科学与技术,当然学过,我清楚的记得这一点,进程是分配资源的基本单位,不过,可能太久了,记不清了(其实内心是:你长的美,你说的都对)。 问:ok,一个应用可以启多个进程吗? 答:不可以 问:(鄙视状)确定? 答:(平静状)不太确定 问:呵呵 答:麻烦您给讲讲吧,我不太懂。 问:一个应用当然是可以启多个线程的,更何况还有跨应用的线程调用,资源也是可以动态分配的,,,(当时没听太懂,也记不清了。)。末了来一句,难道你就没打开过你的资源管理器看过吗? 答:当然看过,不过都是卡了才看,看哪个程序占用太高,给结束了。(内心:看过,但是跟这个问题有毛关系吗??) 上边是俩个长问题,还有一些其他的,例如: 问:你觉得要做一个厉害的程序员应该具备哪些特点? 这个就是一些,FQ啊,工具啊,总结啊,交流啊什么的;比如说,善用google,要至少对一个跨平台的工具很了解,善于学习最新的技术,善于掌握有力的工具,多逛各大社区,善于总结。(我就随便一写,找工作的话,要提前准备类似问题。) 问:我看你学了这么多东西,但是好像没有认真的去思考过为什么,你有没有想过当你记忆达到一个上限时你还能学什么?你还能干什么? 这个当然是要反驳的,我说我当然有思考,然后问你思考的啥,然后答当时就想知道Tomcat到springMVC的衔接是怎么衔接的,然后被鄙视:那你直接打几个断点调试一下不完了吗,java的调试不是很强吗?(貌似这个他也不太确定。而我也不知道断点打到哪去,更不用提怎么调试,哈哈)。 问:我看你这写的有一个了解分布式处理,分布式处理是什么?我怎么没听过。(这个就是一个概念问题,不重要。) 如有错误欢迎指正,暂时就这样吧,最近略忙,后边可能会改。 下面分享的2018一线互联网企业最新技术干货讲解,获取可加 程序员学习交流群: 878249276,欢迎一到五年的工程师加入,合理利用自己每一分每一秒的时间来学习提 升自己,不要再用"没有时间“来掩饰自己思想上的懒惰!趁年轻,使劲拼,给未来的自己一个交代!

优秀的个人博客,低调大师

keepalived + nginx轮询方式 做高可用和负载均衡 访问后端apache web 服务

keepalived+nginx+apache主备及双活搭建测试 keepalived+nginx高可用有主备和双活两种方式。主备方式下对外提供一个vip,同时只有一台服务器工作,另一台作备机;双活方式下对外提供两个vip,两台机器互为备份,下面详细说明搭建测试步骤: 配置: 主机 ip 操作系统 软件 vip nginx01 192.168.2.185 Centos7 nginx 端口82 keepalived 192.168.2.189 nginx02 192.168.2.186 Centos7 nginx 端口82 keepalived 192.168.2.189 web01 192.168.2.187 Centos7 apache 端口80 / web02 192.168.2.188 Centos7 apache 端口80 / 1.nginx01安装nginx [root@nginx01 ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@nginx01 ~]# yum -y install gcc-c++ [root@nginx01 ~]# yum -y install pcre pcre-devel [root@nginx01 ~]# yum -y install zlib zlib-devel [root@nginx01 ~]# yum -y install openssl openssl-devel 下载https://nginx.org/en/download.html https://nginx.org/download/nginx-1.12.2.tar.gz [root@nginx01 ~]# mkdir software [root@nginx01 ~]# cd software/ [root@nginx01 software]# wget https://nginx.org/download/nginx-1.12.2.tar.gz [root@nginx01 software]# ls -ltr total 960 -rw-r--r--. 1 root root 981687 Oct 17 21:20 nginx-1.12.2.tar.gz [root@nginx01 software]# tar -zxvf nginx-1.12.2.tar.gz [root@nginx01 software]# chown -R root.root nginx-1.12.2 [root@nginx01 software]# groupadd nginx [root@nginx01 software]# useradd -g nginx -d /home/nginx -s /sbin/nologin nginx [root@nginx01 software]# id nginx uid=1000(nginx) gid=1000(nginx) groups=1000(nginx) [root@nginx01 software]# grep nginx /etc/passwd nginx:x:1000:1000::/home/nginx:/sbin/nologin [root@nginx01 software]# [root@nginx01 nginx-1.12.2]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module | tee -a configure_nginx_20180417.log ....... ....... ....... Configuration summary + using system PCRE library + using system OpenSSL library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp" [root@nginx01 nginx-1.12.2]# make && make install | tee -a make_make_install_nginx_20180417.log ......... ......... ......... objs/ngx_modules.o \ -ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lz \ -Wl,-E sed -e "s|%%PREFIX%%|/usr/local/nginx|" \ -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/root/software/nginx-1.12.2' make -f objs/Makefile install make[1]: Entering directory `/root/software/nginx-1.12.2' test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx' test -d '/usr/local/nginx/sbin' \ || mkdir -p '/usr/local/nginx/sbin' test ! -f '/usr/local/nginx/sbin/nginx' \ || mv '/usr/local/nginx/sbin/nginx' \ '/usr/local/nginx/sbin/nginx.old' cp objs/nginx '/usr/local/nginx/sbin/nginx' test -d '/usr/local/nginx/conf' \ || mkdir -p '/usr/local/nginx/conf' cp conf/koi-win '/usr/local/nginx/conf' cp conf/koi-utf '/usr/local/nginx/conf' cp conf/win-utf '/usr/local/nginx/conf' test -f '/usr/local/nginx/conf/mime.types' \ || cp conf/mime.types '/usr/local/nginx/conf' cp conf/mime.types '/usr/local/nginx/conf/mime.types.default' test -f '/usr/local/nginx/conf/fastcgi_params' \ || cp conf/fastcgi_params '/usr/local/nginx/conf' cp conf/fastcgi_params \ '/usr/local/nginx/conf/fastcgi_params.default' test -f '/usr/local/nginx/conf/fastcgi.conf' \ || cp conf/fastcgi.conf '/usr/local/nginx/conf' cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default' test -f '/usr/local/nginx/conf/uwsgi_params' \ || cp conf/uwsgi_params '/usr/local/nginx/conf' cp conf/uwsgi_params \ '/usr/local/nginx/conf/uwsgi_params.default' test -f '/usr/local/nginx/conf/scgi_params' \ || cp conf/scgi_params '/usr/local/nginx/conf' cp conf/scgi_params \ '/usr/local/nginx/conf/scgi_params.default' test -f '/usr/local/nginx/conf/nginx.conf' \ || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf' cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default' test -d '/usr/local/nginx/logs' \ || mkdir -p '/usr/local/nginx/logs' test -d '/usr/local/nginx/logs' \ || mkdir -p '/usr/local/nginx/logs' test -d '/usr/local/nginx/html' \ || cp -R html '/usr/local/nginx' test -d '/usr/local/nginx/logs' \ || mkdir -p '/usr/local/nginx/logs' make[1]: Leaving directory `/root/software/nginx-1.12.2' [root@nginx01 nginx-1.12.2]# cd /usr/local/nginx/sbin/ [root@nginx01 sbin]# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx [root@nginx01 sbin]# nginx -v nginx version: nginx/1.12.2 [root@nginx01 sbin]# 查看加载模块 [root@nginx01 sbin]# nginx -V nginx version: nginx/1.12.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module [root@nginx01 sbin]# Nginx相关启动任务 [root@nginx01 sbin]# nginx [root@nginx01 sbin]# ps -ef | grep nginx root 5241 1 0 00:35 ? 00:00:00 nginx: master process nginx nginx 5242 5241 0 00:35 ? 00:00:00 nginx: worker process root 5244 2517 1 00:35 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 sbin]# nginx -s stop [root@nginx01 sbin]# ps -ef | grep nginx root 5247 2517 0 00:35 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 sbin]# nginx -s quit nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory) [root@nginx01 sbin]# nginx [root@nginx01 sbin]# nginx -s quit [root@nginx01 sbin]# ps -ef | grep nginx root 5254 2517 0 00:36 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 sbin]# nginx [root@nginx01 sbin]# nginx -s reload [root@nginx01 sbin]# [root@nginx01 sbin]# ps -ef | grep nginx root 5257 1 0 00:36 ? 00:00:00 nginx: master process nginx nginx 5260 5257 0 00:36 ? 00:00:00 nginx: worker process root 5262 2517 0 00:36 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 sbin]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@nginx01 sbin]# nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。 nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。 nginx -s reload:动态加载,当配置文件nginx.conf有变化时执行该命令动态加载。 Nginx开机自启动 [root@nginx01 sbin]# cd /etc/rc.d [root@nginx01 rc.d]# ls -ltr total 4 -rw-r--r--. 1 root root 473 Nov 7 2016 rc.local drwxr-xr-x. 2 root root 70 Mar 12 18:54 init.d drwxr-xr-x. 2 root root 45 Mar 12 18:54 rc6.d drwxr-xr-x. 2 root root 45 Mar 12 18:54 rc5.d drwxr-xr-x. 2 root root 45 Mar 12 18:54 rc4.d drwxr-xr-x. 2 root root 45 Mar 12 18:54 rc3.d drwxr-xr-x. 2 root root 45 Mar 12 18:54 rc2.d drwxr-xr-x. 2 root root 45 Mar 12 18:54 rc1.d drwxr-xr-x. 2 root root 45 Mar 12 18:54 rc0.d [root@nginx01 rc.d]# cat rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local [root@nginx01 rc.d]# echo "/usr/local/nginx/sbin/nginx" > rc.local [root@nginx01 rc.d]# chmod u+x rc.local [root@nginx01 rc.d]# view rc.local [root@nginx01 rc.d]# cat rc.local /usr/local/nginx/sbin/nginx [root@nginx01 rc.d]# ls -ltr rc.local -rwxr--r--. 1 root root 28 Apr 18 00:39 rc.local [root@nginx01 rc.d]# ps -ef | grep nginx root 5257 1 0 00:36 ? 00:00:00 nginx: master process nginx nginx 5260 5257 0 00:36 ? 00:00:00 nginx: worker process root 5271 2517 0 00:39 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 rc.d]# nginx -s quit [root@nginx01 rc.d]# ps -ef | grep nginx root 5274 2517 0 00:39 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 rc.d]# ./rc.local [root@nginx01 rc.d]# ps -ef | grep nginx root 5277 1 0 00:39 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx nginx 5278 5277 0 00:39 ? 00:00:00 nginx: worker process root 5280 2517 0 00:39 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 rc.d]# 至此nginx安装成功,nginx02也按nginx01的上面的操作执行一遍 2.配置nginx [root@nginx01 rc.d]# cp -p /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bk.2018 [root@nginx01 rc.d]# grep -v '#' /usr/local/nginx/conf/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } [root@nginx01 rc.d]# cp -p /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bk.2018 [root@nginx01 rc.d]# vi /usr/local/nginx/conf/nginx.conf [root@nginx01 rc.d]# diff /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bk.2018 34,37d33 < upstream webser{ < server 192.168.2.187:80; < server 192.168.2.188:80; < } 48,50c44,45 < proxy_pass http://webser; < #root html; < #index index.html index.htm; --- > root html; > index index.html index.htm; [root@nginx01 rc.d]# cat /usr/local/nginx/conf/nginx.conf #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } 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; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; upstream webser{ server 192.168.2.187:80; server 192.168.2.188:80; } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://webser; #root html; #index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } [root@nginx01 rc.d]# [root@nginx01 rc.d]# grep -v '#' /usr/local/nginx/conf/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream webser{ server 192.168.2.187:80; server 192.168.2.188:80; } server { listen 80; server_name localhost; location / { proxy_pass http://webser; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 重启nginx生效 [root@nginx01 rc.d]# nginx -s reload [root@nginx01 rc.d]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@nginx01 rc.d]# nginx -s quit [root@nginx01 rc.d]# ps -ef | grep nginx root 5299 2517 0 00:52 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 rc.d]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@nginx01 rc.d]# nginx [root@nginx01 rc.d]# ps -ef | grep nginx root 5302 1 0 00:52 ? 00:00:00 nginx: master process nginx nginx 5303 5302 0 00:52 ? 00:00:00 nginx: worker process root 5305 2517 0 00:52 pts/0 00:00:00 grep --color=auto nginx [root@nginx01 rc.d]# nginx01 nginx配置完成 nginx02 也按照上面一样的配置 [root@nginx02 rc.d]# cp -p /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bk.20180417 [root@nginx01 rc.d]# scp -p /usr/local/nginx/conf/nginx.conf 192.168.2.186:/usr/local/nginx/conf/nginx.conf The authenticity of host '192.168.2.186 (192.168.2.186)' can't be established. ECDSA key fingerprint is eb:04:83:e8:3d:6e:e6:95:f0:c6:9c:6c:ba:78:34:66. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.2.186' (ECDSA) to the list of known hosts. root@192.168.2.186's password: nginx.conf 100% 2800 2.7KB/s 00:00 [root@nginx01 rc.d]# [root@nginx02 rc.d]# grep -v '#' /usr/local/nginx/conf/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream webser{ server 192.168.2.187:80; server 192.168.2.188:80; } server { listen 80; server_name localhost; location / { proxy_pass http://webser; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } [root@nginx02 rc.d]# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful [root@nginx02 rc.d]# nginx [root@nginx02 rc.d]# ps -ef | grep nginx root 5306 1 0 00:57 ? 00:00:00 nginx: master process nginx nginx 5307 5306 0 00:57 ? 00:00:00 nginx: worker process root 5309 2524 0 00:57 pts/0 00:00:00 grep --color=auto nginx [root@nginx02 rc.d]# 至此2台nginx配置成功 3.keepalived 的安装 [root@nginx01 softare]# pwd /root/softare [root@nginx01 software]# yum -y install keepalived | tee -a install_keepalived_20180417.log [root@nginx02 softare]# yum -y install keepalived | tee -a install_keepalived_20180417.log Keepalived 配置 查看keepalived 安装了那些文件 [root@nginx01 softare]# rpm -qa keepalived keepalived-1.3.5-1.el7.x86_64 [root@nginx02 softare]# rpm -ql keepalived /etc/keepalived /etc/keepalived/keepalived.conf /etc/sysconfig/keepalived /usr/bin/genhash /usr/lib/systemd/system/keepalived.service /usr/libexec/keepalived /usr/sbin/keepalived /usr/share/doc/keepalived-1.3.5 /usr/share/doc/keepalived-1.3.5/AUTHOR /usr/share/doc/keepalived-1.3.5/CONTRIBUTORS /usr/share/doc/keepalived-1.3.5/COPYING /usr/share/doc/keepalived-1.3.5/ChangeLog /usr/share/doc/keepalived-1.3.5/NOTE_vrrp_vmac.txt /usr/share/doc/keepalived-1.3.5/README /usr/share/doc/keepalived-1.3.5/TODO /usr/share/doc/keepalived-1.3.5/keepalived.conf.SYNOPSIS /usr/share/doc/keepalived-1.3.5/samples /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.HTTP_GET.port /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.IPv6 /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.SMTP_CHECK /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.SSL_GET /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.fwmark /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.inhibit /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.misc_check /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.misc_check_arg /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.quorum /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.sample /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.status_code /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.track_interface /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.virtual_server_group /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.virtualhost /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp.localcheck /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp.lvs_syncd /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp.routes /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp.rules /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp.scripts /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp.static_ipaddress /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp.sync /usr/share/doc/keepalived-1.3.5/samples/sample.misccheck.smbcheck.sh /usr/share/man/man1/genhash.1.gz /usr/share/man/man5/keepalived.conf.5.gz /usr/share/man/man8/keepalived.8.gz /usr/share/snmp/mibs/KEEPALIVED-MIB.txt /usr/share/snmp/mibs/VRRP-MIB.txt /usr/share/snmp/mibs/VRRPv3-MIB.txt [root@nginx02 softare]# [root@nginx01 software]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 #smtp_connect_timeout 30 router_id LVS_DEVEL1 vrrp_skip_check_adv_addr vrrp_strict vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script chk_nginx { script "/etc/keepalived/check_nginx.sh" interval 2 weight 20 fall 1 rise 10 } vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.189 } track_script { chk_nginx } } [root@nginx01 software]# [root@nginx01 software]# vi /etc/keepalived/check_nginx.sh [root@nginx01 software]# chmod u+x /etc/keepalived/check_nginx.sh [root@nginx01 software]# cat /etc/keepalived/check_nginx.sh #!/bin/bash A=`ps -C nginx --no-header |wc -l` if [ $A -eq 0 ];then /usr/local/nginx/sbin/nginx if [ `ps -C nginx --no-header |wc -l` -eq 0 ];then pkill keep fi fi [root@nginx01 software]# [root@nginx01 ~]# systemctl start keepalived [root@nginx01 ~]# systemctl enable keepalived Created symlink from /etc/systemd/system/multi-user.target.wants/keepalived.service to /usr/lib/systemd/system/keepalived.service. [root@nginx01 ~]# nginx01上的keepalived 配置完成 配置nginx02上的keepalived [root@nginx02 softare]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 #smtp_connect_timeout 30 router_id LVS_DEVEL2 vrrp_skip_check_adv_addr vrrp_strict vrrp_garp_interval 0 vrrp_gna_interval 0 } vrrp_script chk_nginx { script "/etc/keepalived/check_nginx.sh" interval 2 weight 20 fall 2 rise 1 } vrrp_instance VI_1 { state BACKUP interface ens33 virtual_router_id 51 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.189 } track_script { chk_nginx } } 该脚本用户检测nginx进程是否存在,若不存在则重启,若重启失败则直接杀掉keepalived进程,触发切换。(若没有pkill命令请先安装) [root@nginx02 softare]# vi "/etc/keepalived/check_nginx.sh" [root@nginx02 softare]# cat "/etc/keepalived/check_nginx.sh" #!/bin/bash A=`ps -C nginx --no-header |wc -l` if [ $A -eq 0 ];then /usr/local/nginx/sbin/nginx if [ `ps -C nginx --no-header |wc -l` -eq 0 ];then pkill keep fi fi [root@nginx02 ~]# chmod u+x "/etc/keepalived/check_nginx.sh" [root@nginx02 softare]# [root@nginx02 ~]# systemctl start keepalived [root@nginx02 ~]# systemctl enable keepalived Created symlink from /etc/systemd/system/multi-user.target.wants/keepalived.service to /usr/lib/systemd/system/keepalived.service. Nginx02上的keepalived配置完成 Apache安装 在web01和web02上分别安装apache [root@web01 software]# yum -y install httpd httpd-devel | tee -a yum_install_apache_20180417.log Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-67.el7.centos.6 will be installed --> Processing Dependency: httpd-tools = 2.4.6-67.el7.centos.6 for package: httpd-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-67.el7.centos.6.x86_64 ---> Package httpd-devel.x86_64 0:2.4.6-67.el7.centos.6 will be installed --> Processing Dependency: perl >= 5.004 for package: httpd-devel-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: perl(strict) for package: httpd-devel-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: apr-util-devel for package: httpd-devel-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: apr-devel for package: httpd-devel-2.4.6-67.el7.centos.6.x86_64 --> Processing Dependency: /usr/bin/perl for package: httpd-devel-2.4.6-67.el7.centos.6.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed ---> Package apr-devel.x86_64 0:1.4.8-3.el7_4.1 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package apr-util-devel.x86_64 0:1.5.2-6.el7 will be installed --> Processing Dependency: openldap-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64 --> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64 --> Processing Dependency: expat-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64 ---> Package httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 will be installed ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed ---> Package perl.x86_64 4:5.16.3-292.el7 will be installed --> Processing Dependency: perl-libs = 4:5.16.3-292.el7 for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl-macros for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl-libs for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-292.el7.x86_64 --> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.16.3-292.el7.x86_64 --> Running transaction check ---> Package expat-devel.x86_64 0:2.1.0-10.el7_3 will be installed --> Processing Dependency: expat = 2.1.0-10.el7_3 for package: expat-devel-2.1.0-10.el7_3.x86_64 ---> Package libdb-devel.x86_64 0:5.3.21-21.el7_4 will be installed --> Processing Dependency: libdb(x86-64) = 5.3.21-21.el7_4 for package: libdb-devel-5.3.21-21.el7_4.x86_64 ---> Package openldap-devel.x86_64 0:2.4.44-5.el7 will be installed --> Processing Dependency: openldap(x86-64) = 2.4.44-5.el7 for package: openldap-devel-2.4.44-5.el7.x86_64 --> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.44-5.el7.x86_64 ---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed ---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed ---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed ---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed ---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed ---> Package perl-Getopt-Long.noarch 0:2.40-2.el7 will be installed --> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-2.el7.noarch --> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-2.el7.noarch ---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed ---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch --> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch ---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed ---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed ---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed ---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed ---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed ---> Package perl-constant.noarch 0:1.27-2.el7 will be installed ---> Package perl-libs.x86_64 4:5.16.3-292.el7 will be installed ---> Package perl-macros.x86_64 4:5.16.3-292.el7 will be installed ---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed ---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed --> Running transaction check ---> Package cyrus-sasl-devel.x86_64 0:2.1.26-21.el7 will be installed --> Processing Dependency: cyrus-sasl-lib(x86-64) = 2.1.26-21.el7 for package: cyrus-sasl-devel-2.1.26-21.el7.x86_64 --> Processing Dependency: cyrus-sasl(x86-64) = 2.1.26-21.el7 for package: cyrus-sasl-devel-2.1.26-21.el7.x86_64 ---> Package expat.x86_64 0:2.1.0-8.el7 will be updated ---> Package expat.x86_64 0:2.1.0-10.el7_3 will be an update ---> Package libdb.x86_64 0:5.3.21-19.el7 will be updated --> Processing Dependency: libdb(x86-64) = 5.3.21-19.el7 for package: libdb-utils-5.3.21-19.el7.x86_64 ---> Package libdb.x86_64 0:5.3.21-21.el7_4 will be an update ---> Package openldap.x86_64 0:2.4.40-13.el7 will be updated ---> Package openldap.x86_64 0:2.4.44-5.el7 will be an update ---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed ---> Package perl-Pod-Escapes.noarch 1:1.04-292.el7 will be installed ---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed --> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch --> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch ---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed --> Running transaction check ---> Package cyrus-sasl.x86_64 0:2.1.26-21.el7 will be installed ---> Package cyrus-sasl-lib.x86_64 0:2.1.26-20.el7_2 will be updated ---> Package cyrus-sasl-lib.x86_64 0:2.1.26-21.el7 will be an update ---> Package libdb-utils.x86_64 0:5.3.21-19.el7 will be updated ---> Package libdb-utils.x86_64 0:5.3.21-21.el7_4 will be an update ---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed --> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch --> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch ---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed --> Running transaction check ---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed ---> Package perl-parent.noarch 1:0.225-244.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: httpd x86_64 2.4.6-67.el7.centos.6 updates 2.7 M httpd-devel x86_64 2.4.6-67.el7.centos.6 updates 194 k Installing for dependencies: apr x86_64 1.4.8-3.el7_4.1 updates 103 k apr-devel x86_64 1.4.8-3.el7_4.1 updates 188 k apr-util x86_64 1.5.2-6.el7 base 92 k apr-util-devel x86_64 1.5.2-6.el7 base 76 k cyrus-sasl x86_64 2.1.26-21.el7 base 88 k cyrus-sasl-devel x86_64 2.1.26-21.el7 base 310 k expat-devel x86_64 2.1.0-10.el7_3 base 57 k httpd-tools x86_64 2.4.6-67.el7.centos.6 updates 88 k libdb-devel x86_64 5.3.21-21.el7_4 updates 38 k mailcap noarch 2.1.41-2.el7 base 31 k openldap-devel x86_64 2.4.44-5.el7 base 801 k perl x86_64 4:5.16.3-292.el7 base 8.0 M perl-Carp noarch 1.26-244.el7 base 19 k perl-Encode x86_64 2.51-7.el7 base 1.5 M perl-Exporter noarch 5.68-3.el7 base 28 k perl-File-Path noarch 2.09-2.el7 base 26 k perl-File-Temp noarch 0.23.01-3.el7 base 56 k perl-Filter x86_64 1.49-3.el7 base 76 k perl-Getopt-Long noarch 2.40-2.el7 base 56 k perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k perl-PathTools x86_64 3.40-5.el7 base 82 k perl-Pod-Escapes noarch 1:1.04-292.el7 base 51 k perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k perl-Pod-Usage noarch 1.63-3.el7 base 27 k perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k perl-Socket x86_64 2.010-4.el7 base 49 k perl-Storable x86_64 2.45-3.el7 base 77 k perl-Text-ParseWords noarch 3.29-4.el7 base 14 k perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k perl-Time-Local noarch 1.2300-2.el7 base 24 k perl-constant noarch 1.27-2.el7 base 19 k perl-libs x86_64 4:5.16.3-292.el7 base 688 k perl-macros x86_64 4:5.16.3-292.el7 base 43 k perl-parent noarch 1:0.225-244.el7 base 12 k perl-podlators noarch 2.5.1-3.el7 base 112 k perl-threads x86_64 1.87-4.el7 base 49 k perl-threads-shared x86_64 1.43-6.el7 base 39 k Updating for dependencies: cyrus-sasl-lib x86_64 2.1.26-21.el7 base 155 k expat x86_64 2.1.0-10.el7_3 base 81 k libdb x86_64 5.3.21-21.el7_4 updates 719 k libdb-utils x86_64 5.3.21-21.el7_4 updates 132 k openldap x86_64 2.4.44-5.el7 base 354 k Transaction Summary ================================================================================ Install 2 Packages (+38 Dependent packages) Upgrade ( 5 Dependent packages) Total download size: 17 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. -------------------------------------------------------------------------------- Total 667 kB/s | 17 MB 00:26 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : libdb-5.3.21-21.el7_4.x86_64 1/50 Updating : expat-2.1.0-10.el7_3.x86_64 2/50 Installing : apr-1.4.8-3.el7_4.1.x86_64 3/50 Installing : apr-util-1.5.2-6.el7.x86_64 4/50 Updating : cyrus-sasl-lib-2.1.26-21.el7.x86_64 5/50 Updating : openldap-2.4.44-5.el7.x86_64 6/50 Installing : apr-devel-1.4.8-3.el7_4.1.x86_64 7/50 Installing : cyrus-sasl-2.1.26-21.el7.x86_64 8/50 Installing : cyrus-sasl-devel-2.1.26-21.el7.x86_64 9/50 Installing : openldap-devel-2.4.44-5.el7.x86_64 10/50 Installing : httpd-tools-2.4.6-67.el7.centos.6.x86_64 11/50 Installing : expat-devel-2.1.0-10.el7_3.x86_64 12/50 Installing : libdb-devel-5.3.21-21.el7_4.x86_64 13/50 Installing : apr-util-devel-1.5.2-6.el7.x86_64 14/50 Installing : 1:perl-parent-0.225-244.el7.noarch 15/50 Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 16/50 Installing : perl-podlators-2.5.1-3.el7.noarch 17/50 Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 18/50 Installing : 1:perl-Pod-Escapes-1.04-292.el7.noarch 19/50 Installing : perl-Text-ParseWords-3.29-4.el7.noarch 20/50 Installing : perl-Encode-2.51-7.el7.x86_64 21/50 Installing : perl-Pod-Usage-1.63-3.el7.noarch 22/50 Installing : 4:perl-macros-5.16.3-292.el7.x86_64 23/50 Installing : 4:perl-libs-5.16.3-292.el7.x86_64 24/50 Installing : perl-Storable-2.45-3.el7.x86_64 25/50 Installing : perl-Exporter-5.68-3.el7.noarch 26/50 Installing : perl-constant-1.27-2.el7.noarch 27/50 Installing : perl-Time-Local-1.2300-2.el7.noarch 28/50 Installing : perl-Socket-2.010-4.el7.x86_64 29/50 Installing : perl-Carp-1.26-244.el7.noarch 30/50 Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 31/50 Installing : perl-PathTools-3.40-5.el7.x86_64 32/50 Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 33/50 Installing : perl-File-Temp-0.23.01-3.el7.noarch 34/50 Installing : perl-File-Path-2.09-2.el7.noarch 35/50 Installing : perl-threads-shared-1.43-6.el7.x86_64 36/50 Installing : perl-threads-1.87-4.el7.x86_64 37/50 Installing : perl-Filter-1.49-3.el7.x86_64 38/50 Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 39/50 Installing : perl-Getopt-Long-2.40-2.el7.noarch 40/50 Installing : 4:perl-5.16.3-292.el7.x86_64 41/50 Installing : mailcap-2.1.41-2.el7.noarch 42/50 Installing : httpd-2.4.6-67.el7.centos.6.x86_64 43/50 Installing : httpd-devel-2.4.6-67.el7.centos.6.x86_64 44/50 Updating : libdb-utils-5.3.21-21.el7_4.x86_64 45/50 Cleanup : libdb-utils-5.3.21-19.el7.x86_64 46/50 Cleanup : openldap-2.4.40-13.el7.x86_64 47/50 Cleanup : cyrus-sasl-lib-2.1.26-20.el7_2.x86_64 48/50 Cleanup : libdb-5.3.21-19.el7.x86_64 49/50 Cleanup : expat-2.1.0-8.el7.x86_64 50/50 Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/50 Verifying : mailcap-2.1.41-2.el7.noarch 2/50 Verifying : perl-threads-shared-1.43-6.el7.x86_64 3/50 Verifying : perl-Storable-2.45-3.el7.x86_64 4/50 Verifying : apr-1.4.8-3.el7_4.1.x86_64 5/50 Verifying : perl-Exporter-5.68-3.el7.noarch 6/50 Verifying : perl-constant-1.27-2.el7.noarch 7/50 Verifying : perl-PathTools-3.40-5.el7.x86_64 8/50 Verifying : 4:perl-macros-5.16.3-292.el7.x86_64 9/50 Verifying : perl-File-Temp-0.23.01-3.el7.noarch 10/50 Verifying : httpd-devel-2.4.6-67.el7.centos.6.x86_64 11/50 Verifying : expat-devel-2.1.0-10.el7_3.x86_64 12/50 Verifying : 1:perl-parent-0.225-244.el7.noarch 13/50 Verifying : 4:perl-5.16.3-292.el7.x86_64 14/50 Verifying : cyrus-sasl-lib-2.1.26-21.el7.x86_64 15/50 Verifying : httpd-tools-2.4.6-67.el7.centos.6.x86_64 16/50 Verifying : cyrus-sasl-devel-2.1.26-21.el7.x86_64 17/50 Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 18/50 Verifying : perl-Time-Local-1.2300-2.el7.noarch 19/50 Verifying : 4:perl-libs-5.16.3-292.el7.x86_64 20/50 Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 21/50 Verifying : perl-Socket-2.010-4.el7.x86_64 22/50 Verifying : perl-Carp-1.26-244.el7.noarch 23/50 Verifying : perl-podlators-2.5.1-3.el7.noarch 24/50 Verifying : apr-util-1.5.2-6.el7.x86_64 25/50 Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 26/50 Verifying : openldap-2.4.44-5.el7.x86_64 27/50 Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 28/50 Verifying : 1:perl-Pod-Escapes-1.04-292.el7.noarch 29/50 Verifying : libdb-5.3.21-21.el7_4.x86_64 30/50 Verifying : perl-Pod-Usage-1.63-3.el7.noarch 31/50 Verifying : libdb-devel-5.3.21-21.el7_4.x86_64 32/50 Verifying : perl-Encode-2.51-7.el7.x86_64 33/50 Verifying : libdb-utils-5.3.21-21.el7_4.x86_64 34/50 Verifying : perl-Getopt-Long-2.40-2.el7.noarch 35/50 Verifying : apr-devel-1.4.8-3.el7_4.1.x86_64 36/50 Verifying : perl-File-Path-2.09-2.el7.noarch 37/50 Verifying : apr-util-devel-1.5.2-6.el7.x86_64 38/50 Verifying : httpd-2.4.6-67.el7.centos.6.x86_64 39/50 Verifying : perl-threads-1.87-4.el7.x86_64 40/50 Verifying : expat-2.1.0-10.el7_3.x86_64 41/50 Verifying : perl-Filter-1.49-3.el7.x86_64 42/50 Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 43/50 Verifying : openldap-devel-2.4.44-5.el7.x86_64 44/50 Verifying : cyrus-sasl-2.1.26-21.el7.x86_64 45/50 Verifying : cyrus-sasl-lib-2.1.26-20.el7_2.x86_64 46/50 Verifying : libdb-5.3.21-19.el7.x86_64 47/50 Verifying : expat-2.1.0-8.el7.x86_64 48/50 Verifying : libdb-utils-5.3.21-19.el7.x86_64 49/50 Verifying : openldap-2.4.40-13.el7.x86_64 50/50 Installed: httpd.x86_64 0:2.4.6-67.el7.centos.6 httpd-devel.x86_64 0:2.4.6-67.el7.centos.6 Dependency Installed: apr.x86_64 0:1.4.8-3.el7_4.1 apr-devel.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 apr-util-devel.x86_64 0:1.5.2-6.el7 cyrus-sasl.x86_64 0:2.1.26-21.el7 cyrus-sasl-devel.x86_64 0:2.1.26-21.el7 expat-devel.x86_64 0:2.1.0-10.el7_3 httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 libdb-devel.x86_64 0:5.3.21-21.el7_4 mailcap.noarch 0:2.1.41-2.el7 openldap-devel.x86_64 0:2.4.44-5.el7 perl.x86_64 4:5.16.3-292.el7 perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-2.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-Pod-Escapes.noarch 1:1.04-292.el7 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-292.el7 perl-macros.x86_64 4:5.16.3-292.el7 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 Dependency Updated: cyrus-sasl-lib.x86_64 0:2.1.26-21.el7 expat.x86_64 0:2.1.0-10.el7_3 libdb.x86_64 0:5.3.21-21.el7_4 libdb-utils.x86_64 0:5.3.21-21.el7_4 openldap.x86_64 0:2.4.44-5.el7 Complete! [root@web01 software]# [root@web02 software]# yum -y install httpd httpd-devel | tee -a yum_install_apache_20180417.log [root@web01 software]# systemctl start httpd [root@web01 software]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@web01 software]# echo web01-192.168.2.187 > /var/www/html/index.html [root@web01 software]# [root@web02 software]# systemctl start httpd [root@web02 software]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@web02 software]# echo web02-192.168.2.188 > /var/www/html/index.html [root@web02 software]# 关闭所有服务器的防火墙和selinux [root@nginx01 ~]# systemctl stop firewalld.service [root@nginx01 ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. [root@nginx01 ~]# firewall-cmd --state not running [root@nginx01 ~]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28 [root@nginx01 ~]# setenforce 0 [root@nginx01 ~]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28 [root@nginx01 ~]# vi /etc/selinux/config [root@nginx01 ~]# grep -v '#' /etc/selinux/config SELINUX=disabled SELINUXTYPE=targeted [root@nginx01 ~]# 重启所有服务 [root@nginx01 ~]# nginx -s reload [root@nginx01 ~]# systemctl restart keepalived [root@nginx02 ~]# nginx -s reload [root@nginx02 ~]# systemctl restart keepalived [root@nginx02 ~]# [root@web01 software]# systemctl restart httpd [root@web01 software]# [root@web02 software]# systemctl restart httpd [root@web02 software]# 高可用测试 [root@nginx01 ~]# ip ad 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:6f:aa:40 brd ff:ff:ff:ff:ff:ff inet 192.168.2.185/24 brd 192.168.2.255 scope global ens33 valid_lft forever preferred_lft forever inet 192.168.2.189/32 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::6ceb:c635:2a8e:56b1/64 scope link valid_lft forever preferred_lft forever inet6 fe80::acee:8487:9f9d:5909/64 scope link tentative dadfailed valid_lft forever preferred_lft forever inet6 fe80::1766:5ed5:664c:7324/64 scope link tentative dadfailed valid_lft forever preferred_lft forever [root@nginx01 ~]# 无法通过访问192.168.2.189 修改keepalived 配置 [root@nginx01 ~]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 #smtp_connect_timeout 30 router_id proxy1 #vrrp_skip_check_adv_addr #vrrp_strict #vrrp_garp_interval 0 #vrrp_gna_interval 0 } vrrp_script chk_nginx { script "/etc/keepalived/check_nginx.sh" interval 2 weight 20 fall 1 rise 10 } vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.189 } track_script { chk_nginx } } [root@nginx01 ~]# [root@nginx02 ~]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 #smtp_connect_timeout 30 router_id proxy2 #vrrp_skip_check_adv_addr #vrrp_strict #vrrp_garp_interval 0 #vrrp_gna_interval 0 } vrrp_script chk_nginx { script "/etc/keepalived/check_nginx.sh" interval 2 weight 20 fall 2 rise 1 } vrrp_instance VI_1 { state BACKUP interface ens33 virtual_router_id 51 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.189 } track_script { chk_nginx } } [root@nginx02 ~]# 重启上面2个keepalived. 继续测试 1.先确保web01和web02可以直接访问 Web01: ![](https://s1.51cto.com/images/blog/201804/23/0f18667d461dd918adcc7697d846b0c2.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) Web02: ![](https://s1.51cto.com/images/blog/201804/23/9be3721d1c53559cc4a0e87455030c6d.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) 查看nginx01和nginx02 IP [root@nginx01 ~]# ip ad | grep 192.168 inet 192.168.2.185/24 brd 192.168.2.255 scope global ens33 inet 192.168.2.189/32 scope global ens33 [root@nginx02 ~]# ip ad | grep 192.168 inet 192.168.2.186/24 brd 192.168.2.255 scope global ens33 [root@nginx02 ~]# 可见当前是nginx01提供keepalived 服务 访问vritual IP 192.168.2.189 可见keepalived 是基于nginx已IP轮询方式提供服务 ![](https://s1.51cto.com/images/blog/201804/18/8b3de4baae37910a8cbf503ce2926f71.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ![](https://s1.51cto.com/images/blog/201804/18/1d103fb7da2c969a25bd58e2fd7763d4.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) 停掉nginx01上的keepalived 相当于nginx01宕机 [root@nginx01 ~]# systemctl stop keepalived [root@nginx01 ~]# ip ad | grep 192.168 inet 192.168.2.185/24 brd 192.168.2.255 scope global ens33 [root@nginx01 ~]# [root@nginx02 ~]# ip ad | grep 192.168 inet 192.168.2.186/24 brd 192.168.2.255 scope global ens33 inet 192.168.2.189/32 scope global ens33 此时nginx02上的keepalived从backup提升为master 刷新访问virtual IP 192.168.2.189 ,keepalived 会以nginx 轮询方式接受访问web服务器。 ![](https://s1.51cto.com/images/blog/201804/18/83fe30f8b9cdc5d7cf5d9ada4981844d.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ![](https://s1.51cto.com/images/blog/201804/18/90e00cd64619a9c3aefe19cff9c17111.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) 测试通过。 双活架构模式: 配置主机 ip 操作系统 软件 vip nginx01 192.168.2.185 Centos7 nginx 端口82 keepalived 192.168.2.189 nginx02 192.168.2.186 Centos7 nginx 端口82 keepalived 192.168.2.190 web01 192.168.2.187 Centos7 apache 端口80 / web02 192.168.2.188 Centos7 apache 端口80 / Nginx01配置: [root@nginx01 ~]# cp -p /etc/keepalived/keepalived.conf /etc/keepal ived/keepalived.conf.bk.20140418_master_backup_mode [root@nginx01 ~]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 #smtp_connect_timeout 30 router_id proxy1 #vrrp_skip_check_adv_addr #vrrp_strict #vrrp_garp_interval 0 #vrrp_gna_interval 0 } vrrp_script chk_nginx { script "/etc/keepalived/check_nginx.sh" interval 2 weight 20 fall 1 rise 10 } vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.189 } track_script { chk_nginx } } vrrp_instance VI_2 { state BACKUP interface ens33 virtual_router_id 52 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.190 } track_script { chk_nginx } } [root@nginx01 ~]# systemctl restart keepalived [root@nginx01 ~]# ip a | grep 192.168 inet 192.168.2.185/24 brd 192.168.2.255 scope global ens33 inet 192.168.2.189/32 scope global ens33 Nginx02的配置 [root@nginx02 ~]# cp -p /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bk.20140418_master_backup_mode [root@nginx02 ~]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc } notification_email_from Alexandre.Cassen@firewall.loc #smtp_server 192.168.200.1 #smtp_connect_timeout 30 router_id proxy2 #vrrp_skip_check_adv_addr #vrrp_strict #vrrp_garp_interval 0 #vrrp_gna_interval 0 } vrrp_script chk_nginx { script "/etc/keepalived/check_nginx.sh" interval 2 weight 20 fall 2 rise 1 } vrrp_instance VI_1 { state BACKUP interface ens33 virtual_router_id 51 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.189 } track_script { chk_nginx } } vrrp_instance VI_2 { state MASTER interface ens33 virtual_router_id 52 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.190 } track_script { chk_nginx } } [root@nginx02 ~]# ip a | grep 192.168 inet 192.168.2.186/24 brd 192.168.2.255 scope global ens33 inet 192.168.2.190/32 scope global ens33 页面访问测试 VIP 1 192.168.2.189 ![](https://s1.51cto.com/images/blog/201804/18/96fe794ef04c0967eaf59253ec704d77.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) 可知其以轮询方式去访问 VIP192.168.2.190 ![](https://s1.51cto.com/images/blog/201804/18/bc389d5fef3a689a8f591ea54a6df723.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) 高可用测试 Stop nginx上的 keepalived 模拟宕机 [root@nginx01 ~]# systemctl stop keepalived [root@nginx01 ~]# ip a | grep 192.168 inet 192.168.2.185/24 brd 192.168.2.255 scope global ens33 [root@nginx01 ~]# [root@nginx02 ~]# ip a | grep 192.168 inet 192.168.2.186/24 brd 192.168.2.255 scope global ens33 inet 192.168.2.190/32 scope global ens33 inet 192.168.2.189/32 scope global ens33 [root@nginx02 ~]# 页面访问: VIP 1 192.168.2.189 VIP 1 192.168.2.190 发现vip1和vip2访问web服务正常 现vip1漂移至vip2,nginx02接管nginx01的vip1,此时nginx02单独对外提供服务。 总结: 1.主备模式对外只提供一个vip,访问便捷,但同时只有一台服务器对外提供服务; 2.双活模式对外提供两个vip,访问比较麻烦,但同时又两台服务器对外提供服务; 3.不管主备模式还是双活模式都能高可用运行。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册