Skip to main content

Jak wyeksportować volume przez NFS w NSIS

Konfiguracja serwera

Zaktualizuj swój system:

sudo apt update && apt upgrade

Zainstaluj niezbędne pakiety:

sudo apt install nfs-kernel-server

Utwórz nowy folder, który zostanie wyeksportowany przez NFS, np:

sudo mkdir -p /mnt/<name of your folder>

Usunięcie wszystkich ograniczeń dostępu w folderze:

sudo chown -R nobody:nogroup /mnt/<name of your folder>/

Można również zastąpić uprawnienia plików w folderze własnymi preferencjami.

np.

sudo chmod 777 /mnt/<name of your folder>/

Definiowanie uprawnień dostępu do serwera NFS.

W pliku /etc/exports dodaj następującą linię:

/mnt/<name of your folder>  <IP address of allowed client>(rw,sync,no_subtree_check)

gdzie <adres IP> to adres serwera z zezwoleniem na dostęp do folderu /mnt/<nazwa folderu>.

np.

# /etc/exports: the access control list for filesystems which may be exported

#        to NFS clients.  See exports(5).

#

# Example for NFSv2 and NFSv3:

# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)

#

# Example for NFSv4:

# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)

# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)

#

/mnt/<name of your folder>  <IP address of NFS server>(rw,sync,no_subtree_check)

Możesz także udostępnić swój folder większej liczbie adresów IP:

/mnt/<name of your folder>  <IP address 1>(rw,sync,no_subtree_check)
/mnt/<name of your folder>  <IP address 2>(rw,sync,no_subtree_check)
/mnt/<name of your folder>  <IP address 3>(rw,sync,no_subtree_check)

Możesz również udostępnić folder wszystkim serwerom w podsieci (zamiast dodawać każdy adres IP osobno), dodając następującą linię do /etc/exports (np. serwery w 192.168.0.0/24):

/mnt/<name of your folder> 192.168.0.0/24(rw,sync,no_subtree_check)

Po zapisaniu pliku konfiguracyjnego /etc/exports należy wywołać następujące polecenia:

sudo exportfs -a
sudo systemctl restart nfs-kernel-server

KONIECZNE JEST OTWARCIE PORTU 2049 W GRUPIE BEZPIECZEŃSTWA!

(Poradnik dotyczący otwierania portów w grupie bezpieczeństwa jest dostępny pod adresem Jak mogę otworzyć nowe porty http dla mojej usługi lub instancji w NSIS?).

Konfiguracja klienta

Zainstaluj wymagane pakiety:

sudo apt install nfs-common

Zamontuj folder NFS:

sudo mount <IP address of your NFS server>:/mnt/<name of your folder in NFS server> <name of your folder in Client>/