首页 > 其他分享 >GlusterFS环境部署

GlusterFS环境部署

时间:2023-02-20 22:01:19浏览次数:30  
标签:centos7 部署 环境 glusterfs gluster volume GlusterFS data dis

这是一篇关于GlusterFS入门文章,主要讲述GlusterFS环境搭建以及初步使用。

GlusterFS相关进程

glusterfs的进程结构

  • glusterfs :用于客户端挂在的进程
  • glusterfsd:用于数据读写的进程
  • glusterd:物理节点上的glusterfsd的管理进程,glusterd可以管理节点上一个或者多个glusterfsd的进程
  • gluster:用于和glusterd管理进程通信的交互的命令行工具

安装GlusterFS

建议使用ansible配置:yum -y install ansible
yum -y install glusterfs-server
systemctl enable glusterd 或  ansible glusterfs -m shell -a ' systemctl enable glusterd.service'
systemctl start glusterd
firewall-cmd --permanent --add-service=glusterfs
firewall-cmd --reload

配置hosts解析
cat >> /etc/hosts << EOF
192.168.23.11 centos7-1
192.168.23.12 centos7-2
192.168.23.13 centos7-3
192.168.23.14 centos7-4
EOF

配置ssh互信
ssh-copy-id centos7-1
ssh-copy-id centos7-2
ssh-copy-id centos7-3
ssh-copy-id centos7-4

建议关闭selinux

挂载本地磁盘

1.手动挂载
fdisk /dev/sdb  分别按:n 、p 、3个回车键 、w
ansible glusterfs -m shell -a 'lsblk'
ansible glusterfs -m shell -a 'mkfs.xfs -i size=512 /dev/sdb1'
ansible glusterfs -m shell -a 'mount -t xfs /dev/sdb1 /data/sdb1'
ansible glusterfs -m shell -a 'lsblk'
ansible glusterfs -m shell -a 'echo -e "/dev/sdb1 /data/sdb1 xfs defaults 0 0\n" >> /etc/fstab'


2.脚本挂载
vim /opt/fdisk.sh 编辑内容如下

	#!/bin/bash
	echo "the disks exist list:"
	##grep出系统所带磁盘
	fdisk -l |grep '磁盘 /dev/sd[a-z]'    
	echo "=================================================="
	PS3="chose which disk you want to create:"
	 ##选择需要创建的磁盘编号
	select VAR in `ls /dev/sd*|grep -o 'sd[b-z]'|uniq` quit   
	do
   	 case $VAR in
   	 sda)
	 ##本地磁盘就退出case语句
     	   fdisk -l /dev/sda   
     	   break ;;
  	  sd[b-z])
    	    #create partitions
       	 echo "n    ##创建磁盘
          	      p
        	        
                
           
           	     w"  | fdisk /dev/$VAR
 
        	#make filesystem
	##格式化
      	  mkfs.xfs -i size=512 /dev/${VAR}"1" &> /dev/null    
		#mount the system
      	  mkdir -p /data/${VAR}"1" &> /dev/null
	###永久挂载
        	echo -e "/dev/${VAR}"1" /data/${VAR}"1" xfs defaults 0 0\n" >> /etc/fstab
	###使得挂载生效
     	   mount -a &> /dev/null
      	  break ;;
    	quit)
     	   break;;
  	  *)
       	 echo "wrong disk,please check again";;
   	 esac
	done


chmod +x /opt/fdisk.sh
cd /opt/
sh -x fdisk.sh

配置GlusterFS卷,在任意一个节点执行都可以

  • dis-volume 分布式卷
  • stripe-volume 条带卷
  • rep-volume 复制卷
  • dis-stripe 分布式条带卷
  • dis-rep 分布式复制卷
gluster peer probe centos7-1
gluster peer probe centos7-2
gluster peer probe centos7-3
gluster peer probe centos7-4
gluster peer status

创建分布式卷,没有指定类型,默认创建的是分布式卷  
[root@centos7-1 ~]# gluster volume create dis-volume centos7-1:/data/sdb1 centos7-2:/data/sdb1 centos7-3:/data/sdb1 centos7-4:/data/sdb1 force
volume create: dis-volume: success: please start the volume to access data

