存储概念解析

  • 分布式存储
  • 概念
  • 是一种独特的系统架构
  • 由一组能够通过网络连接 为了完成共同任务而协调任务的计算机节点组成
  • 分布式是为了使用廉价的普通的计算机完成复杂的计算和存储任务
  • 目的就是利用更多的机器处理更多的数据或任务
  • 特性
  • 可扩展:分布式存储系统可以扩展到几百甚至几千台的集群规模而且随着集群规模的增长 系统整体性能表现为线性增长
  • 低成本:分布式存储系统的自动容错 自动负载均衡机制使其可以构建在普通的PC机上 另外 线性扩展能力也使得增加 尖山机器非常方便 可以实现自动运维
  • 高性能: 无论是针对整个集群还是单台服务器 都要求分布式存储系统具备高性能
  • 易用: 分布式存储系统需要能够提供易用的对外接口 也要求具备完善的监控 运维工具 并与其它系统集成
  • 分布式算法
  • 哈希分布
  • 顺序分布
  • 常用分布式存储方案
  • Lustre
  • Hadoop
  • FastDFS
  • GlusterFS
  • Ceph

Ceph概述

  • 什么是Ceph
  • ceph是一个分布式存储系统 具有高扩展 高可用 高性能等优点
  • ceph可以提供块存储 文件存储 对象存储
  • ceph可以支持EB级别的存储空间
  • 作为软件定义存储的优秀解决方案在行业中已得到广泛应用
  • Ceph架构图

Ceph Ceph概述 块存储 存储池 rbd镜像管理 Ceph客户端_Ceph

MON:集群监控  

OSD:数据存储

MGR:管理器

MDS:存放文件系统的元数据 

RGW:对象存储

  • ceph工作图

Ceph Ceph概述 块存储 存储池 rbd镜像管理 Ceph客户端_Ceph_02

Ceph数据存储

  • 名词解释
  • Object:对象
  • Ceph最底层的存储单元
  • 每个Object包含元数据和数据
  • Pool:存储池
  • 石村出对想得逻辑区分
  • 规定了数据冗余的类型和对应的副本分布策略
  • 支持两种类型:副本和纠删码 目前基本上使用的都是3副本类型
  • PG:数据放置组
  • 是一个逻辑概念
  • 引入这一层是为了更好的分配和定位数据
  • CRUSH:算法
  • 是ceph使用的数据分布算法
  • 确保数据分配到预期的地方
  • 是容灾级别的控制策略
  • 支持ceph存储集群动态扩展 重新平衡和恢复
  • Ceph数据存储

Ceph Ceph概述 块存储 存储池 rbd镜像管理 Ceph客户端_Ceph_03

Ceph搭建    实验举例:

  • 虚拟机准备 所有主机至少2G内存 关闭防火墙和SeLinux
  • ceph1 192.168.88.11 额外3块硬盘
  • ceph2 192.168.88.12 额外3块硬盘
  • ceph3 192.168.88.13 额外3块硬盘
  • client 192.168.88.10
  • 基础准备工作
  • 更新自定义yum源 加入ceph相关软件
## 更新自定义yum源

[root@server1 ~]# scp /linux-soft/s2/zzg/ceph_soft/cephclient-rpm/* [email protected]:/var/ftp/rpms/

[root@pubserver ~]# createrepo --update /var/ftp/rpms/      #更新yum源repodata信息
[root@pubserver ~]# yum clean all; yum repoinfo
...
Total packages: 8,289
[root@pubserver ~]#
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 配置所有节点主机名解析
## 添加所有节点主机名解析配置

# blockinfile模块跟lineinfile基本一样,向指定文件内加入一段内容
# 192.168.88.240必须解析为quay.io!!!
[root@pubserver ~]# cd ceph/
[root@pubserver ceph]# vim 01_update_hosts.yml
---
- name: update hosts
  hosts: all
  tasks:
    - name: add host resolv     #修改/etc/hosts文件添加主机名映射
      blockinfile:
        path: /etc/hosts
        block: |
          192.168.88.10 client
          192.168.88.11 ceph1
          192.168.88.12 ceph2
          192.168.88.13 ceph3
          192.168.88.240  quay.io 
[root@pubserver ceph]# ansible-playbook 01_update_hosts.yml
[root@pubserver ceph]# ansible all -m shell -a "tail -7 /etc/hosts"
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 配置所有节点yum源
## 更新所有节点yum源

[root@pubserver ceph]# vim files/local88.repo
[BaseOS]
name=RockyLinux BaseOS
enabled=1
gpgcheck=0
baseurl="ftp://192.168.88.240/dvd/BaseOS/"

[AppStream]
name=RockyLinux AppStream
enabled=1
gpgcheck=0
baseurl="ftp://192.168.88.240/dvd/AppStream/"

[rpms]
name=local rpms
enabled=1
gpgcheck=0
baseurl="ftp://192.168.88.240/rpms/"

[root@pubserver ceph]# vim 02_update_yum.yml
---
- name: update yum
  hosts: all
  tasks:
    - name: remove dir  #删除目录
      file:
        path: /etc/yum.repos.d/
        state: absent
    - name: create dir  #创建目录
      file:
        path: /etc/yum.repos.d/
        state: directory
    - name: upload file #发送repo文件
      copy:
        src: files/local88.repo
        dest: /etc/yum.repos.d/local88.repo

[root@pubserver ceph]# ansible-playbook 02_update_yum.yml
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 配置时间同步服务
## 配置时间同步服务Chronyd

# 配置服务端
[root@pubserver ~]# timedatectl                                 #查看系统时间配置
[root@pubserver ~]# timedatectl set-timezone Asia/Shanghai      #设置时区为上海

[root@pubserver ~]# date    
[root@pubserver ~]# date -s "年-月-日 时:分:秒"                   #如果日期时间不对则修改

[root@pubserver ~]# yum -y install chrony
[root@pubserver ~]# vim /etc/chrony.conf
...
 25 allow 192.168.88.0/24   #允许88网段主机同步时间
 26  
 27 # Serve time even if not synchronized to a time source.
 28 local stratum 10        #向下10层同步时间
...
[root@pubserver ~]# systemctl enable chronyd            #设置服务开机自启动
[root@pubserver ~]# systemctl restart chronyd           #重启chronyd服务
[root@pubserver ~]# ss -antpul | grep 23
udp   UNCONN 0  0  127.0.0.1:323   0.0.0.0:*    users:(("chronyd",pid=9225,fd=5))
udp   UNCONN 0  0    0.0.0.0:123   0.0.0.0:*    users:(("chronyd",pid=9225,fd=6))
[root@pubserver ~]# 

# 配置客户端(使用系统角色)
[root@pubserver ~]# yum -y install rhel-system-roles.noarch
[root@pubserver ~]# cd ceph/
[root@pubserver ceph]# cp -r /usr/share/ansible/roles/rhel-system-roles.timesync/ ./roles/timesync
[root@pubserver ceph]# ansible-galaxy list
# /root/ceph/roles
- timesync, (unknown version)
[root@pubserver ceph]# vim 03_timesync.yml 
---
- name: config ntp  #利用