建站服務器
[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,官方網址:vcdvsql.cn
配置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:http://vcdvsql.cn/article6/chshog.html
成都網站建設公司_創新互聯,為您提供靜態網站、網站營銷、網頁設計公司、定制開發、微信小程序、網站建設
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