2.2ceph集群部署准备-软件准备上

系统的选择

操作系统的选取,除了要考虑ceph本身的运行,一般情况下还需要考虑的因素有如下几点

  • 系统本身的稳定性

    目前稳定可靠的系统主要是基于x86和arm的linux系统,ceph并不能安装到windows上,分支上,debian和redhat为最常见的选择,生产环境用得很多,稳定性久经考验,细分分支中最常见的又数Debian和Centos为佳,像Fedora、ubuntu这类系统虽说开发时间长,用户也多,但作为常年运行的生产环境操作系统来说,是不太合适的。

  • 软件包的支持

    虽然大部分的发行版系统都能够通用软件包,但很难避免有些软件包移植产生一些兼容性问题,尤其在不同平台上,软件包的支持度很重要,运行ceph生产集群除了ceph本身的软件包外,还需要大量的软件包支持集群的监控及补充功能开发,另外,针对ceph的二次开发,也需要一些额外的开发工具支持。

  • 运维人员的熟练度

    集群运行期间需要运维人员进行持续的维护,运维人员对系统的熟悉程度直接关系到运维质量,因此在选定操作系统的同时,也需要考虑运维人员对各类系统的熟练度。

本篇及生产集群的操作系统选取上,我们推荐使用Debian Buster系统,它符合上述的三个要求,并且ceph的Pacific对系统版本有最低要求

即Centos 7.x系列已经不支持安装Ceph Pacific及后续版本了

节点配置国内APT源及本地源的建设

国内源速度快,这里配置的是清华源的debian源

bash 复制代码
cat /etc/apt/source.list
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free

配置完成后,需要使用apt update刷新

接下来,我们将自建一个内部的apt源。

我们在前面的步骤中已经配置了腾讯云的源,接下来,我们增加ceph的国内源,并安装apt-mirror

bash 复制代码
root@debian:/etc/apt# apt install gnupg
root@debian:/etc/apt# wget -q -O- 'http://mirrors.ustc.edu.cn/ceph/keys/release.asc' | apt-key add -
root@debian:/etc/apt# echo deb http://mirrors.ustc.edu.cn/ceph/debian-pacific/ $(lsb_release -sc) main | tee /etc/apt/sources.list.d/ceph.list
root@debian:/etc/apt# apt update
root@debian:/etc/apt# apt install apt-mirror

接下来,我们利用apt源,搭建我们自己的内部源,首先我们要将网络上的源同步到本地,修改mirror的信息如下

bash 复制代码
############# config ##################
#base_path是指我们同步网络上的源数据到本地的路径,注意这个
#路径必须要有足够的空间存放数据,至少需要110GiB的可用空间
set base_path    /mnt/
set nthreads     20
set _tilde 0
#
############# end config ##############
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
deb http://mirrors.ustc.edu.cn/ceph/debian-pacific/ buster main

clean http://ftp.us.debian.org/debian

在开始之前,需要修改apt-mirror的相关配置,否则会有部分deb包无法正常下载

bash 复制代码
vi /usr/bin/apt-mirror
523行加入对xz的支持
if ( $filename =~ m{^$component/i18n/Translation-[^./]*\.(bz2|xz)$} )

配置都准备好后,我们执行apt-mirror命令进行同步,这个时间比较长,待同步完成后,整个源的包就下载好了.

bash 复制代码
root@debian:/mnt# apt-mirror
Downloading 118 index files using 20 threads...
Begin time: Sun Feb  4 14:39:44 2024
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]

接下来下载ceph源的key

bash 复制代码
wget http://mirrors.ustc.edu.cn/ceph/keys/release.asc

安装并配置nginx,使得我们的源可以被其他集群节点正常访问,注意修改目录的文件权限

