centos7搭建文件共享服务器(centos7创建共享文件夹)

Centos7安装配置NFS服务和挂载

1、选取192.168.65.10作为主服务器,192.168.65.11作为从服务器

2、主机安装rpcbind、nfs服务

yum install nfs-utils rpcbind

3、主机编写配置文件

vim /etc/exports

/data/nginx 192.168.65.0/24(rw,sync,fsid=0)

#同192.168.65.0/24一个网络号的主机可以挂载NFS服务器上的/home/nfs/目录到自己的文件系统中,rw表示可读写;sync表示同步写,fsid=0表示将/data找个目录包装成根目录

4、先为rpcbind和nfs做开机启动:(必须先启动rpcbind服务)

systemctl start rpcbind.service

systemctl start nfs-server.service

systemctl enable rpcbind.service//开机启动

systemctl enable nfs-server.service//开机启动

5、rpcinfo -p #检查 NFS 服务器是否挂载我们想共享的目录

6、exportfs -r #使配置生效

7、exportfs#查看共享目录

8、丛机安装主机安装nfs

9、启动rpcbind

systemctl start rpcbind.service#不需要启动nfs

10、showmount -e 192.168.65.10 #检查 NFS 服务器端是否有目录共享:showmount -e nfs服务器的IP

11、mount -t nfs 192.168.65.10:/data/nginx /data/nginx#挂载目录到共享服务器

12、df -h #查看是否挂载成功

二、Centos7-FTP服务器的搭建

ftpname为你为该ftp创建的用户名,/data/KodServer/data/User/tomas/home 为登录进去后的位置

(备注:用cat etc/passwd可以查看当前系统用户)

①、查看ftp的状态:sestatus -b | grep ftp

②、在结果中可以看到: tftp_home_dir off

③、将状态改为on:setsebool -P tftp_home_dir on

④、重启vsftp服务:systemctl restart vsftpd.service

问题:Failed to restart vsftpd.service: Unit not found.

把ftp用户写进去,如果没有这个文件的话就可以复制当前目录下user_list那个文件,然后清空添加用户名即可。

然后就可以使用ftp工具从外部访问了

centos7配置nfs共享存储服务?

nfs服务端需要确定这两个包正确安装 nfs-utils rpcbind

若是ubuntu服务器,则是nfs-common,nfs-kernel-server两个包,rpcbind是默认安装的。

yum -y install nfs-utils rpcbind

编辑共享目录配置文件 /etc/exports

/var/www/html  192.168.10.0/24(rw,async,no_root_squash)  192.168.20.0/24(ro)

#多个网段或主机之间用空格分开

/var/www          192.168.10.0/24(ro,sync,root_squash)

参数:ro表示只读,rw表示可读写,sync同步写*即同时写入内存和硬盘,async异步*暂存于内存,no_root_squash表示如果客户端连接过来的用户是root,则对服务端的目录同样是root权限****请不要开启,好危险的,root_squash表示客户端是root则将其转为匿名用户的权限***建议开启。

启动nfs服务,并设为开机自启动

service rpcbind start #或则 systemctl start rpcbind

service nfs start #或则 systemctl start nfs

######ubuntu服务器则是 service startnfs-kernel-server start

chkconfig rpcbind on #或则 systemctl enable rpcbind

chkconfig nfs on #或则 systemctl enable nfs

配置防火墙,放行响应端口或服务

firewall-cmd --permanent --add-service=nfs

firewall-cmd --permanent --add-service=rpc-bind

firewall-cmd --permanent --add-service=mountd

firewall-cmd --reload

firewall-cmd --list-all #查看firewalld方向的资源

客户端挂载

showmount -e nfs_server_ip: 查看nfs服务端的可用挂载点

客户端挂载操作

mount -t nfs nfs_server:/var/www/html  /bendikongmulu

或者

mount -t nfs nfs_server:/var/www/html  /bendikongmulu -o proto=tcp

无报错便成功,当然客户端可以使用 df -h 来查看是否挂载过来了;这里客户端切换到本地挂载点便可以看见服务端的文件了(注意若,服务端共享的目录为空,客户端是无法查看的)网页链接

centos7挂载Windows共享文件夹

centos7挂载windows共享文件夹

练习环境:centos7是安装在台式机的虚拟机,Windows共享文件夹是公司服务器的共享文件夹(已设置好的共享)

步骤

1. 设置挂载点: mkdir /mnt/win #挂载点可以自己根据喜好设置

mount -t cifs -o username=\"共享文件夹的登录账户\",password=\"共享文件夹的共享密码\" //192.168.4.245/备份目录 /mnt/win

查看win的共享文件夹是否被挂载

df -h

或者直接到挂载文件夹下看一下有没有挂载内容

pre style=\"box-sizing: border-box; outline: 0px; margin: 0px 0px 24px; padding: 8px; font-weight: normal; position: relative; white-space: pre-wrap; overflow-wrap: break-word; overflow-x: auto; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; line-height: 22px; color: rgb(0, 0, 0);\"#cd /mnt/win

3. 开机自动挂载

修改fstab文件 vim /etc/fstab

在文件的末尾加上一行

//192.168.4.245/备份 /mnt/win cifs username=共享文件夹的登录账户,password=共享文件夹的共享密码 0 0

一旦共享文件夹的主机ip地址、登录账户及密码发生改变,将需要重复1.2.3步骤。

未经允许不得转载:便宜VPS网 » centos7搭建文件共享服务器(centos7创建共享文件夹)