基于NFS的分布式持久化
来源:互联网 发布:2017淘宝入门基础知识 编辑:程序博客网 时间:2024/06/05 01:00
原文链接:http://www.cnblogs.com/JiaK/p/5803734.html
基于容器的微服务架构中,分布式持久化方案并没有一个默认的最好方案,这里使用NFS来作为容器持久化方案。
NFS服务需要在服务器及需要挂载的客户端上分别安装配置。
nfs-utils包含服务:
rpcbind : The rpcbind server converts RPC program numbers into universal addresses.
nfs-server : It enables the clients to access NFS shares.
nfs-lock / rpc-statd : NFS file locking. Implement file lock recovery when an NFS server crashes and reboots.
nfs-idmap : It translates user and group ids into names, and to translate user and group names
into ids
nfs相关配置文件:
/etc/exports : It is a main configuration file, controls which file systems are exported to remote hosts and specifies options.
/etc/fstab : This file is used to control what file systems including NFS directories are mounted when the system boots.
/etc/sysconfig/nfs : This file is used to control which ports the required RPC services run on.
/etc/hosts.allow, and /etc/hosts.deny : These files are called TCP wrappers, controls the access to NFS server. It is used by NFS to decide whether or not to accept a connection coming in from another IP address
NFS服务器安装:
Step1:安装及启动
1 yum install nfs-utils libnfsidmap2 systemctl enable rpcbind3 systemctl enable nfs-server4 systemctl start rpcbind5 systemctl start nfs-server6 systemctl start rpc-statd7 systemctl start nfs-idmapd
Step2:创建共享路径,并开放访问
1 mkdir /data1/share2 chmod 777 /data1/share3 echo '/data1/share 10.200.xx.xx/24(rw,sync,no_root_squash)' >>/etc/exports
其中,IP地址参数指定了需要挂载的client的IP,用掩码模式则指定IP段;
rw表示挂载路径允许读写权限;
sync表示同步模式,默认情况下是异步模式,由于是共享路径所以采用同步模式;
no_root_squash表示客户端能够以root权限操作挂载点文件系统。
Step3:更新挂载文件信息
exportfs -r
exportfs指令的各个参数说明如下:
exportfs -v : Displays a list of shares files and export options on a server
exportfs -a : Exports all directories listed in /etc/exports
exportfs -u : Unexport one or more directories
exportfs -r : Reexport all directories after modifying /etc/exports
Step4:配置服务器防火墙
firewall-cmd --permanent --zone public --add-service mountdfirewall-cmd --permanent --zone public --add-service rpc-bindfirewall-cmd --permanent --zone public --add-service nfsfirewall-cmd --reload
NFS客户端安装:
Step1:安装及启动
yum -y install nfs-utils libnfsidmapsystemctl enable rpcbindsystemctl start rpcbind
Step2:确认NFS服务器挂载信息
showmount -e 10.200.xx.xx
如果返回信息如下:
Export list for 10.200.xx.xx:/data1/share 10.200.xx.xx/24
其中,IP段包含了该客户端的IP地址,则该客户端可以挂载到远程NFS服务器。
Step3:创建挂载URL并挂载NFS服务器
1 mkdir /mnt/share2 mount 10.200.xx.xx:/data1/share /mnt/share
挂载后,通过以下指令查看挂载信息:
mount | grep nfs
正常情况下能够看到挂载到的NFS服务器的挂载信息,也可以通过
df -hT
来查看挂载信息,类型为nfs4的挂载即是到NFS服务器的挂载点。
客户端挂载信息的持久化:
默认情况下,客户端的挂载信息将在服务器reboot后丢失,需要重新挂载。与硬盘挂载相同,可以通过在/etc/fstab中添加NFS挂载信息来持久化挂载:
echo '10.200.xx.xx:/data1/share/ /mnt/share nfs rw,sync,hard,intr 0 0' >>/etc/fstab
而解除挂载,可以直接在NFS客户端使用unmount进行:
unmount /mnt/share
- 基于NFS的分布式持久化
- 分布式内存数据库---Redis的持久化
- 基于JDBC持久化的事务管理
- 分布式持久化消息队列memcacheq的安装部署
- 利用PaceMaker+Qpid(持久化消息)+NFS的Qpid高可用配置
- 基于Field的持久对象
- 分布式 [ ubuntu 上 NFS的安装配置 ]
- 基于Berkeley DB实现的持久化队列
- Java:基于ORM技术的配置文件持久化实现
- 【Quartz】Quartz存储与持久化-基于Spring的配置
- Hibernate是一个基于对象模型持久化的技术
- Quartz存储与持久化-基于quartz.properties的配置
- Quartz存储与持久化-基于Spring的配置
- 【Quartz】Quartz存储与持久化-基于Spring的配置
- 分布式缓存Redis之持久化
- Kubernetes 1.5 实践Tomcat日志NFS服务持久化
- 构建基于NFS文件系统的Openldap身份验证
- 构建基于NFS文件系统的Openldap身份验证
- Netty 3.x 简例
- 观察者模式与发布/订阅模式区别
- 欢迎使用CSDN-markdown编辑器
- for 实习之图像类
- SQL简单查询笔记记录
- 基于NFS的分布式持久化
- 认识一下java的开发环境
- 文件传输基础----Java IO流
- 修路方案 【最小生成树变形】-- 次小生成树
- 浅谈TCP协议的端口(port)
- Essential C++学习笔记 第一章 C++编程基础
- jQuery系列2---DOM操作和事件
- NULL 值与索引
- 单链表的建立