(二)、NFS服务端部署
中小型规模网站集群架构:NFS-Server部署
: Ago linux运维群:https://hankbook.cn
1.整体思路
服务端:
- 安装nfs
- yum install -y nfs-utils rpcbind
- 目录
- /data
- 权限:755
- 所有者(组):www ID为888
useradd -s /sbin/nologin -M -u 888 www
- 配置文件/etc/exports
- 优化:
- anonuid = 888
- anongid = 888
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888)
客户端:
- 优化:
- 挂载参数
- mount -t nfs -o nosuid,noexec,nodev,noatime,nodiratime,rsize=131071,wsize=131072
- 内核参数
cat >> /etc/sysctl.conf << EOF
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
EOF
2.具体部署
配置文件nfs_exports
/nfsdata/dedecms 172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888)
/nfsdata/discuz 172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888)
/nfsdata/wordpress 172.16.1.0/24(rw,sync,all_squash,anonuid=888,anongid=888)
ansible执行剧本
---
- hosts: 172.16.1.31
tasks:
- name:
include: /server/playbook/base.yml
- name: "install nfs-server"
yum:
name: nfs-utils
state: installed
- name: "add www group"
group:
name: www
gid: 888
- name: "add www user"
user:
createhome: no
group: www
name: www
uid: 888
shell: /sbin/nologin
- name: "send cfg to server"
copy:
src: /server/files/nfs_exports
dest: /etc/exports
- name: "make nfs's server dedecms dir"
file:
path: /nfsdata/dedecms
state: directory
owner: www
group: www
- name: "make nfs's server discuz dir"
file:
path: /nfsdata/discuz
state: directory
owner: www
group: www
- name: "make nfs's server wordpress dir"
file:
path: /nfsdata/wordpress
state: directory
owner: www
group: www
- name: "rpcbind start..."
service:
name: rpcbind
state: started
- name: "nfs start..."
service:
name: nfs
state: started
- name:
yum:
name: sersync
state: installed