FTP服务搭建
# yum -y install vsftpd //服务端安装vsftpd服务
# vi /etc/vsftpd/vsftpd.conf anon_root=/opt
# systemctl restart vsftpd
ftp://+IP //使用浏览器验证
# vi /etc/yum.repos.d/lcoal.repo //客户端使用FTP源
添加以下内容:
[centos]
name=centos
baseurl=ftp://192.168.200.10/centos
gpgcheck=0
enabled=1
验证yum源
# yum clean all
# yum repolist
服务端配置NFS
使用nfs服务需要安装两个包(nfs-utils和rpcbind),使用yum安装nfs-utlis时会一并安装rpcbind
# yum install -y nfs-utils
# mkdir /mnt/test
# vi /etc/exports
添加以下内容:
/mnt/test 192.168.100.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
rw:表示读/写
ro:表示只读
sync:同步模式,表示内存中的数据实时写入磁盘
async:非同步模式,表示内存中的数据定期写入磁盘
anonuid:匿名用户 UID
anongid:匿名用户 GID
# systemctl start rpcbind
# systemctl start nfs
# systemctl enable rpcbind
# systemctl enable nfs
客户端挂载NFS
# showmoubt -e 192.168.100.11 //-e:显示指定nfs服务器输出目录
# mount -t nfs 192.168.100.11:/mnt/test /mnt/
# df -h //可以产看到增加了一个/mnt分区,它就是NFS共享的目录
验证共享
# cd /mnt/
# touch 123.txt (无法创建是因为服务端上创建的/mnt/test目录权限不合适,需到服务端上修改目录权限:chmod 777 /mnt/test/)
exportfs命令
-a:表示全部挂载或者卸载
-r:表示重新挂载
-u:表示卸载某一个目录
-v:表示显示共享的目录
samba服务
# yum -y install samba //单节点安装samba服务
修改samba配置文件并添加以下内容:
# vi /etc/samba/smb.conf
修改:
printcap name = /dev/null
load printers = no
添加:(在最后添加)
[share]
path = /opt/share
browseable = yes
public = yes
writable = yes
# mkdir /opt/share //创建共享目录
# ll /opt/
total 2
drwxr-xr-x 8 root root 2048 Sep 12 2019 centos
drwxr-xr-x 2 root root 6 Aug 31 17:20 share
# systemctl start smb //启动samba守护进程
# systemctl start nmb
# netstat -ntpl |grep 45
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 12851/smbd
tcp6 0 0 :::445 :::* LISTEN 12851/smbd
# smbpasswd -a root //创建samba用户密码
New SMB password:
Retype new SMB password:
Added user root.