資源共享
1.ftp (ftp協議
)
2.samba (smb協議
)
3.nfs
Samba
配置:
1.[root@localhost Server]# ll samba*
-r--r--r-- 55 root root 17197883 2008-12-16 samba-3.0.33-3.7.el5.i386.rpm //實現服務器
-r--r--r-- 55 root root 6008643 2008-12-16 samba-client-3.0.33-3.7.el5.i386.rpm //實現客戶端
-r--r--r-- 63 root root 9148397 2008-12-16 samba-common-3.0.33-3.7.el5.i386.rpm //smb配置腳本
-r--r--r-- 55 root root 8726082 2008-12-16 samba-swat-3.0.33-3.7.el5.i386.rpm //經過
web進行管理
2.[root@localhost Server]# rpm -qa |grep samba
samba-common-3.0.33-3.7.el5
samba-client-3.0.33-3.7.el5
3.安裝
samba服務
[root@localhost Server]# rpm -ivh perl-Convert-ASN1-0.20-1.1.noarch.rpm //依賴包
[root@localhost Server]# rpm -ivh samba-3.0.33-3.7.el5.i386.rpm
vim /etc/samba/smb.conf
文件內容:
79 interfaces = lo eth0 192.168.2.100/24 //如下三行爲安全參數
80 bind interfaces only = yes //這兩行表示綁定地址
81 hosts allow = 127. 192.168.2. //控制訪問者
90 log file = /var/log/samba/%m.log //計算機名日誌
92 max log size = 0 //無限大
101 security = user //安全級別
221 load printers = yes //自動加載打印機
222 cups options = raw //通用打印機系統選項
255 [printers] //共享名字
256 comment = All Printers //描述
257 path = /var/spool/samba
258 browseable = no //不可看到共享名字
259 guest ok = no //須要身份驗證訪問
valid users = zhangsan //容許
zhangsan訪問
260 writable = no //不可寫因此是隻讀(只可下載),爲網絡權限
[root@localhost Server]# service smb start
[root@localhost Server]# ifconfig eth0:0 192.168.2.200
samba服務器的安全級別
share 匿名
user 身份驗證
samba賬號庫 【本地】
server 身份驗證
samba賬號庫 【其餘服務器】
domain 【
ads】 身份驗證
Windows客戶端測試:
本地權限
[root@localhost Server]# mkdir /zhangsan
[root@localhost Server]# useradd zhangsan
[root@localhost Server]# chown zhangsan.zhangsan /zhangsan
[root@localhost Server]# smbpasswd -a zhangsan //建立
smb賬號
linux客戶端訪問
[root@localhost ~]# smbclient -L //192.168.2.100 -U zhangsan //鏈接並列出目錄
password: //smb賬號密碼
[root@localhost ~]# smbclient //192.168.2.100/smbzs -U zhangsan//鏈接目錄
臨時掛載
root@localhost ~]# mkdir /mnt/smb
root@localhost ~]# mount -t cifs //192.168.2.100/smbzs /mnt/smb -o username=zhangsan%123
永久掛載
vim /etc/fstab
//192.168.2.100/smbzs /mnt/smb cifs default,username=zhangsan%123 0 0
爲了更安全
vim /etc/fstab
//192.168.2.100/smbzs /mnt/smb cifs default,credentials=/etc/samba/f1 0 0
vim /etc/samba/f1
文件內容:
username=zhangsan //不能有空格
password=123
[root@localhost ~]# mount -a
自動掛載
NFS
網絡文件系統
適用於
linux和linux之間 linux和unix之間
配置
1.[root@localhost ~]# rpcinfo –
p //查看rpc進程, rpc表示遠程進程調用
2.服務器共享文件
[root@localhost ~]# mkdir /public
vim /etc/exports //編輯共享清單,默認爲空文件
文件內容:
/public 192.168.2.0/24(ro)
文件內容結構爲
: 物理文件夾 來源(權限,參數)
例如:
/public *(ro)
/public 1.1.1.1(rw,sync) //同步
/public *.abc.com(ro)
/public 192.168.2.0/24(ro)
[root@localhost ~]# rpm -qa |grep nfs
nfs-utils-1.0.9-40.el5 //默認是安裝的
nfs-utils-lib-1.0.8-7.2.z2
[root@localhost ~]# service nfs start
[root@localhost ~]# exportfs -rv //輸出清單到環境中去
客戶端
[root@localhost ~]# rpcinfo -p
[root@localhost ~]# showmount -e 192.168.2.100 //查看是否能夠訪問
臨時掛載
[root@localhost ~]# mkdir /mnt/nfs
[root@localhost ~]# mount 192.168.2.100:/public /mnt/nfs
永久掛載
vim /etc/fstab
文件內容加入:
192.168.2.100:/public /mnt/nfs nfs ro,soft(出錯提示
),intr(容許中斷) 0 0
[root@localhost ~]# mount -a
自動掛載(爲了節省服務器資源消耗)
[root@localhost ~]# rpm -qa |grep auto // autofs爲自動掛載文件系統
automake16-1.6.3-8
[root@localhost ~]# chkconfig --list |grep auto
vim /etc/auto.master //自動掛載寫入腳本
文件內容加入:
10 /mnt/nfs /etc/auto.nfs --timeout=60 //監控 目錄 超時
[root@localhost ~]# cp -p /etc/auto.misc /etc/auto.nfs
vim /etc/auto.nfs
文件內容加入:
18 server1 -ro,soft,intr 192.168.2.100:/public
[root@localhost ~]# service autofs restart
客戶端測試:
[root@mail ~]# cd /mnt/nfs
[root@mail nfs]# ll
總計
0
[root@mail nfs]# cd server1
[root@mail server1]# mount
192.168.2.100:/public on /mnt/nfs/server1 type nfs (ro,soft,intr,addr=192.168.2.100)