查看类型  
[root@centos7-1 ~]# gluster volume list
dis-volume

开启  
[root@centos7-1 ~]# gluster volume start dis-volume
volume start: dis-volume: success

查看卷信息  
[root@centos7-1 ~]# gluster volume info dis-volume
Volume Name: dis-volume
Type: Distribute
Volume ID: cbad7555-a018-4278-82d9-a81858470201
Status: Started
Snapshot Count: 0
Number of Bricks: 4
Transport-type: tcp
Bricks:
Brick1: centos7-1:/data/sdb1
Brick2: centos7-2:/data/sdb1
Brick3: centos7-3:/data/sdb1
Brick4: centos7-4:/data/sdb1
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on

创建其他类型卷,参考网上的例子:

创建条带卷,新版本已经不支持  
gluster volume create stripe-volume stripe 2 node1:/data/sdc1 node2:/data/sdc1 force

创建复制卷  
gluster volume create rep-volume replica 2 node3:/data/sdb1 node4:/data/sdb1 force#指定类型为replica,数值为2,且后面跟了2个Brick Server,所以创建的是复制卷gluster volume start rep-volumegluster volume info rep-volume

创建分布式条带卷  
gluster volume create dis-stripe stripe 2 node1:/data/sdd1 node2:/data/sdd1 node3:/data/sdd1 node4:/data/sdd1 force#指定类型为stripe,数值为2,而且后面跟了4个Brick Server,是2的两倍,所以创建的是分布式条带卷gluster volume start dis-stripegluster volume info dis-stripe

创建分布式复制卷  
gluster volume create dis-rep replica 2 node1:/data/sde1 node2:/data/sde1 node3:/data/sde1 node4:/data/sde1 force#指定类型为 replica,数值为 2,而且后面跟了 4 个 Brick Server,是 2 的两倍,所以创建的是分布式复制卷gluster volume start dis-repgluster volume info dis-repgluster volume list

GlusterFS客户端挂载

mkdir /glusterfs-client
mount.glusterfs centos7-1:dis-volume /glusterfs-client

也可以写到/etc/fstab文件:echo "centos7-1:dis-volume /glusterfs-client glusterfs defaults 0 0" >> /etc/fstab  ,这个命令我没执行过

查看客户端文件  
[root@centos7-1 glusterfs-client]# ls
10.c  1.c  2.c  3.c  4.c  5.c  6.c  7.c  8.c  9.c

查看GlusterFS文件存储位置  
[root@centos7-1 glusterfs-client]#  ansible glusterfs -m shell -a 'ls /data/sdb1'
centos7-3 | CHANGED | rc=0 >>
10.c
4.c
7.c
9.c
centos7-4 | CHANGED | rc=0 >>
1.c
2.c
8.c
centos7-2 | CHANGED | rc=0 >>
5.c
centos7-1 | CHANGED | rc=0 >>
3.c
6.c

删除卷,移除节点

gluster volume stop dis-volume  停止卷
gluster volume delete dis-volume  删除卷
gluster peer detach centos7-4  移除机器

停止卷
[root@centos7-1 glusterfs-client]# gluster volume stop dis-volume
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: dis-volume: success

[root@centos7-1 glusterfs-client]# gluster volume list
dis-volume

[root@centos7-1 glusterfs-client]# gluster volume info dis-volume
Volume Name: dis-volume
Type: Distribute
Volume ID: cbad7555-a018-4278-82d9-a81858470201
Status: Stopped
Snapshot Count: 0
Number of Bricks: 4
Transport-type: tcp
Bricks:
Brick1: centos7-1:/data/sdb1
Brick2: centos7-2:/data/sdb1
Brick3: centos7-3:/data/sdb1
Brick4: centos7-4:/data/sdb1
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on

删除卷
[root@centos7-1 glusterfs-client]# gluster volume delete dis-volume
Deleting volume will erase all information about the volume. Do you want to continue? (y/n) y
volume delete: dis-volume: success

[root@centos7-1 glusterfs-client]# gluster volume list
No volumes present in cluster

移除节点
[root@centos7-1 glusterfs-client]# gluster peer detach centos7-4
All clients mounted through the peer which is getting detached need to be remounted using one of the other active peers in the trusted storage pool to ensure client gets notification on any changes done on the gluster configuration and if the same has been done do you want to proceed? (y/n) y
peer detach: success

