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源

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

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的信息如下

############# 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包无法正常下载

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

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

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

wget http://mirrors.ustc.edu.cn/ceph/keys/release.asc

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

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客户端的源配置,首先是常规源

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才能正常使用

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工具

apt install ansible sshpass

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

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

# 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文件

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

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

ansible all -i nodes -m ping

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

ansible osds -i nodes -m shell -a 'uptime'

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

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'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奋斗的松鼠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值