真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

nginx反向代理docker,并用nfs同步docker-創(chuàng)新互聯(lián)

nginx反向代理docker,并用nfs同步docker
nginx1 192.168.1.10

為企業(yè)提供成都網(wǎng)站制作、成都做網(wǎng)站、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)營銷推廣、競價托管、品牌運營等營銷獲客服務(wù)。創(chuàng)新互聯(lián)建站擁有網(wǎng)絡(luò)營銷運營團隊,以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認(rèn)可!

nginx2 192.168.1.20

docker01 192.168.1.30

docker02 192.168.1.40

nfs主 192.168.1.50

nfs備 192.168.1.60

nfs1下載安裝nfs:
[root@nfs01 ~]# yum -y install nfs-utils

[root@nfs01 ~]# cd /datashare/
[root@nfs01 datashare]# vim /etc/exports

添加:

/datashare *(rw,sync,no_root_squash)

啟動:

[root@nfs01 datashare]# systemctl start rpcbind
[root@nfs01 datashare]# systemctl enable rpcbind
[root@nfs01 datashare]# systemctl start nfs-server
[root@nfs01 datashare]# systemctl enable nfs-server
docker01上操作:

導(dǎo)入鏡像:
nginx反向代理docker,并用nfs同步docker

[root@docker01 ~]# docker load < nginx.tar 

[root@docker01 ~]# mkdir /wwwroot
[root@docker01 ~]# mkdir /docker

[root@docker01 ~]# docker run -itd --name test nginx:latest

[root@docker01 ~]# docker cp test:/etc/nginx /docker/

[root@docker01 ~]# docker cp test:/usr/share/nginx/html /wwwroot/
[root@docker01 ~]# showmount -e 192.168.1.50
Export list for 192.168.1.50:
/datashare *

[root@docker01 ~]# mount 192.168.1.50:/datashare /wwwroot/html/

[root@docker01 ~]# docker run -itd --name nginx-web1 -v /docker/nginx:/etc/nginx -v /wwwroot/html:/usr/share/nginx/html -p 80:80 nginx:latest
docker02上操作:

導(dǎo)入鏡像:

nginx反向代理docker,并用nfs同步docker

[root@docker02 ~]# docker load < nginx.tar

[root@docker02 ~]# mkdir /wwwroot
[root@docker02 ~]# mkdir /docker

[root@docker02 ~]# docker run -itd --name test nginx:latest 

[root@docker02 ~]# docker cp test:/etc/nginx /docker/
[root@docker02 ~]# docker cp test:/usr/share/nginx/html /wwwroot/
[root@docker02 ~]# showmount -e 192.168.1.50
Export list for 192.168.1.50:
/datashare *

[root@docker02 ~]# mount 192.168.1.50:/datashare /wwwroot/html/

[root@docker02 ~]# docker run -itd --name nginx-web2 -v /docker/nginx:/etc/nginx -v /wwwroot/html:/usr/share/nginx/html -p 80:80 nginx:latest
更改docker01網(wǎng)頁界面,docker02上驗證同步:
[root@docker01 ~]# cd /wwwroot/html/

[root@docker01 html]# cat index.html 
skx nginx

[root@docker01 html]# curl 127.0.0.1
skx nginx

[root@docker02 ~]# curl 127.0.0.1
skx nginx

驗證成功
再nginx01和nginx02上做漂移地址:
nginx01:
[root@nginx01 ~]# yum -y install pcre-devel openssl-devel

導(dǎo)入鏡像:

nginx反向代理docker,并用nfs同步docker

[root@nginx01 ~]# tar zxf ngx_cache_purge-2.3.tar.gz 
[root@nginx01 ~]# unzip nginx-sticky-module.zip 

[root@nginx01 ~]# tar zxf nginx-1.14.0.tar.gz 

[root@nginx01 ~]# cd nginx-1.14.0/

[root@nginx01 nginx-1.14.0]#  ./configure --prefix=/usr/local/nginx1.14  --user=www --group=www   --with-http_stub_status_module --with-http_realip_module   --with-http_ssl_module --with-http_gzip_static_module   --http-client-body-temp-path=/var/tmp/nginx/client  --http-proxy-temp-path=/var/tmp/nginx/proxy   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi   --with-pcre  --with-http_flv_module   --add-module=../nginx-sticky-module  --add-module=../ngx_cache_purge-2.3 && make && make install

[root@nginx01 nginx-1.14.0]#  ln -s /usr/local/nginx1.14/sbin/nginx  /usr/local/sbin/

[root@nginx01 nginx-1.14.0]#  useradd www  -s /sbin/nologin -M

[root@nginx01 nginx-1.14.0]#  mkdir -p /var/tmp/nginx/client

[root@nginx01 nginx-1.14.0]# nginx
[root@nginx01 nginx-1.14.0]# netstat -anpt | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7711/nginx: master
nginx02:

nginx反向代理docker,并用nfs同步docker

[root@nginx02 ~]# tar zxf ngx_cache_purge-2.3.tar.gz 
[root@nginx02 ~]# unzip nginx-sticky-module.zip 

[root@nginx02 ~]# tar zxf nginx-1.14.0.tar.gz 

[root@nginx02 ~]#  yum -y install pcre-devel openssl-devel

[root@nginx02 ~]# cd nginx-1.14.0/

[root@nginx02 nginx-1.14.0]# ./configure --prefix=/usr/local/nginx1.14  --user=www --group=www   --with-http_stub_status_module --with-http_realip_module   --with-http_ssl_module --with-http_gzip_static_module   --http-client-body-temp-path=/var/tmp/nginx/client  --http-proxy-temp-path=/var/tmp/nginx/proxy   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi   --with-pcre  --with-http_flv_module   --add-module=../nginx-sticky-module  --add-module=../ngx_cache_purge-2.3 && make && make install

