Chinaunix首页 | 论坛 | 博客
  • 博客访问: 374117
  • 博文数量: 80
  • 博客积分: 1750
  • 博客等级: 上尉
  • 技术积分: 1380
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-13 11:35
文章分类
文章存档

2014年(3)

2013年(1)

2012年(54)

2011年(22)

分类: 服务器与存储

2012-07-14 09:01:10

rhel samba server

        samba是一个工具套件,在Unix上实现SMB(Server Message Block)协议,或者称之为NETBIOS/LanManager协议。SMB协议通常是被windows系列用来实现磁盘和打印机共享。需要注意的 是,NetBIOS是基于以太网广播机制的,没有透明网桥是不能跨越网段的,也许用WINS和LMHOSTS可以,但我没试过。我感觉samba是把 SMB绑定到TCP/IP上实现的,samba只在IP子网内广播(很多时候我不得不指定IP地址
      
       使用 RPM 来安装真是一点都不难。不过,要注意安装的套件名称,因为不同的distribution 对于 RPM 档案的命名都不太一样!举例, Red Hat 9 时对于SAMBA 这个服务器总共需要至少三个套件,分别是: 
  samba:这个套件主要包含了 SAMBA 的主要 daemon档案 ( smbd 及 nmbd )、 SAMBA 的文件档 ( document )、以及其它与 SAMBA 相关的logrotate 设定文件及开机预设选项档案等;
  samba-common:这个套件则主要提供了 SAMBA 的主要设定档(smb.conf) 、 smb.conf 语法检验的测试程序 ( testparm )等等;
  samba-client:这个套件则提供了当 Linux 做为SAMBA Client 端时,所需要的工具指令,例如挂载 SAMBA 档案格式的执行档 smbmount等等

系统环境:rhel6.0 x86-64

软件安装:
  1. yum install samba-* -y
  2. rpm -qa | grep smaba
  3. samba-3.5.6-86.el6.x86_64
  4. samba-winbind-clients-3.5.6-86.el6.x86_64
  5. samba-common-3.5.6-86.el6.x86_64
  6. samba-client-3.5.6-86.el6.x86_64
SELINUX为了避免上下文设置带来的困扰,可以直接将selinux的状态置为disable

  1. vim /etc/selinux/config
  2. ....
  3. selinux=disabled
  4. ....
Samba的主配置文件进行设定(/etc/samba/smb.conf)
1.Global Setting(也可保持默认)
  1.     workgroup = MYGROUP
  2. ;   server string = Samba Server Version %v
  3.     server string = Welcome to visit yungho'samba Server

  4.     netbios name = MYSERVER

  5. ;   interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
  6. ;   hosts allow = 127. 192.168.12. 192.168.13.
Workgroup 工作组名
Server srting 服务器描述
Netbios name netbios
Interfaces 运行 samba 服务器监听的网卡接口
Hosts allow 访问控制列表,允许访问 samba 的机器,在 samba 服务里面 hosts
allow 的权限大于 hosts deny,另外子项里的配置权限和全局冲突时,子项里的生效

2.Logging Options(更改日志的大小,存放路径;此处默认)

  1. # logs split per machine
  2. log file = /var/log/samba/log.%m
  3. # max 50KB per log file, then rotate
  4. max log size = 50
3.Share Definitions(把自己共享的配置写在这里)

  1. [homes]
  2. comment = Home Directories
  3. browseable = no
  4. writable = yes
  5. ; valid users = %S
  6. ; valid users = MYDOMAIN\%S

  7. [printers]
  8. comment = All Printers
  9. path = /var/spool/samba
  10. browseable = no
  11. guest ok = no
  12. writable = no
  13. printable = yes
4.自定义的共享配置

  1. [share]
  2. comment = linux share
  3. path = /var/ftp/pub/temp
  4. public = yes
  5. writable = yes
此处共享的文件为/var/ftp/pub/temp这个其目录,并对其有写的权限,并且给chmod 777 /var/ftp/pub/temp
通过testparm检查配置文件有无错误

5.启起samba服务

  1. /etc/init.d/smb start
  2. /etc/init.d/nmb start
  3. or
  4. chkconfig --level 35 smb on
  5. chkconfig --level 35 nmb on
6.如果对iptables不太熟悉,或是觉得设置规则比较麻烦,想轻松一点,可以这样做

  1. iptables -F
  2. or
  3. /etc/init.d/iptables stop
7.添加samba用户(系统已经存在的用户)

  1. smbpasswd -a yungho
  2. New SMB password:
  3. Retype new SMB password:
8.windows客户端访问




9.linux客户端访问
查看共享文件
  1. smbclient -L 192.168.1.44 -U yungho
  2. Enter yungho's password:
  3. Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.5.6-86.el6]

  4. Sharename Type Comment
  5. --------- ---- -------
  6. share Disk linux share
  7. IPC$ IPC IPC Service (Welcome to visit yungho'samba Server)
  8. yungho Disk Home Directories
登录共享服务器

  1. smbclient //192.168.1.44/share -U yungho
  2. Enter yungho's password:
  3. Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.5.6-86.el6]
  4. smb: \> ls
  5. . D 0 Sat Jul 14 07:58:13 2012
  6. .. D 0 Fri Dec 16 03:42:32 2011
  7. Optional D 0 Thu Jun 21 10:00:03 2012
  8. smplayer.tgz A 31021411 Thu Jun 21 10:00:51 2012
  9. server6.0 DR 0 Thu Sep 23 07:21:04 2010
  10. server6.1 DR 0 Wed May 11 07:28:01 2011
  11. client6.1 DR 0 Wed May 11 07:41:02 2011
  12. temp D 0 Sat Jul 14 09:41:03 2012
  13. unrar-3.9.10-1.el6.rf.x86_64.rpm A 104904 Thu Jun 21 10:00:30 2012
  14. client6.0 DR 0 Thu Sep 23 06:59:12 2010

注:用户要对共享文件有写权限,除了samba允许写,还有系统用户本身也应具有写权限。


GOOD LUCK!

阅读(983) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~