安装SAMBA
# cd /mnt/cdrom/Packages/
# ls samba*
samba-4.1.1-31.el7.x86_64.rpm
samba-client-4.1.1-31.el7.x86_64.rpm
samba-common-4.1.1-31.el7.x86_64.rpm
samba-libs-4.1.1-31.el7.x86_64.rpm
samba-python-4.1.1-31.el7.x86_64.rpm
samba-winbind-4.1.1-31.el7.x86_64.rpm
samba-winbind-modules-4.1.1-31.el7.x86_64.rpm
要安装samba包需要依赖很多包所以需要耐心的安装
# rpm -Uvh samba-4.1.1-31.el7.x86_64.rpm
samba-client-4.1.1-31.el7.x86_64.rpm
samba-libs-4.1.1-31.el7.x86_64.rpm
samba-common-4.1.1-31.el7.x86_64.rpm
samba-winbind-4.1.1-31.el7.x86_64.rpm
libtdb-1.2.12-3.el7.x86_64.rpm
libtalloc-2.0.8-4.el7.x86_64.rpm
samba-winbind-modules-4.1.1-31.el7.x86_64.rpm
libwbclient-4.1.1-31.el7.x86_64.rpm
libsmbclient-4.1.1-31.el7.x86_64.rpm
libtevent-0.9.18-6.el7.x86_64.rpm
libldb-1.1.16-4.el7.x86_64.rpm
cups-libs-1.6.3-14.el7.x86_64.rpm
iniparser-3.1-5.el7.x86_64.rpmpytalloc-2.0.8-4.el7.x86_64.rpm
配置
创建共享目录
# mkdir -p /smb/docs
# mkdir -p /smb/tech
配置内核参数
# ulimit -n 16384
# vi /etc/security/limits.conf
#在最后加入以下内容
* - nofile 16384
# cd /etc/samba/
# cp smb.conf smb.conf.origin
# vi /etc/samba/smb.conf
删除原有所有内容,添加如下内容:
[global]
workgroup=BIGCLOUD
netbios name=ZZSRV2
server string=Samba Server
#security=share
security=user
mapto guest = Bad User
[SHAREDOCS]
path=/smb/docs
readonly=yes
browseable=yes
guest ok=yes
[RDDOCS]
path = /smb/tech/
public = no
writable = yes
write list = @RD
valid users = @RD
创建操作系统用户
# useradd alice
# useradd jack
# useradd tom
# useradd RD
修改用户的组
# usermod -a -G RD alice
# usermod -a -G RD jack
# usermod -a -G RD tom
# id alice
uid=1000(alice) gid=1000(alice)groups=1000(alice),1003(RD)
# id jack
uid=1001(jack) gid=1001(jack)groups=1001(jack),1003(RD)
# id tom
uid=1002(tom) gid=1002(tom)groups=1002(tom),1003(RD)
创建SAMBA用户
# smbpasswd -a alice
# smbpasswd -a jack
# smbpasswd -a tom
修改目录权限
# chown RD:RD /smb/tech/
# chmod 770 /smb/tech
# ll -d /smb/tech/
drwxrwx--- 2 RD RD 4096 Aug 12 14:44/smb/tech/
# systemctl restart smb
# systemctl enable smb
ln -s '/usr/lib/systemd/system/smb.service''/etc/systemd/system/multi-user.target.wants/smb.service'
# systemctl status smb
smb.service - Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled)
Active: active (running) since Tue 2014-08-12 14:53:36 CST; 30s ago
MainPID: 25689 (smbd)
Status: "smbd: ready to serve connections..."
CGroup: /system.slice/smb.service
a”a”25689 /usr/sbin/smbd
a””a”25690 /usr/sbin/smbd
Aug 12 14:53:36 ZZSRV2.localdomainsystemd[1]: Starting Samba SMB Daemon...
Aug 12 14:53:36 ZZSRV2.localdomainsmbd[25689]: [2014/08/12 14:53:36.521910, 0] ../...y)
Aug 12 14:53:36 ZZSRV2.localdomainsystemd[1]: Started Samba SMB Daemon.
Aug 12 14:53:36 ZZSRV2.localdomainsmbd[25691]: STATUS=daemon 'smbd' finished starti...ed
Aug 12 14:53:36 ZZSRV2.localdomainsmbd[25690]: STATUS=daemon 'smbd' finished starti...UL
Hint: Some lines were ellipsized, use -l toshow in full.
# testparm
Load smb config files from/etc/samba/smb.conf
Processing section "[SHAREDOCS]"
Processing section "[RDDOCS]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your servicedefinitions
[global]
workgroup = BIGCLOUD
server string = Samba Server
map to guest = Bad User
idmap config * : backend = tdb
[SHAREDOCS]
path = /smb/docs
guest ok = Yes
[RDDOCS]
path = /smb/tech/
valid users = @RD
write list = @RD
read only = No
linux上测试
# smbclient -L localhost -U alice%P@ssw0rd
Domain=[BIGCLOUD] OS=[Unix] Server=[Samba4.1.1]
Sharename Type Comment
--------- ---- -------
SHAREDOCS Disk
RDDOCS Disk
IPC$ IPC IPC Service (Samba Server)
Domain=[BIGCLOUD] OS=[Unix] Server=[Samba4.1.1]
Server Comment
--------- -------
Workgroup Master
--------- -------
windows上测试
C:\>net use \\192.168.188.12 P@ssw0rd/U:alice
命令成功完成。
打开进行写入测试