阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Nginx 集群负载均衡器

40次阅读
没有评论

共计 1604 个字符,预计需要花费 5 分钟才能阅读完成。

实验环境:

10.10.204.62 Load Balancing

10.10.204.63 Nginx Web server

10.10.204.64 Nginx Web server

10.10.204.65 File Storage

Nginx 集群负载均衡器

1.File Storage 服务器安装

yum -y install nfs-utils

2. 配置 NFS 并创建共享目录

# mkdir -p /Data/webapp
# vim /etc/exports

/Data/webapp 10.10.204.0/24(rw,sync,no_subtree_check,no_root_squash)

3. 开启自启动

# systemctl enable rpcbind
# systemctl enable nfs-server
# systemctl start rpcbind
# systemctl start nfs

4. 相关参数:

rw:read-write:可读写;ro:read-only,只读;sync:文件同时写入硬盘和内存。no_root_squash:来访的 root 用户保持 root 帐号权限;显然开启这项是不安全的。root_squash:将来访的 root 用户映射为匿名用户或用户组;通常它将使用 nobody 或 nfsnobody 身份。all_squash:所有访问用户都映射为匿名用户或用户组;anonuid:匿名用户的 UID 值,可以在此处自行设定。anongid:匿名用户的 GID 值。sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性。async:文件暂存于内存,而不是直接写入内存。no_subtree_check:即使输出目录是一个子目录,nfs 服务器也不检查其父目录的权限,这样可以提高效率。

5.File Storage 服务器防火墙配置

# firewall-cmd --permanent --add-service=rpc-bind
# firewall-cmd --permanent --add-service=nfs
# firewall-cmd --reload

6.Nginx Web server 服务器安装以及挂载

# yum -y install nfs-utils
# mkdir -p /Data/webapp
# mount -t nfs 10.10.204.65:/Data/webapp /Data/webapp

7. 如果需要开机自动挂载, 在该文件最下方添加一行即可

# vim /etc/fstab
10.10.204.65:/Data/webapp /Data/webapp nfs auto,rw,vers=3,hard,intr,tcp,rsize=32768,wsize=32768 0 0

8.Nginx Web server 服务器测试
连续写 16384 个 16KB 的块到 nfs 目录下的 testfile 文件

# time dd if=/dev/zero of=/Data/webapp/testfile bs=16k count=16384

  16384+0 records in
  16384+0 records out
  268435456 bytes (268 MB) copied, 2.89525 s, 92.7 MB/s
  real 0m2.944s
  user 0m0.015s
  sys 0m0.579s

测试读的性能

# time dd if=/nfsfolder/testfile of=/dev/null bs=16k
  16384+0 records in
  16384+0 records out
  268435456 bytes (268 MB) copied, 0.132925 s, 2.0 GB/s
  real 0m0.138s
  user 0m0.003s
  sys 0m0.127s

综合来讲,NFS 的速度还算理想。如果觉得速度慢,那么添加相关参数后,反复挂载卸载并测试读写,找到适合自己的配置方案。

阿里云 2 核 2G 服务器 3M 带宽 61 元 1 年,有高配

腾讯云新客低至 82 元 / 年,老客户 99 元 / 年

代金券:在阿里云专用满减优惠券

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2024-07-27发表,共计1604字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中