I. Introduction
In the distributed server cluster, the file storage service is often extracted, and the file server becomes a node by itself. This article builds a samba server according to the rhythm of the bird's linux private kitchen.
2. Installation
You can usually install it with yum
yum -y install samba
Three, the main software
samba: This software mainly provides documents of various service programs required by the SMB server, as well as other logrotate configuration files and boot default options files related to SAMBA.
samba-client: This software provides the tool commands required when Linux acts as the SAMBA Client, such as mount.cifs in the SAMBA file format
Fourth, the main configuration file and startup file directory
The configuration file is mainly
/etc/samba/smb.conf #主要配置服务器的相关设定
startup scripts, mainly
/usr/sbin/smbd #用于启动
/usr/sbin/smbstatus #列出目前Samba的联机状况
/usr/bin/{smbpasswd,pdedit} #用于修改密码
/usr/bin/testparm #用于校验配置文件的正确性
/usr/bin/smbclient #查看别台计算机所分享出来的目录
5. Construction steps
1.配置smb.conf 文件
2.配置可供使用的帐号数据
3.启动服务
6. Start building
First create the directory we want to share
mkdir /apps
Modify the smb.cnf configuration file so that our folder can be shared, and add a line at the end of smb.cnf
[hello_world] #这里是共享出去的文件名,即外部的机器看到的名字
comment=this is a test #这里是文件的注释
path=/apps #这里是真实的文件路径
browseable=yes #能否让所有用户看到这个项目
writable=yes #是否能写入
valid users=root #允许的登入者,这里使用的登入者必须是linux帐号中的一个
Use testparm to see if the configuration is correct
From the feedback from testparm we can see what we have configured
Add to add a root user for samba
pdedit -a -u root
enter password
use
pdedit -L
View current user information
Start with the following command
service smb start
Monitoring with the netstat command
netstat -anple|grep smbd
You can see that the port is being monitored by samba
Use smbclient to link and view shared file information
try to mount
mount -t cifs //127.0.0.1/hello_world /mnt
#指使用cifs的类型来mount
#cifs是Common Internet File System,通用internet文件系统 ,简单来说就是用来通过网络进行文件的读写、共享等功能。
Use the df command to see if the mount is successful
Make sure setlinux is closed, you can execute it with the setenforce 0 command. By default, SELinux prohibits network writes to shared directories on the Samba server, even if you allow this in smb.conf. /usr/bin/setenforce Modify the real-time running mode of SELinux
setenforce 1 #置SELinux 成为enforcing模式
setenforce 0 设置SELinux 成为permissive模式
If you want to completely disable SELinux, you need to set the parameter selinux=0 in /etc/sysconfig/selinux, or add this parameter in /etc/grub.conf
/usr/bin/setstatus -v
You can now view the files inside
Use window to view shared files directly
Use smbstatus to view the current number of links
So far, the enthusiastic samba file server has been successfully built, and you can directly pull files from the window to the virtual machine in the future.
When the mount is successful, that is, the file sharing is successful, the following is the unmount command
umount /mnt