日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

No.7 nginx、nfs、集群

發布時間:2023/12/10 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 No.7 nginx、nfs、集群 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝并啟動nginx服務

1、二進制安裝nginx包

~ yum -y install epel-release && yum -y install nginx #配置環境 關閉防火墻 ~ iptables -F // 或 systemctl stop filewallf

2、作為web服務修改配置文件

~ vim /etc/nginx/nginx.conf //暫時不修改配置

3、讓配置生效,驗證配置

~ systemctl start nginx //啟動nginx服務 #systemctl disable firewalld 設置開機也不啟動防火墻 #systemctl enable firewalld 開機啟動防火墻 #systemctl enable nginx 開機啟動nginx #systemctl status nginx.service 查看nginx服務是否在運行 #systemctl reload nginx //重新加載配置文件 #nginx -s reload

安裝并設置啟用nfs服務

1、二進制安裝nfs

~ yum -y install nfs

2、作為共享存儲掛載在三臺web的網站根目錄下

  • nfs主機操作
~ vim /etc/exports ~ cat /etc/exports /Nfsdir 192.168.16.0/24(rw,sync,fsid=0) ~ mkdir /Nfsdir ~ echo 'this is a shared directory' > /Nfsdir/index.html ~ chmod -R o+w /Nfsdir //設置權限 ~ systemctl start rpcbind.service //啟動rpc服務 ~ systemctl start nfs-server.service //啟動nfs服務 ~ exportfs //查看是nfs否開啟成功 ~ showmount -a //查看當前和那幾個客戶端有鏈接 ~ showmount -e //默認查看自己的服務 ~ systemctl status rpcbind.service //查看rpc是否在運行 ~ systemctl status nfs-server.service //查看nfs服務是否在運行 ~ vim /etc/nginx/nginx.conf //修改目錄為Nfsdir ~ systemctl reload nginx //重新加載配置文件 ~ systemctl enable nfs-server.service // 設置開機啟動nfs ~ systemctl enable rpc-rquotad.service //開機啟動rpc
  • nfs 客戶端操作
~ mount -t nfs 192.168.16.180:/Nfsdir /var/www/html ~ vim /etc/nginx/nginx.conf //修改目錄為/var/www/html ~ systemctl reload nginx //nginx -s reload重新加載配置文件
  • 實現,在任意一臺web上修改的結果,其余兩臺都可以看到



nginx反向代理三臺web

  • 實現基于輪詢的方式調度三臺web,并驗證結果
~ vim /etc/nginx/nginx.conf http {upstream pythonweb {server 192.168.16.167;server 192.168.16.99:80;server 192.168.16.199;}

  • 實現基于權重的方式調度三臺web,并驗證結果
~ vim /etc/nginx/nginx.conf http {upstream pythonweb {server 192.168.16.167 weight=3;server 192.168.16.99:80;server 192.168.16.199;}
  • 實現基于hash的方式調用三臺web,并驗證結果
http {upstream pythonweb {ip_hash;server 192.168.16.167;server 192.168.16.99:80;server 192.168.16.199;}

nginx反向代理+三臺web+nfs共享存儲實現集群配置

# 客戶端修改網站根目錄為/web ~ mount -t nfs 192.168.16.180:/Nfsdir /web // vim /etc/fstab 開機就掛載的設備 ~ vim /etc/nginx/nginx.conf ~ systemctl reload nginx //重新加載配置文件 ~ vim /etc/selinux/config //關閉硬件防火墻 改為disabled 需要重啟 #setenforce 0 臨時關閉防火墻,不需要重啟
  • vim /etc/fstab
# /etc/fstab # Created by anaconda on Wed Mar 8 22:54:46 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/cl-root / xfs defaults 0 0 UUID=4b0a06e7-efa0-464e-b668-8d02da33c482 /boot xfs defaults 0 0 /dev/mapper/cl-swap swap swap defaults 0 0 #把共享nfs目錄開機掛載,公司環境會用到 192.168.16.180:/Nfsdir /web nfs defaults 0 0

源碼安裝nginx,并按照作業一描述的那樣去測試使用

  • 下載nginx
~ wget http://nginx.org/download/nginx-1.10.3.tar.gz ~ tar xvf nginx-1.10.3.tar.gz && cd nginx-1.10.3
  • 安裝nginx
~ ./configure --prefix=/usr/local/nginx #出現問題 ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
  • 安裝yum -y install pcre-devel 解決問題
~ yum -y install pcre-devel ~ ./configure //成功編譯 ~ make && make install ~ vim /etc/nginx/nginx.conf /修改配置文件 ~ systemctl start nginx

轉載于:https://www.cnblogs.com/hyhnm/p/6592125.html

總結

以上是生活随笔為你收集整理的No.7 nginx、nfs、集群的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。