Network File System

From Server rental store
Jump to navigation Jump to search
  1. Network File System (NFS) – A Server Configuration Guide

This article details the configuration of a Network File System (NFS) for your MediaWiki environment. NFS allows you to share directories and files between servers over a network, which is particularly useful for centralizing storage of uploaded files, backups, and other data used by your wiki installation. This guide assumes a basic understanding of Linux server administration.

What is NFS?

Network File System (NFS) is a distributed file system protocol allowing a user on a client computer to access files over a network as if they were on a local disk. This is achieved by allowing a server to share directories (exports) with clients. NFS is commonly used in Unix-like systems, including Linux, and is a valuable tool for managing data across multiple servers. It’s often preferred over alternatives like Samba (SMB/CIFS) in homogenous Unix environments due to its simplicity and performance. For more information about file systems, see File System Basics.

Benefits of Using NFS with MediaWiki

  • Centralized Storage: Consolidate all uploaded files and backups onto a dedicated NFS server, simplifying management and backups. This is preferable to having files scattered across multiple wiki servers. See Backups for more information.
  • Scalability: Easily expand storage capacity by adding more disk space to the NFS server without modifying the MediaWiki servers directly.
  • Simplified Management: Manage permissions and access control centrally on the NFS server.
  • Improved Performance: In some cases, NFS can provide better performance than local storage, especially with fast network connections. However, proper tuning (discussed later) is crucial. Check Performance Tuning for general wiki performance guidance.


NFS Server Configuration

This section outlines the steps required to configure the NFS server. We will use a Debian/Ubuntu-based system for this example, but the general principles apply to other distributions.

1. Install NFS Server

First, install the necessary NFS server packages:

```bash sudo apt update sudo apt install nfs-kernel-server ```

2. Create Shared Directory

Create the directory you want to share. For example, to share a directory called `/nfs/mediawiki_files`:

```bash sudo mkdir -p /nfs/mediawiki_files sudo chown www-data:www-data /nfs/mediawiki_files #Important: Set ownership to the web server user sudo chmod 775 /nfs/mediawiki_files #Allow read/write/execute for owner and group, read/execute for others ```

3. Configure `/etc/exports`

Edit the `/etc/exports` file to define which directories are shared and with what permissions. Add a line similar to the following:

``` /nfs/mediawiki_files <client_IP_address>(rw,sync,no_subtree_check,no_root_squash) ```

  • `<client_IP_address>`: Replace this with the IP address of your MediaWiki server. You can also use a subnet (e.g., `192.168.1.0/24`) to allow access from multiple servers.
  • `rw`: Allows read and write access.
  • `sync`: Forces NFS to write changes to disk before replying to the client. This provides better data integrity, but can slightly reduce performance.
  • `no_subtree_check`: Disables subtree checking, which can improve performance in some cases.
  • `no_root_squash`: Allows the root user on the client to have root privileges on the shared directory. **Use with caution!** Consider `root_squash` for increased security. See Security Considerations.

After editing `/etc/exports`, export the shares:

```bash sudo exportfs -a ```

4. Restart NFS Server

Restart the NFS server to apply the changes:

```bash sudo systemctl restart nfs-kernel-server ```

NFS Client Configuration

This section details how to configure the MediaWiki server as an NFS client.

1. Install NFS Client

Install the NFS client packages:

```bash sudo apt update sudo apt install nfs-common ```

2. Create Mount Point

Create a directory on the MediaWiki server where the NFS share will be mounted. For example:

```bash sudo mkdir /var/www/mediawiki/images_nfs ```

3. Mount the NFS Share

Mount the NFS share using the `mount` command:

```bash sudo mount <NFS_server_IP>:/nfs/mediawiki_files /var/www/mediawiki/images_nfs ```

Replace `<NFS_server_IP>` with the IP address of your NFS server.

4. Configure Auto-Mount (fstab)

To automatically mount the NFS share on boot, add an entry to `/etc/fstab`:

``` <NFS_server_IP>:/nfs/mediawiki_files /var/www/mediawiki/images_nfs nfs defaults,auto 0 0 ```

After editing `/etc/fstab`, you can mount all entries with:

```bash sudo mount -a ```

Technical Specifications

The following tables summarize key technical details for both the NFS server and client configurations.

