1、Samba、FTP、NFS比较
Samba、FTP和NFS的共同点是都可以在网络中共享文件信息。它们的区别如下:
Samba主要用于局域网中,Windows和Linux系统之间的文件共享
FTP主要用于Internet上文件的上传和下载
NFS主要用于局域网中,Linux系统之间的文件共享
2、查看系统信息
[root@localhost ~]# cat /etc/redhat-release
3、查看yum源中SAMBA版本
[root@localhost ~]# yum list | grep samba
4、查看CentOS7 IP地址
[root@localhost ~]# ifconfig
或者
[root@localhost ~]# ip address
5、关闭防火墙
关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service
禁止防火墙开机启动
[root@localhost ~]# systemctl disable firewalld.service
查看防火墙状态
[root@hadoop101 ~]# firewall-cmd --state
6、关闭SeLinux
临时性关闭
[root@localhost ~]# setenforce 0
永久性关闭
[root@hadoop101 ~]# vim /etc/sysconfig/selinux
SELINUX=disabled
永久关闭SeLinux,需要重启机器,修改配置文件/etc/selinux/config,将SELINU置为disabled
重启后使用命令检查,查看SELinux状态
[root@hadoop101 ~]# getenforce
Disabled
[root@hadoop101 ~]# sestatus -v
SELinux status: disabled
[root@localhost ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: error (Success)
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
7、安装Samba服务
[root@hadoop101 ~]# yum install -y samba
8、查看安装状况
[root@hadoop101 /]# rpm -qa | grep samba
samba-4.8.3-4.el7.x86_64
samba-client-libs-4.8.3-4.el7.x86_64
samba-libs-4.8.3-4.el7.x86_64
samba-common-4.8.3-4.el7.noarch
samba-common-libs-4.8.3-4.el7.x86_64
samba-common-tools-4.8.3-4.el7.x86_64
samba-client-4.8.3-4.el7.x86_64
9、启动smb
[root@hadoop101 /]# systemctl start smb.service
10、查看smb
[root@hadoop101 /]# systemctl status smb.service
11、启动nmb
[root@hadoop101 /]# systemctl start nmb.service
12、查看nmb
[root@hadoop101 /]# systemctl status nmb.service
13、smb开机自启动
[root@hadoop101 ~]# chkconfig smb on
Note: Forwarding request to 'systemctl enable smb.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
14、nmb开机自启动
[root@hadoop101 ~]# chkconfig nmb on
Note: Forwarding request to 'systemctl enable nmb.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.
15、查看Samba服务进程
[root@hadoop101 ~]# ps -ef | grep -E 'smb|nmb'
root 3040 1 0 16:56 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 3042 3040 0 16:56 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 3043 3040 0 16:56 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 3044 3040 0 16:56 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 3067 1 0 16:57 ? 00:00:00 /usr/sbin/nmbd --foreground --no-process-group
root 3144 2871 0 16:59 pts/0 00:00:00 grep --color=auto -E smb|nmb
16、备份配置文件
[root@hadoop101 ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
17、需求描述
公司现有一个工作组workgroup,需要添加samba服务器作为文件服务器,并发布共享目录/share,共享名为public,此共享目录允许所有员工访问
18、编辑配置文件
[root@hadoop101 ~]# vim /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
security = user
map to guest = Bad User
server string = alex Samba Server Version %v
netbios name = alexSamba
log file = /var/log/samba/log.%m
[public]
comment = Public Stuff
path = /opt/module/share
public = yes
guest ok = yes
writeable = yes
available = yes
browseable = yes
19、创建目录
[root@hadoop101 ~]# mkdir -p /opt/module/share
[root@hadoop101 ~]# echo 123 /opt/module/share/a.txt
20、重启服务
[root@hadoop101 ~]# systemctl restart smb
[root@hadoop101 ~]# systemctl restart nmb
[root@hadoop101 ~]# systemctl status smb
[root@hadoop101 ~]# systemctl status nmb
21、测试检查smb.conf 配置是否正确
[root@hadoop101 ~]# testparm
22、Linux客户端连接
[root@hadoop101 /]# smbclient //192.168.2.121/public
Enter WORKGROUP\root's password:
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Mon Apr 15 17:16:15 2019
.. DR 0 Mon Apr 15 17:15:53 2019
samba.txt N 0 Mon Apr 15 17:16:10 2019
aa.txt N 0 Mon Apr 15 17:16:15 2019
52403200 blocks of size 1024. 46628252 blocks available
smb: \> quit
23、window 连接
window + R -> \\192.168.2.121\public
Linux Share
网友评论