nfs:mysql
Network File Systemweb
RPC:Remote Procedure Callsql
NFS: sun, 協議;服務器
NFSv1app
NFSv2, NFSv3, 異步
NIS:Network Information Serviceasync
nfsd:2049/tcp tcp
輔助類的服務:rpc (portmap)ide
rpc.mountd:認證;對掛載的主機進行認證wordpress
rpc.lockd:加鎖:防止多進程同時訪問同一個文件使文件發生錯亂
rpc.statd:狀態
nfs server:
安裝:內核模塊nfsd
用戶空間的工具程序:nfs-utils
Unit File:/usr/lib/systemd/system/nfs.service
配置文件:/etc/exports, /etc/exports.d/*
管理共享的nfs文件系統:配置文件每一行定義一個共享文件系統
Each line contains an export point and a whitespace-separated list of clients allowed to mount the file system at that point.
/PATH/TO/SOME_DIR CLIENTS_1(export_options,...) CLIENTS_2(export_options,...)
CLIENTS:
single host: IPv4, IPv6, FQDN
IP networks:network/netmask,支持兩種格式的掩碼;
wildcards:在主機名字符串中使用通,*.magedu.com,
anonymous:*,表示全部的客戶端主機;
General Options
ro:只讀;
rw:讀寫;
sync:同步
async:異步
User ID Mapping:
遠程客戶端和服務端的用戶映射是根據uid進行映射的,爲了不root權限過大的問題,默認限制了root用戶的權限即默認就有root_squash
root_squash:壓縮root用戶的權限,默認行爲;nfsnobody
no_root_squash:不壓縮root用戶的權限;
all_squash:壓縮全部用戶的權限; //默認是不壓縮,以uid號進行映射
anonuid=uid,anongid=gid:將壓縮的用戶映射爲此處指定的用戶
NFS Client:
mount -t nfs NFS_SERVER:/PATH/TO/EXPORTED_DIR /MOUNT_POINT [-rvVwfnsh] [-o OPTIONS]
showmount - show mount information for an NFS server
-e or --exports
Show the NFS server's export list.
-d or --directories
List only the directories mounted by some client.
exportfs - maintain table of exported NFS file systems
-a Export or unexport all directories.
-r Reexport all directories, synchronizing /var/lib/nfs/etab with /etc/exports and files under /etc/exports.d.
-u Unexport one or more directories.
開機自動掛載:/etc/fstab文件中,若是nfs服務器沒開啓,這樣會使客戶機出現阻塞。解決方法是在掛載的時候mount命令加上timeout ;
練習:
(1) 建立一個共享mydata,路徑爲/mysql/data,客戶端1掛載至/mydata;然後客戶端1主機安裝mysql或mariadb,將數據目錄設定爲/mydata,要確保mysql服務能正常 運行,但數據目錄位於samba server上;
(2) 客戶端2主機使用相似客戶端1主機的方式掛載mydata共享至本地的/mydata目錄,然後,直接安裝mysql或mariadb server,設定其數據目錄爲/mydata;測試
(a) 客戶端1 mysql服務運行時,客戶端2的mysql服務可否啓動?
1啓動2不能啓動,
(b) 客戶端1 mysql服務中止時,客戶端2的mysql服務可否啓動?
1停2能啓動
練習:(1) nfs sever共享/data/application/web,在目錄中提供wordpress;
(2) 部署兩臺amp服務器,均掛載此共享做爲某主機的文檔映射路徑;
(3) 驗正兩臺主機上的wordpress是否可被同時訪問;
(a) 發一個文件,驗正圖片上傳等功能;
(b) 在任一客戶端上訪問此應用,屢次刷新,確認下全部資源訪問是否正常 ;