NFS Server Specifications Value
Operating System Debian 11 (Bullseye)
NFS Server Package nfs-kernel-server v4.1.6
Kernel Version 5.10.0-18-amd64
Network Interface eth0 (192.168.1.100)
NFS Client Specifications Value
Operating System Ubuntu 20.04 (Focal Fossa)
NFS Client Package nfs-common v1.3.4
Kernel Version 5.4.0-122-generic
Network Interface eth0 (192.168.1.101)
`/etc/exports` Options Description
rw Read-write access
sync Synchronous writes
no_subtree_check Disables subtree checking
no_root_squash Allows root access from client
root_squash Maps root to nobody user (more secure)

MediaWiki Configuration

After mounting the NFS share, you need to configure MediaWiki to use it. Edit your `LocalSettings.php` file and update the `$wgUploadDirectory` variable to point to the mount point:

```php $wgUploadDirectory = "/var/www/mediawiki/images_nfs"; ```

Remember to clear the MediaWiki cache after making this change. See Cache Management.

Security Considerations

  • **Firewall:** Configure your firewall to allow NFS traffic (ports 111, 2049, and potentially others depending on your configuration) between the server and client. See Firewall Configuration.
  • **`root_squash` vs. `no_root_squash`:** Carefully consider the implications of using `no_root_squash`. It's generally recommended to use `root_squash` for increased security, especially in production environments.
  • **Authentication:** NFS relies on UID/GID mapping for authentication. Ensure that user and group IDs are consistent between the server and client.
  • **Network Security:** Ensure your network is secure to prevent unauthorized access to the NFS share. Consider using a VPN if accessing the share over an untrusted network. See Network Security.

Troubleshooting

  • **Mount Errors:** Check the system logs on both the server and client for error messages. Use the `showmount -e <NFS_server_IP>` command on the client to verify that the share is being exported correctly.
  • **Permission Issues:** Ensure that the web server user on the MediaWiki server has appropriate permissions to read and write to the mounted directory.
  • **Performance Problems:** Monitor network traffic and disk I/O on both the server and client to identify bottlenecks. Consider tuning the NFS options (e.g., using `async` instead of `sync` if data integrity is not a critical concern).



Main Page Configuration Security Performance Tuning Backups File System Basics Cache Management Firewall Configuration Network Security LocalSettings.php Troubleshooting Server Administration User Management Database Configuration Web Server Configuration System Logs Linux Basics


Intel-Based Server Configurations

Configuration Specifications Benchmark
Core i7-6700K/7700 Server 64 GB DDR4, NVMe SSD 2 x 512 GB CPU Benchmark: 8046
Core i7-8700 Server 64 GB DDR4, NVMe SSD 2x1 TB CPU Benchmark: 13124
Core i9-9900K Server 128 GB DDR4, NVMe SSD 2 x 1 TB CPU Benchmark: 49969
Core i9-13900 Server (64GB) 64 GB RAM, 2x2 TB NVMe SSD
Core i9-13900 Server (128GB) 128 GB RAM, 2x2 TB NVMe SSD
Core i5-13500 Server (64GB) 64 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Server (128GB) 128 GB RAM, 2x500 GB NVMe SSD
Core i5-13500 Workstation 64 GB DDR5 RAM, 2 NVMe SSD, NVIDIA RTX 4000

AMD-Based Server Configurations

Configuration Specifications Benchmark
Ryzen 5 3600 Server 64 GB RAM, 2x480 GB NVMe CPU Benchmark: 17849
Ryzen 7 7700 Server 64 GB DDR5 RAM, 2x1 TB NVMe CPU Benchmark: 35224
Ryzen 9 5950X Server 128 GB RAM, 2x4 TB NVMe CPU Benchmark: 46045
Ryzen 9 7950X Server 128 GB DDR5 ECC, 2x2 TB NVMe CPU Benchmark: 63561
EPYC 7502P Server (128GB/1TB) 128 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/2TB) 128 GB RAM, 2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (128GB/4TB) 128 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/1TB) 256 GB RAM, 1 TB NVMe CPU Benchmark: 48021
EPYC 7502P Server (256GB/4TB) 256 GB RAM, 2x2 TB NVMe CPU Benchmark: 48021
EPYC 9454P Server 256 GB RAM, 2x2 TB NVMe

Order Your Dedicated Server

Configure and order your ideal server configuration

Need Assistance?

⚠️ *Note: All benchmark scores are approximate and may vary based on configuration. Server availability subject to stock.* ⚠️