Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use NFS service to achieve website data synchronization?

Shulou Source: shulou.com Published: 2022-06-03 06:08:20 09月30日 Update

How to use NFS service to achieve website data synchronization? This problem may be often seen in our daily work. Through this question, I hope you can gain more. Let's take a look at the solution with the editor today.

NFS service

NFS:network file system network file system, a protocol for sharing files between unix systems.

The client of NFS is mainly linux, which supports simultaneous mounting of multiple nodes and concurrent writes.

Prepare 3 servers:

Web1:192.168.2.1

Web2:192.168.2.2

Nas:192.168.2.3

Close selinux:sed-I'/ ^ SELINUX=/cSELINUX=disable' / etc/selinux/config

-I: directly modify the contents of the read file instead of outputting it to the terminal.

Turn off the firewall: systemctl stop firewalld.service; systemctl disable firewalld

1.nas (storage side)

1) installation service: yum-y install nfs-utils.x86_64

2) create a directory: [root@nas ~] # mkdir / webdata

3) write to the webpage file: [root@nas ~] # echo "nfs test." > / webdata/index.html

4) write configuration file: [root@nas ~] # vim / etc/exports

/ webdata 192.168.2.0 Universe 24 (rw,sync,no_root_squash)

Rw: read and write

Sync: write data to memory and hard disk at the same time to ensure no data loss

No_root_squash does not suppress root, and when a NFS client is accessed as a root administrator, it is mapped to the root administrator of the NFS server.

Configuration of 2.WEB1/WEB2:

1) View: [root@web1 ~] # showmount-e 192.168.2.3

Export list for 192.168.2.101:

/ webdata 192.168.2.0/24

2) installation service: yum-y install nfs-utils; yum-y install httpd

3) Mount: vim / etc/fstab

192.168.2.3:webdata / var/www/html nfs defaults 0 0

Mount-a

4) View df: 192.168.2.3:/webdata 18G 3.1G 15G 18% / var/www/html

3. Verification: no matter which WEB server you visit, the content of the web page you see is the same, achieving data synchronization.

****

On the use of NFS services to achieve website data synchronization methods to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you like this article, you might as well share it for more people to see.

Tags: Services data files synchronization content more servers websites at the same time customers clients administrators systems web pages problems management configuration inter-memory solutions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB MySQL Huawei NVidia