centos 7 啟用NFS server

真真氣死人, 只是使用restic備份, 需要掛載不同性質的資料來源,
從 rclone 到 sshfs 到回歸nfs server, 只有一種感慨, 就是交給專業的來,不要想東想西的, ssh 來掛載目錄, rclone掛載ssh都不切實際,目前都不穩定.

服務器端啟用nfs server

yum install nfs-utils

## 分享目錄
mkdir -p /mnt/docker
vi etc/exports
=================
#只讀ro,  10.192.130.4可使用
/mnt/docker      10.192.130.4(ro,sync,no_root_squash,no_all_squash)
#讀寫rw,  10.192.130.0/24網段可使用
/mnt/docker      10.192.130.0/24(rw,sync,no_root_squash,no_all_squash)
=================

#啟用
firewall-cmd --zone=public --add-service=nfs --permanent

## rockylinux
#firewall-cmd --add-service={nfs,nfs3,mountd,rpc-bind} --permanent

firewall-cmd --reload
systemctl enable nfs 
systemctl start nfs

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

#查看狀態(windows,linux通用)
showmount -e localhost

用戶端(linux)

mount -t nfs <server ip>:/mnt/docker  <本地要掛載的目錄>
或是
mount -t nfs4 <server ip>:/mnt/docker  <本地要掛載的目錄>

用戶端(windows)

mount -o anon  \\ip\mount_path  z:

rclone 掛載sftp 連線過慢, 因此先用sshfs擋著先

RockyLinux

dnf --enablerepo=powertools -y install fuse-sshfs

以下為自動掛載方式,(這樣不是很安全,用rsa-key方式比較好)

echo 密碼| sshfs -o reconnect -o allow_other -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 帳號@主機:/來源目錄/ 掛載目錄 -o workaround=rename -o password_stdin

增加效能

 -o Ciphers=aes128-ctr -o Compression=no -o ServerAliveCountMax=100 -o ServerAliveInterval=15 

傳輸過程若出現 transport endpoint is not connected 的錯誤

請試著修改 /etc/fuse.conf , 啟用 user_allow_other 選項