资源共享
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)