bash 复制代码
apt install nginx
chown www-data.www-data -R /mnt/
vi /etc/nginx/conf.d/apt.conf
server {
    listen       80;
    listen       [::]:80;
    server_name 192.168.183.100 #注意这个位置要改对,不对的话没法用
    charset utf-8;

    # Load configuration files for the default server block.
    index index.html;

    location / {
            root   /var/www/mirror;
            autoindex  on;
            autoindex_exact_size  off;
            autoindex_localtime  on;
            index index.html;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
ln -s /mnt/mirror /var/www/mirror
启动nginx并验证是否能够访问80端口

在网络允许的情况下,最好能够定期同步上游的源,避免出现内部源过期的情况

apt客户端的源配置,首先是常规源

bash 复制代码
deb http://192.168.183.100/mirrors.tuna.tsinghua.edu.cn/debian/ buster main non-free contrib
deb http://192.168.183.100/mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main
deb http://192.168.183.100/mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main non-free contrib
deb http://192.168.183.100/mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main non-free contrib

apt update

接下来配置ceph源,ceph源需要单独配置key才能正常使用

bash 复制代码
ansible all -i nodes -m shell -a 'apt install -y gnupg'
deb http://192.168.183.100/mirrors.ustc.edu.cn/ceph/debian-pacific/ buster main
集群节点添加对ceph的key
ansible mons -i nodes -m copy -a 'src=/mnt/mirror/release.asc dest=/root/'
cat release.asc | apt-key add -
apt update

这样我们就可以使用内部的apt源了。

ansible工具

在设计规划像ceph这样的分布式集群时,我们必须考虑规模,尽管很多环境集群规模不大,但是用好批量化的工具很重要,无论集群规模大小,都能够在工作中提升工作效率。

ansible是一款针对大量机器进行批量化操作的软件,安装方便,命令简单,功能强大,我们将在环境中大量用到它

首先,安装配置ansible工具

bash 复制代码
apt install ansible sshpass

完成后,我们就可以使用ansible工具了。

接下来我们简单认识一下ansible工具的配置文件,这个文件保存在当前目录下,名称为ansible.cfg即可

bash 复制代码
# Comments inside this file must be set BEFORE the option.
# NOT after the option, otherwise the comment will be interpreted as a value to that option.

[defaults]
ansible_managed = Please do not change this file directly since it is managed by Ansible and will be overwritten
library = ./library
action_plugins = plugins/actions
callback_plugins = plugins/callback
roles_path = ./roles
# Be sure the user running Ansible has permissions on the logfile
log_path = ansible.log

# 指定开启进程数
forks = 10
host_key_checking = False
gathering = smart
fact_caching = jsonfile
fact_caching_connection = $HOME/ansible/facts
fact_caching_timeout = 7200
nocows = 1
callback_whitelist = profile_tasks

# Disable them in the context of https://review.openstack.org/#/c/469644
retry_files_enabled = False

# This is the default SSH timeout to use on connection attempts
# CI slaves are slow so by setting a higher value we can avoid the following error:
# Timeout (12s) waiting for privilege escalation prompt:
timeout = 60

接下来,我们配置一个ansible的应用配置,当我们执行ansible命令时,这个配置告诉ansible应该到哪些节点执行哪些任务,比如下面这个nodes文件

bash 复制代码
cat nodes
[osds]
192.168.183.101
192.168.183.102
192.168.183.103
192.168.183.104
192.168.183.105
192.168.183.106
192.168.183.107
[mons]
192.168.183.101
192.168.183.102
192.168.183.103
[rgws]
192.168.183.108
192.168.183.109
[all:vars]
ansible_ssh_port = 22
ansible_ssh_user=root
ansible_ssh_pass=pupu666

比如,我们可以使用如下命令测试节点的连通性

bash 复制代码
ansible all -i nodes -m ping

或者我们单独指定探测osd节点的负载情况

bash 复制代码
ansible osds -i nodes -m shell -a 'uptime'

接下来我们用ansible工具将本节点的hosts文件进行分发,首先创建/etc/hosts文件,hosts相关配置对我们后续集群建设有很大影响

bash 复制代码
for x in $( seq 1 9 );do echo "192.168.183.10${x} debian${x}";done

cat /etc/hosts
192.168.183.100 deployhost
192.168.183.101 debian1
192.168.183.102 debian2
192.168.183.103 debian3
192.168.183.104 debian4
192.168.183.105 debian5
192.168.183.106 debian6
192.168.183.107 debian7
192.168.183.108 debian8
192.168.183.109 debian9

ansible all -i nodes -m copy -a 'src=/etc/hosts dest=/etc/hosts'
相关推荐
国科安芯10 小时前
ASL706S:让 MCU 不再“失忆跑飞“的守护芯片
分布式·单片机·嵌入式硬件·安全·fpga开发·架构
阿无,11 小时前
RabbitMQ面试题
分布式·rabbitmq
盛世宏博智慧档案14 小时前
全国100个分布式机房环境温湿度智能监测系统建设方案
分布式·机房·温湿度
六bring个六15 小时前
分布式设备连接对端失败问题分析
分布式·分布式软总线
天涯明月199321 小时前
ray深度研究报告
大数据·人工智能·分布式·ray
Rain的Java大神之路1 天前
介绍一下分布式事务
java·分布式·后端·spring·spring cloud·架构·springcloud
大菠萝爱上小西瓜2 天前
【大数据实战】Spark 2.2.2 完全分布式集群搭建
大数据·分布式·spark
肠畔码农2 天前
深度解析 RocketMQ 消费端限流与重平衡(Rebalance):分布式队列分配与流控防雪崩本质
分布式·rocketmq
海兰2 天前
【 Kafka进阶3】Apache Kafka 分布式事件流平台:架构原理与微服务解耦机制简要分析
分布式·架构·kafka
麻瓜记录Jackson3 天前
深入剖析 ZooKeeper 分布式 互斥锁:Curator 之 InterProcessMutex 源码全解(附图解)
java·spring boot·分布式·后端·zookeeper·java-zookeeper