RHCE 共享文件系统
9.1 共享文件系统
概述: 共享文件系统通常有两种方式:
基于文件共享,一种直接共享文件夹给client端,常见的技术有NFS(Network File System )和 SMB (Server Message Block)
基于block共享,即共享服务器端分配的磁盘给client端使用。
--------------------------------------------------------------------------------------------------------
测试环境
--------------------------------------------------------------------------------------------------------
9.1.1 基于文件共享
NFS 配置
服务端设置
安装包
libnfsidmap-0.25-9.el7.x86_64
nfs-utils-1.3.0-0.el7.x86_64
服务名: nfs
防火墙:
1. 安装包检查及安装
rpm -qa | grep -i nfs
yum install nfs-utils-*
2. 启动服务nfs-server
systemctl restart nfs-server
systemctl enable nfs-server
systemctl status nfs-serve
3. 开启防火墙
rhel 7
firewall-cmd --permanent --add-service=nfs
firewall-cmd --reload
4. 配置分享的文件
4.1. 创建分享的文件系统
mkdir /nfs
如果分享的用户有写权限,需要设置other 对共享文件夹有写权限
4.2. 配置共享文件
/etc/exports /nfs desktop0(rw)
保存退出后,使用命令检测是否成功
exportfs -r
客户端设置
配置/etc/fstab
192.168.56.12:/nfs /sharednfs nfs defaults 0 0
执行挂载
mount -a
df -h
mount 192.168.56.12:nfs /sharednfs
SMB (Server Message Block)
安装包
samba
samba-client
服务 :smb
防火墙:
服务端设置
1. 安装包
yum install samba*
2. 启动服务
systemctl restart smb
systemctl enable smb
systemctl status smb
3. 开启防火墙
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
4. 创建共享文件目录,及用户需求
mkdir /samba
5. 设置共享文件
5.1 添加共享配置
/etc/samba/smb.conf [samba_s0]
path=/samba
valid users=user0
write list=user1,user2
hosts allow=192.168.56.1
writable=no
5.2 执行命令testparm 检查配置是否存在语法错误
[root@localhost ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[samba_s0]"
Loaded services file OK.
“Loaded services file OK.” 表示everything is ok
5.3 将用户升级为samba用户,需要设置对应用户的登录密码
smbpasswd -a user0
[root@localhost ~]# smbpasswd -a user0
New SMB password:
Retype new SMB password:
Added user user0.
客户端设置
安装包
samba-client-3.6.23-45.el6_9.x86_64
cifs-utils-4.8.1-20.el6.x86_64 服务:N/A
1. 安装安装包
yum install samba-client
yum install cifs*
2. 测试是否能够访问成功
2.1 测试是否mount 成功
[root@dpf01 ~]# mount -ousername=user0 //192.168.56.12/samba_s0 /samba
Password:
2.2 测试是否有读权限
[root@dpf01 ~]# cd /samba
[root@dpf01 samba]# ls
ls: reading directory .: Permission denied
原因分析及解决方法
临时关闭 selinux, 测试成功
setenforce 0
接下来我们 fix ,在 server 端做如下操作
方法一:
[root@localhost ~]# semanage fcontext -a -t samba_share_t "/samba(/.*)?"
[root@localhost ~]# restorecon -R -v /samba
restorecon reset /samba context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:samba_share_t:s0
[root@localhost ~]# ls -dZ /samba
drwxr-xr-x. root root unconfined_u:object_r:samba_share_t:s0 /samba 方法二: 通过查看配置文件 /etc/samba/smb.conf
# Security-Enhanced Linux (SELinux) Notes:
#
# Turn the samba_domain_controller Boolean on to allow Samba to use the useradd
# and groupadd family of binaries. Run the following command as the root user to
# turn this Boolean on:
# setsebool -P samba_domain_controller on
#
# Turn the samba_enable_home_dirs Boolean on if you want to share home
# directories via Samba. Run the following command as the root user to turn this
# Boolean on:
# setsebool -P samba_enable_home_dirs on
#
# If you create a new directory, such as a new top-level directory, label it
# with samba_share_t so that SELinux allows Samba to read and write to it. Do
# not label system directories, such as /etc/ and /home/, with samba_share_t, as
# such directories should already have an SELinux label.
#
# Run the "ls -ldZ /path/to/directory" command to view the current SELinux
# label for a given directory.
#
# Set SELinux labels only on files and directories you have created. Use the
# chcon command to temporarily change a label:
# chcon -t samba_share_t /path/to/directory
#
# Changes made via chcon are lost when the file system is relabeled or commands
# such as restorecon are run.
#
# Use the samba_export_all_ro or samba_export_all_rw Boolean to share system
# directories. To share such directories and only allow read-only permissions:
# setsebool -P samba_export_all_ro on
# To share such directories and allow read and write permissions:
# setsebool -P samba_export_all_rw on
9.1.2 基于 block 共享
ISSCI
1. 安装必要的安装包
2. 创建共享的磁盘
3. 配置ISSCI 服务端
服务端设置
要求的安装包
target
服务:target
防火墙:
1. 安装包
yum install target*
2. 启动服务
systemctl restart target
systemctl enable target
systemctl status target
3. 配置共享磁盘
targetcli [root@localhost RHEL-7.0 Server.x86_64]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'. /> ls
o- / ..................................................................................................................... [...]
o- backstores .......................................................................................................... [...]
| o- block .............................................................................................. [Storage Objects: 0]
| o- fileio ............................................................................................. [Storage Objects: 0]
| o- pscsi .............................................................................................. [Storage Objects: 0]
| o- ramdisk ............................................................................................ [Storage Objects: 0]
o- iscsi ........................................................................................................ [Targets: 0]
o- loopback ..................................................................................................... [Targets: 0]
/> /backstores> block/ create block0 /dev/sda5
Created block storage object block0 using /dev/sda5.
cd ..
/> ls
o- / ..................................................................................................................... [...]
o- backstores .......................................................................................................... [...]
| o- block .............................................................................................. [Storage Objects: 1]
| | o- block0 .................................................................. [/dev/sda5 (200.0MiB) write-thru deactivated]
| o- fileio ............................................................................................. [Storage Objects: 0]
| o- pscsi .............................................................................................. [Storage Objects: 0]
| o- ramdisk ............................................................................................ [Storage Objects: 0]
o- iscsi ........................................................................................................ [Targets: 0]
o- loopback ..................................................................................................... [Targets: 0]
/> iscsi/ create iqn.2017-11.com.example:remotedisk1
cd iscsi/iqn.2017-11.com.example:remotedisk1/tpg1/
acls/ create iqn.2017-11.com.example:192.168.56.1
luns/ create
portals/ create 192.168.56.12 /> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 1]
| | o- block0 ........................................................................ [/dev/sda5 (200.0MiB) write-thru activated]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 1]
| o- iqn.2017-11.com.example:remotedisk1 ............................................................................... [TPGs: 1]
| o- tpg1 ............................................................................................... [no-gen-acls, no-auth]
| o- acls .......................................................................................................... [ACLs: 1]
| | o- iqn.2017-11.com.example:192.168.56.1 ................................................................. [Mapped LUNs: 1]
| | o- mapped_lun0 ................................................................................ [lun0 block/block0 (rw)]
| o- luns .......................................................................................................... [LUNs: 1]
| | o- lun0 ....................................................................................... [block/block0 (/dev/sda5)]
| o- portals .................................................................................................... [Portals: 1]
| o- 192.168.56.12:3260 ............................................................................................... [OK]
o- loopback ......................................................................................................... [Targets: 0]
/>
4. 防火墙设置
[root@localhost ~]# firewall-cmd --permanent --add-port=3260/tcp
success
[root@localhost ~]# firewall-cmd --reload
success
客户端设置
1. 安装包
iscsi-initiator-utils
2. 启动服务
systemctl restart iscsid
systemctl enable iscsid
systemctl status iscsid
2. 设置配置文件
/etc/iscsi/initiatorname.iscsi
nitiatorName=iqn.2017-11.com.example:192.168.56.1
3. 发现共享 node
iscsiadm --mode discoverydb --type sendtargets --portal 192.168.56.12 --discover
[root@dpf01 ~]# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.56.12 --discover
Starting iscsid: [ OK ]
192.168.56.12:3260,1 iqn.2017-11.com.example:remotedisk1
4. login node
iscsiadm --mode node --targetname iqn.2017-11.com.example:remotedisk1 --portal 192.168.56.12:3260 --login
iscsiadm --mode node --targetname iqn.2001-05.com.doe:test --portal 192.168.1.1:3260 --logout
5. 配置/etc/fstab
RHCE 共享文件系统的更多相关文章
- 基于 Azure 托管磁盘配置高可用共享文件系统
背景介绍 在当下,共享这个概念融入到了人们的生活中,共享单车,共享宝马,共享床铺等等.其实在 IT 界,共享这个概念很早就出现了,通过 SMB 协议的 Windows 共享目录,NFS 协议的网络文件 ...
- Linux安装配置Samba共享文件系统
Samba共享文件系统搭建与配置: 1.Samba服务端:yum install samba samba-client cifs-utilscd /etc/samba/cp smb.conf smb. ...
- Openmpi 编译安装+集群配置 + Ubuntu14.04 + SSH无密码连接 + NFS共享文件系统
来源 http://www.open-mpi.org/ 网络连接 SSH连接,保证各台机器之间可以无密码登陆,此处不展开 hosts文件如下 #/etc/hosts 192.168.0.190 mas ...
- NFS网络共享文件系统
1.nfs服务端配置操作 1.1 创建所需的共享目录--源 mkdir /data/rw #rw代表同步的数据可读可写 1.2 对共享目录进行授权 chown -R nfsnobody.nfsno ...
- NFS,两台linux设置网络共享文件系统
NFS,MOUNT,UMOUNT 简介 NFS是Network File System的简写,网络文件系统.通过使用NFS,用户和程序可以像访问本地文件一样访问远端系统上的文件,根据权限的控制可以对N ...
- exportfs - 管理NFS共享文件系统列表
概述 (SYNOPSIS) /usr/sbin/exportfs [-avi] [-o options,..] [client:/path ..] /usr/sbin/exportfs -r [-v] ...
- nfs共享文件系统
NFS服务简介 NFS 就是 Network FileSystem 的缩写,最早之前是由sun 这家公司所发展出来的. 它最大的功能就是可以透过网络,让不同的机器.不同的操作系统.可以彼此分享个别的档 ...
- NFS共享文件系统部署
1. 概述 本篇博客主要是介绍如何安装和使用NFS服务. 2. 安装软件包 首先确认系统是否已经安装相应的软件包,执行命:rpm -qa | egrep "rpcbind|nfs-utils ...
- SharedFile System Master Slave(共享文件系统)做ActiveMQ集群
WINDOWS环境下:http://www.apache.org/dyn/closer.cgi?path=/activemq/apache-activemq/5.9.0/apache-activemq ...
随机推荐
- UVa 10829 L-Gap Substrings (后缀数组+rmq)
题意:给定上一个串,问你多少种UVU这一种形式的串,其中U不为空并且V的长度给定了. 析:枚举 U 的长度L,那么U一定是经过 0 L 2L 3L .... 其中的一个,所以求两个长度反lcp,一个向 ...
- (转)【javascript基础】原型与原型链
原文地址:http://www.cnblogs.com/allenxing/p/3527654.html 前言 原型是什么 理解原型对象 原型对象 isPrototypeOf hasOwnProper ...
- Tomcat 系统架构与设计模式2
门面设计模式 门面设计模式在 Tomcat 中有多处使用,在 Request 和 Response 对象封装中.Standard Wrapper 到 ServletConfig 封装中.Applica ...
- 点滴笔记(一):for循环ajax请求添加数据
项目里遇到循环添加数据,添加多条数据到主表后,还要根据每条主表数据主键ID添加到子表里,于是想到post提交 发现循环post没效果,也没async参数.. 于是用ajax里面有async设置了fal ...
- Android-DateTimeAndroidUtil-工具类
DateTimeAndroidUtil-工具类 是关于时间日前相关的公用方法: package liudeli.mynetwork01.utils; import android.util.Log; ...
- 如何修改TFS 2013中工作项附件大小限制
默认情况下,TFS工作项的附件大小限制为4MB.我们可以通过调用TFS提供的Web Service将这个限制调整最高到2GB. 调整这个设置的必备条件是你需要拥有TFS应用层管理员的权限.下面来看看如 ...
- Azure静态公网ip自助反解
Linux下安装az工具,并登陆 az login 执行 az network public-ip update --resource-group ip所在资源组名称 --name ip对应资源名称 ...
- 手动编译安装lamp之mysql
转自马哥教育的讲课文档 二.安装mysql-5.5.28 1.准备数据存放的文件系统 新建一个逻辑卷,并将其挂载至特定目录即可.这里不再给出过程. 这里假设其逻辑卷的挂载目录为/mydata,而后需要 ...
- C#多边形求角——实例说
前段时间有写过一个计算多边形角度的代码,这里给它整理整理,留给自己也送给萌新. 看左下图,这是一个多环的多边形,一个外环(内部为多边形内部区域),一个内环(外部为多边形内部区域),同时多边形中任意一个 ...
- C++的一些知识点摘抄(创建基本类 高级类)
问:对象有多大? 答:对象占据的内存量取决于其成员变量的长度,类函数不占据为对象分配的内容. 有些编译器在内存中对齐变量,这导致2字节变量实际占用的内存多于2字节. 问:为何不应将所有成员数据声明为公 ...