云存储实践-构建NAS

实验准备 两台虚拟机 主节点 Nfs-server 从节点nfs-client

两个节点上安装 nfs服务

yum -y install nfs-utils rpcbind


关闭防火墙(主节点从节.点全部关闭)

主节点

[root@nfs-server ~]# systemctl stop firewalld

[root@nfs-server ~]# systemctl disable firewalld

从节点

[root@nfs-client ~]# systemctl stop firewalld

[root@nfs-client ~]# systemctl disable firewalld

关闭selinux(主从都做)

[root@nfs-server ~]# setenforce 0

[root@nfs-server ~]# getenforce

Permissive

[root@nfs-client ~]# setenforce 0

[root@nfs-client ~]# getenforce

Permissive

配置Hosts映射文件(主从都做)

[root@nfs-server ~]# vi /etc/hosts



Server端共享

在server段创建一个目录用来共享

[root@nfs-server ~]# mkdir -p /opt/test

[root@nfs-server ~]# ll /opt/

total 0

drwxr-xr-x. 2 root root 6 Apr 20 18:26 test


编辑配置文件

[root@nfs-server ~]# vi /etc/exports

/opt/test 192.168.100.15/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)

编辑配置文件

[root@nfs-server ~]# vi /etc/exports

/opt/test 192.168.100.15/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)


rw 读写访问


sync 所有数据在请求时写入共享


hide 在NFS共享目录中不共享其子目录


no_hide 共享NFS目录的子目录


all_squash 共享文件的UID和GID映射匿名用户anonymous,适合公用目录。


no_all_squash 保留共享文件的UID和GID(默认)


root_squash root用户的所有请求映射成如anonymous用户一样的权限(默认)


no_root_squas root用户具有根目录的完全管理访问权限

初始化配置

[root@nfs-server ~]# exportfs -r

[root@nfs-server ~]#

启动Nfs

[root@nfs-server ~]# systemctl start rpcbind

[root@nfs-server ~]# systemctl enable rpcbind

[root@nfs-server ~]# systemctl start nfs

^[[A[root@nfs-server ~]# systemctl enable nfs

Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.


查看可挂载目录

[root@nfs-server ~]# showmount -e 192.168.100.10

Export list for 192.168.100.10:

/opt/test 192.168.100.15/24


Client端挂载共享目录


查看挂载情况


验证NFS共享存储

创建一个123文件进行测试


用md 5 工具计算123 代码如下

[root@nfs-client mnt]# md5sum 123

d41d8cd98f00b204e9800998ecf8427e 123

主节点查看/opt/test目录


用md5计算123


L两个值一样 验证成功

切换tcp协议

[root@nfs-client mnt]# mount -t nfs 192.168.100.10:/opt/test /mnt/ -o proto=tcp -o nolock

配置cifs

修改主机名

[root@nfs-client mnt]# hostnamectl set-hostname samba

[root@nfs-client mnt]# bash


[root@samba ~]# /usr/sbin/iptables-save

# Generated by iptables-save v1.4.21 on Wed Apr 20 18:48:49 2022

*filter

:INPUT ACCEPT [175:11776]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [94:9492]

COMMIT

# Completed on Wed Apr 20 18:48:49 2022


[root@samba ~]# yum install samba



[root@samba ~]# mkdir -p /opt/share

[root@samba ~]# chmod 777 /opt/share

[root@samba ~]#




[root@samba ~]# smbpasswd -a root

New SMB password:

Retype new SMB password:

Added user root.

[root@nfs-client ~]# yum install samba-client




发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章