[root@nginx02 nginx-1.14.0]# ln -s /usr/local/nginx1.14/sbin/nginx /usr/local/sbin/
[root@nginx02 nginx-1.14.0]#  useradd www  -s /sbin/nologin -M
[root@nginx02 nginx-1.14.0]# mkdir -p /var/tmp/nginx/client

[root@nginx02 nginx-1.14.0]# nginx
[root@nginx02 nginx-1.14.0]# netstat -anpt | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7355/nginx: master
nginx01安裝keepalived:

nginx反向代理docker,并用nfs同步docker

[root@nginx01 ~]# tar -zxvf keepalived-1.2.13.tar.gz 

[root@nginx01 ~]# cd keepalived-1.2.13/
[root@nginx01 keepalived-1.2.13]# ./configure --prefix=/

[root@nginx01 keepalived-1.2.13]# make && make install
[root@nginx01 keepalived-1.2.13]# vim /etc/keepalived/keepalived.conf 

3行:

global_defs {
   router_id LVS_DEVEL_1
  }

14行:

   interface ens33

22行:

virtual_ipaddress {
        192.168.1.254 
    }
nginx02安裝keepalived:

nginx反向代理docker,并用nfs同步docker
[root@nginx01 ~]# tar -zxvf keepalived-1.2.13.tar.gz

[root@nginx01 ~]# cd keepalived-1.2.13/
[root@nginx01 keepalived-1.2.13]# ./configure --prefix=/

[root@nginx01 keepalived-1.2.13]# make && make install

[root@nginx02 keepalived-1.2.13]# vim /etc/keepalived/keepalived.conf

3行:

global_defs {
router_id LVS_DEVEL_2
}

14行:

? interface ens33

22行:

virtual_ipaddress {
192.168.1.254
}

docker01和docker02啟動服務(wù):

[root@nginx02 keepalived-1.2.13]# /etc/init.d/keepalived start
Reloading systemd: [ OK ]
Starting keepalived (via systemctl): [ OK ]

訪問:

![](https://s1.51cto.com/images/blog/201912/21/f4595e87674a32c6cb6c25a4f631861a.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

#### docker01和docker02做反向代理:

#### docker01:

[root@nginx01 ~]# vim /usr/local/nginx1.14/conf/nginx.conf

21行添加:

upstream backend {

? ip_hash;

? server 192.168.1.30:80 weight=1 max_fails=2 fail_timeout=10s;
? server 192.168.1.40:80 weight=1 max_fails=2 fail_timeout=10s;
? }

49行添加:

proxy_pass http://backend;

重啟服務(wù):

[root@nginx01 ~]# nginx -t
nginx: the configuration file /usr/local/nginx1.14/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx1.14/conf/nginx.conf test is successful
[root@nginx01 ~]# nginx -s reload

#### docker02:

33行添加:

upstream backend {
ip_hash;
server 192.168.1.30:80 weight=1 max_fails=2 fail_timeout=10s;
server 192.168.1.40:80 weight=1 max_fails=2 fail_timeout=10s;
}

50行添加:

proxy_pass http://backend;

重啟服務(wù):

[root@nginx01 ~]# nginx -t
nginx: the configuration file /usr/local/nginx1.14/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx1.14/conf/nginx.conf test is successful
[root@nginx01 ~]# nginx -s reload

瀏覽器用漂流地址訪問

#### 做NFS的Rsync+Inotify

#### nfs01:
![](https://s1.51cto.com/images/blog/201912/21/853d21d253a7f2ca29e7b1c5bd0a25bc.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

[root@nfs01 ~]# tar zxf inotify-tools-3.14.tar.gz
[root@nfs01 ~]# cd inotify-tools-3.14/
[root@nfs01 inotify-tools-3.14]# ./configure && make && make install

[root@nfs01 inotify-tools-3.14]# vim /etc/rsyncd.conf

最后一行添加:

gid = nobody
use chroot = yes
address = 192.168.1.50
port 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
hosts allow = 192.168.1.0/24
[wwwroot]
path = /datashare
read only = no
dont compress = .gz.tgz .zip.z .Z.rpm .deb.bz2

#### 編寫腳本來實現(xiàn)實時同步:

[root@nfs01 ~]# vim /inotify_sync.sh

#!/bin/bash

inotify_cmd="inotifywait -mrq -e modify,create,attrib,move,delete /datashare"

rsync_cmd="rsync -azH /datashare/* 192.168.2.40::wwwroot"

$inotify_cmd | while read DIRECTORY EVENT FILE

do

? $rsync_cmd

done

[root@nfs01 ~]# chmod +x /inotify_sync.sh

啟動服務(wù):

[root@nfs01 ~]# rsync --daemon

#### nfs02:

[root@nfs02 ~]# yum -y install rsync

[root@nfs02 ~]# vim /etc/rsyncd.conf

uid = nobody
gid = nobody
use chroot = yes
address = 192.168.1.60
port 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
hosts allow = 192.168.1.0/24
[wwwroot]
path = /datashare
read only = no
dont compress = .gz.tgz .zip.z .Z.rpm .deb.bz2

[root@nfs02 ~]# mkdir /datashare

#### nfs01:

[root@nfs01 ~]# sh /inotify_sync.sh

nfs02:

#### 驗證:

[root@nfs02 ~]# cat /datashare/

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


新聞標(biāo)題:nginx反向代理docker,并用nfs同步docker-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://weahome.cn/article/djijcj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部