Using NAS

12006

1. What is NAS

NAS (Network Attached Storage) is a dedicated data storage server that provides data access services over a network. It is commonly used for storing and sharing large amounts of data among multiple users or devices within a network. NAS systems can connect to corporate or home networks via standard network protocols such as TCP/IP.

The main functions of NAS include:

  • Data storage and backup: NAS provides a centralized location for storing files, making data backup and recovery simple and effective.
  • File sharing: NAS allows multiple users on the network to access files stored on it simultaneously, enhancing team collaboration efficiency.
  • Data security: Most NAS devices offer data encryption and user access control to protect stored data from unauthorized access.
  • Multimedia services: Many NAS devices can function as multimedia servers, supporting streaming of videos and music.

The benefits of using NAS devices on servers include:

  • Scalability: NAS provides a straightforward way to expand the storage capacity of existing servers.
  • Performance: As a dedicated device, NAS can offer higher data transfer rates and better storage performance.
  • Flexibility and convenience: NAS allows users to access data from anywhere on the network, providing greater flexibility.
  • Simplified management: Managing NAS devices is generally simpler than managing storage on traditional servers.

Servers connect to NAS devices via the NFS protocol. NFS (Network File System) protocol is a protocol that allows computers to access remote file systems over a network. It is a commonly used protocol, especially in UNIX and Linux systems. Using NFS, a server can export a portion of its file system to clients on the network, allowing clients to access these files as if they were local. This method is particularly suitable for sharing data between multiple systems, especially in large network environments.

This lesson uses Synology NAS devices as an example to demonstrate how to use the shared folder feature of NAS for more convenient and efficient storage and backup of files and data on servers.

2. Using the Shared Folder Feature of NAS

A shared folder is a directory in NAS devices that allows data to be shared between different servers and users. To connect a server to a NAS device, you first need to create a shared folder and then add NFS permissions to the shared folder:

NAS-Shared Folder Settings.png

Here, the IP address refers to the internal IP address of the server. Generally, a shared folder is only accessible to one server's IP to prevent multiple servers from reading and writing to the same folder, which could cause data conflicts.

3. Jianghu Panel - NFS Manager

Once the shared folder is set up, you can configure the server to connect to the NAS device through the Jianghu Panel. In the Jianghu Panel, this step is configured using the "NFS Manager" plugin:

  • On the software management page of the Jianghu Panel, search for and install the NFS Manager plugin.
  • After installation, click to open the NFS Manager on the left side of the panel and start adding mount directories. The NFS Manager will automatically create the corresponding mount directories:

Jianghu Panel - NFS Add Mount Directory.png

  • After adding the mount directory, click "Mount," and then check the previously set mount directory to see the contents of the NAS shared folder.
  • You can also set this mount directory to start automatically on boot to simplify operations after startup.

4. File Storage and Backup Solutions Using NAS Devices

The use of NAS devices allows us to store and back up files and data on servers more conveniently. Here is a commonly used file storage and backup solution:

  • Files and data that change infrequently and can be rebuilt from other sources, such as website configurations, plugin configurations, project code, etc., should be stored on the server's own hard drive.
  • Files and data that change frequently, grow rapidly, or cannot be rebuilt from other sources, such as user-uploaded files and service backup data, should be stored in the NAS directory.
  • The NAS shared folder is set up with two default directories: backup and wwwstorage. After the server mounts the shared folder, create soft links to these two directories in the /www directory to replace the original backup directory and user data directory. This way, user-uploaded files and server backup data can be directly stored in the NAS.
    • /www/wwwstorage: stores user data
    • /www/backup: stores backups
  • The Jianghu Panel script tool provides a script for organizing the server, which can search the upload directory under /www/wwwroot for user-uploaded data and copy it to the /www/wwwstorage directory, creating corresponding soft links.

For knowledge about soft links, you can refer to the reference materials of this lesson.

5. File Backup in NAS

NAS shared folders also need to be backed up. Synology NAS devices provide the HyperBackup tool, which can schedule backups of specified shared folders and offers version control functionality to save historical versions of folders within a certain time range.

In our backup solution, the commonly used version control configuration is:

  • Within 1 day: retain one version per hour
  • From 1 day to 1 month: retain one version per day
  • From 1 month to the earliest: retain one version per week, with a maximum of 100 versions

For specific operational methods of the HyperBackup tool, please refer to the user documentation for Synology NAS devices.

Reference Materials:

  1. Explanation of Soft Links:
  1. Synology NAS Device HyperBackup Tool: https://kb.synology.cn/zh-cn/DSM/tutorial/Quick_Start_Hyper_Backup