建站服务器
[root@shiyan~]#systemctldisablefirewalld [root@shiyan~]#systemctlstopfirewalld [root@shiyan~]#iptables–F
[root@shiyan~]#vim/etc/selinux/config SELINUX=disabled #保存重启系统生效
[root@shiyan~]#yuminstallkeepalivedhttpdnginx#(Nginx需要单独配置EPEL源)
[root@shiyan~]#yuminstallhttpd
[root@shiyan3~]#mkdir-p/app/apache/html/ [root@shiyan3~]#chown-Rapache.apache/app/apache/html/ [root@shiyan3~]#echoApacheServer1>/app/apache/html/index.html [root@shiyan3~]#vim/etc/httpd/conf/httpd.conf #此处是更改httpd.conf中的内容,并非添加内容 DocumentRoot/app/apache/html #更改为自定义的路径 # #Relaxaccesstocontentwithin/var/www. # <Directory/app/apache>#更改为自定义的路径 AllowOverrideNone #Allowopenaccess: Requireallgranted </Directory> #Furtherrelaxaccesstothedefaultdocumentroot: <Directory/app/apache/html>#更改为自定义的路径. [root@shiyan3~]#systemctlrestarthttpd #测试网站是否正常运行 [root@yum~]#curlhttp://172.18.17.33 ApacheServer1#测试成功
[root@shiyan4~]#mkdir-p/app/apache/html/ [root@shiyan4~]#chown-Rapache.apache/app/apache/html/ [root@shiyan4~]#echoApacheServer2>/app/apache/html/index.html [root@shiyan4~]#vim/etc/httpd/conf/httpd.conf #此处是更改httpd.conf中的内容,并非添加内容 DocumentRoot/app/apache/html #更改为自定义的路径 # #Relaxaccesstocontentwithin/var/www. # <Directory/app/apache>#更改为自定义的路径 AllowOverrideNone #Allowopenaccess: Requireallgranted </Directory> #Furtherrelaxaccesstothedefaultdocumentroot: <Directory/app/apache/html>#更改为自定义的路径. [root@shiyan4~]#systemctlrestarthttpd #测试网站是否正常运行 [root@yum~]#curlhttp://172.18.17.34 ApacheServer2#测试成功
配置Sorry-Server [root@shiyan1~]#mkdir-p/app/apache/html/ [root@shiyan1~]#chown-Rapache.apache/app/apache/html/ [root@shiyan1~]#echo<h2>SorryServer1</h2>>/app/apache/html/index.html [root@shiyan1~]#vim/etc/httpd/conf/httpd.conf #此处是更改httpd.conf中的内容,并非添加内容 Listen8080 DocumentRoot/app/apache/html #更改为自定义的路径 # #Relaxaccesstocontentwithin/var/www. # <Directory/app/apache>#更改为自定义的路径 AllowOverrideNone #Allowopenaccess: Requireallgranted </Directory> #Furtherrelaxaccesstothedefaultdocumentroot: <Directory/app/apache/html>#更改为自定义的路径. [root@shiyan1~]#systemctlrestarthttp #测试网站是否正常运行 [root@yum~]#curlhttp://172.18.17.31:8080 <h2>SorryServer1</h2>#测试成功 配置Keepalived [root@shiyan1~]#cp/etc/keepalived/keepalived.conf{,.bak}#备份文件 [root@shiyan1~]#vim/etc/keepalived/keepalived.conf global_defs{ notification_email{ root#定义收邮件的用户 } notification_email_fromAlexandre.Cassen@firewall.loc smtp_server172.18.17.31#定义邮件地址 smtp_connect_timeout30 router_idnode1#定义节点名称 } vrrp_instanceVI_1{ stateMASTER#定义节点为主节点模式 interfaceens33#定义使用ens33为VIP网卡 virtual_router_id51#定义节点编号 priority150#定义优先级 advert_int1 authentication{ auth_typePASS auth_pass1111 } virtual_ipaddress{ 172.18.17.30#定义VIP } } ~配置Nginx服务 [root@shiyan1~]#vim/etc/nginx/nginx.conf #添加nginx集群 upstreamwebsrvs{ server172.18.17.33:80; server172.18.17.34:80; server127.0.0.1:8080backup; } #server部分的内容需要全部注释掉 [root@shiyan1~]#vim/etc/nginx/conf.d/default.conf server{ listen80; location/{ roothtml; proxy_passhttp://websrvs; indexindex.htmlindex.htm; } } [root@shiyan1~]#systemctlrestartnginx [root@shiyan1~]#systemctlrestartkeepalived [root@shiyan1~]#systemctlrestarthttpd创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于网站建设、成都做网站、岐山网络推广、微信小程序定制开发、岐山网络营销、岐山企业策划、岐山品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们大的嘉奖;创新互联公司为所有大学生创业者提供岐山建站搭建服务,24小时服务热线:18982081108,官方网址:www.cdcxhl.com
配置Sorry-Server [root@shiyan2~]#mkdir-p/app/apache/html/ [root@shiyan2~]#chown-Rapache.apache/app/apache/html/ [root@shiyan2~]#echo<h2>SorryServer2</h2>>/app/apache/html/index.html [root@shiyan2~]#vim/etc/httpd/conf/httpd.conf #此处是更改httpd.conf中的内容,并非添加内容 Listen8080 DocumentRoot/app/apache/html #更改为自定义的路径 # #Relaxaccesstocontentwithin/var/www. # <Directory/app/apache>#更改为自定义的路径 AllowOverrideNone #Allowopenaccess: Requireallgranted </Directory> #Furtherrelaxaccesstothedefaultdocumentroot: <Directory/app/apache/html>#更改为自定义的路径. [root@shiyan2~]#systemctlrestarthttp #测试网站是否正常运行 [root@yum~]#curlhttp://172.18.17.31:8080 <h2>SorryServer2</h2>#测试成功 配置Keepalived [root@shiyan2~]#cp/etc/keepalived/keepalived.conf{,.bak}#备份文件 [root@shiyan2~]#vim/etc/keepalived/keepalived.conf global_defs{ notification_email{ root#定义收邮件的用户 } notification_email_fromAlexandre.Cassen@firewall.loc smtp_server172.18.17.31#定义邮件地址 smtp_connect_timeout30 router_idnode1#定义节点名称 } vrrp_instanceVI_1{ stateMASTER#定义节点为主节点模式 interfaceens33#定义使用ens33为VIP网卡 virtual_router_id51#定义节点编号 priority150#定义优先级 advert_int1 authentication{ auth_typePASS auth_pass1111 } virtual_ipaddress{ 172.18.17.30#定义VIP } } ~配置Nginx服务 [root@shiyan2~]#vim/etc/nginx/nginx.conf #添加nginx集群 upstreamwebsrvs{ server172.18.17.33:80; server172.18.17.34:80; server127.0.0.1:8080backup; } #server部分的内容需要全部注释掉 [root@shiyan2~]#vim/etc/nginx/conf.d/default.conf server{ listen80; location/{ roothtml; proxy_passhttp://websrvs; indexindex.htmlindex.htm; } } [root@shiyan2~]#systemctlrestartkeepalived [root@shiyan2~]#systemctlrestartnginx [root@shiyan2~]#systemctlrestarthttpd
#默认使用rr算法依次轮询访问后端httpd服务器 [root@yum~]#curlhttp://172.18.17.30 ApacheServer1 [root@yum~]#curlhttp://172.18.17.30 ApacheServer2 #关闭后端http1服务,这样只能访问httpd2的服务 [root@yum~]#curlhttp://172.18.17.30 ApacheServer2 [root@yum~]#curlhttp://172.18.17.30 ApacheServer2 #关闭两台后端主机的httpd服务,这样因为没有后端服务器所以Master的sorry-server提供服务 [root@yum~]#curlhttp://172.18.17.30 <h2>SorryServer1</h2> #关闭Master测试 [root@yum~]#curlhttp://172.18.17.30 <h2>SorryServer2</h2>
标题名称:Keepaliev+Nginx+http
标题URL:https://www.cdcxhl.com/article6/chshog.html
成都网站建设公司_创新互联,为您提供静态网站、网站营销、网页设计公司、定制开发、微信小程序、网站建设
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联