1. 程式人生 > >linux系統運維學習日記

linux系統運維學習日記

準備工作: 1.關閉防火

# chkconfig iptables off
# service iptables stop
# service iptables status

2.關閉selinux

 # setenforce 0    <<< 臨時關閉selinux
 # getenforce      <<< 檢視seLinux的狀態
 # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

第一步:安裝nfs服務端(nfs rpc)

# yum install rpcbind nfs-utils -y

第二步:安裝nfs客戶端

# yum install rpcbind nfs-utils -y

(客戶端僅僅需要安裝nfs,不需要配置和啟動)

第三步:在伺服器端和客戶端分別建立一個系統使用者(訪問nfs時轉換的使用者)

# groupadd -g 1024 tom
# useradd -u 1024 -r -s  /sbin/nologin -g 1024 tom
【伺服器和各個客戶端節點都要執行建立】

第四步:啟動nfs的伺服器端

# service rpcbind start
# chkconfig rpcbind on
# service nfs start
# chkconfig nfs on

第五步:檢查rpc中所註冊的埠資訊

# rpcinfo -p localhost     <<< 從伺服器端檢視自己的rpc中所註冊的埠資訊
# rpcinfo -p 192.168.31.200  <<< 從客戶端檢視遠端的nfs上的rpc中所註冊的埠資訊
注意:rpc服務的埠是111

第六步:共享一個目錄

# mkdir  /data
# vim  /etc/exports
	/data  192.168.31.0/24(rw,async,insecure,all_squash,root_squash,anonuid=1024,anongid=102
# service nfs restart

第七步:在客戶端掛載nfs所共享的目錄 格式: mount -t nfs nfsIP:目錄名 掛載點

# mkdir /root/nfsSource/
# mount -t nfs 192.168.31.200:/data /root/nfsSource/

第八步:在客戶端使用該目錄

# cd /root/nfsSource/
# touch a.txt
  >>> 此時報許可權錯誤
  這是因為通過nfs所共享的目錄,在使用這個目錄的時候,是以一個特定的使用者身份執行的,而不是root身份

解決在方式有兩種 第一種:在 nfs 伺服器端修改共享目錄的許可權位777 第二種:在 nfs 伺服器端對nfsnobody所單獨授權

  # chown 1024.1024 /data