[root@centos7-1 glusterfs-client]# gluster peer status
Number of Peers: 2

Hostname: centos7-2
Uuid: 87788af3-ef7a-4b28-b179-906affbad8df
State: Peer in Cluster (Connected)

Hostname: centos7-3
Uuid: d751dc03-0265-4b6e-bb04-889ae8f7095f
State: Peer in Cluster (Connected)

查看客户端文件,已经看不到了
[root@centos7-1 glusterfs-client]# ls /glusterfs-client
ls: cannot access /glusterfs-client: Transport endpoint is not connected

查看节点中的文件,文件还在
[root@centos7-1 glusterfs-client]# ansible glusterfs -m shell -a 'ls /data/sdb1'
centos7-2 | CHANGED | rc=0 >>
5.c
centos7-4 | CHANGED | rc=0 >>
1.c
2.c
8.c
centos7-3 | CHANGED | rc=0 >>
10.c
4.c
7.c
9.c
centos7-1 | CHANGED | rc=0 >>
3.c
6.c

重新恢复
gluster peer probe centos7-4
gluster volume create dis-volume centos7-1:/data/sdb1 centos7-2:/data/sdb1 centos7-3:/data/sdb1 centos7-4:/data/sdb1 force
gluster volume start dis-volume
mkdir /test
mount.glusterfs centos7-1:dis-volume /test
[root@centos7-1 glusterfs-client]# ls /test/
10.c  1.c  2.c  3.c  4.c  5.c  6.c  7.c  8.c  9.c

标签:centos7,部署,环境,glusterfs,gluster,volume,GlusterFS,data,dis
From: https://blog.51cto.com/u_14207158/6074482

相关文章

  • maven环境变量配置教程
    maven官网1.点击maven官网,下载maven的zip压缩包解压压缩包2、打开高级系统设置界面鼠标右键桌面的“此电脑”图标,点击“属性”,弹出系统窗口,然后点击“高级系统设置......
  • 周一安卓开发安装测试环境
    今天周一,从头开始学习Android开发。Android基于手机的Unix内核开发。使用的软件是Androidstudio,然后是安装SDK,软件开发工具包。发布helloworld。......
  • 部署堡垒机——准备环境
    1、准备环境centos7关闭防火墙firewalld#清空防火墙规则[email protected]:/root#iptables-F#关闭开机自启动防火墙[email protected]......
  • Conda+VScode配置Python开发环境
    Conda配置与常用指令1、查看conda与Python相关信息查看Python路径wherepython查看conda版本conda--version查看conda详细信息condainfo2、换源更换为清华......
  • 用kubeadm部署K8S
    一、kubeadm部署K8S集群架构主机名IP地址安装组件master(2C/4G,cpu核心数要求大于2)192.168.2.66docker、kubeadm、kubelet、kubectl、flannelnode01(2C/2G)19......
  • K8S多节点二进制部署
    一、多Maser集群架构的了解Kubernetes作为容器集群系统,通过健康检查+重启策略实现了Pod故障自我修复能力,通过调度算法实现将Pod分布式部署,并保持预期副本数,根据Node失效......
  • kubeadm部署k8s集群(云原生)
    内容预知架构说明1.环境准备2.所有节点安装docker3.所有节点安装kubeadm,kubelet和kubectl4.部署Dashboard5.安装部署与k8s集群对接的Harbor仓库内核参数......
  • 生产环境中redis是怎么部署的?
    你的redis是不是主从架构?集群架构?用了哪种集群方案?有没有用高可用保证?有没有开启持久化机制确保可以进行数据恢复?线上redis给几个G的内存?设置了哪些参数?压测后你们redis......
  • django的部署在centos
    虚拟环境#virtualenv是一个创建独立python环境的工具sudopipinstallvirtualenv#virtualenvwrapper将所有的虚拟环境统一管理,留意安装路径后面要用sudopipinstall......
  • Docker安装部署kong和konga,并且配置konga页面
    ps:docker安装kong时,postgres的版本最好使用9.6,版本过高过低可能会出现问题网络配置1dockernetworkcreatekong-net安装启动postgres容器1dockerr......