• 利用ansible书写playbook在华为云上批量配置管理工具自动化安装ceph集群


    ansible、playbook、华为云、ceph

    首先在华为云上购买搭建ceph集群所需云主机:

    然后购买ceph所需存储磁盘

    将购买的磁盘挂载到用来搭建ceph的云主机上

    在跳板机上安装ansible

    查看ansible版本,检验ansible是否安装成功

    配置主机分组

    测试结果

    书写playbook文件内容如下:

     1 ---
     2 #将yum文件同步到各个节点
     3 - hosts: ceph
     4   remote_user: root
     5   tasks: 
     6     - copy:
     7         src: /etc/yum.repos.d/ceph.repo
     8         dest: /etc/yum.repos.d/ceph.repo
     9     - shell: yum clean all
    10 #给ceph-0001主机安装ceph-deploy,创建工作目录,初始化配置文件
    11 - hosts: ceph-0001
    12   remote_user: root
    13   tasks:
    14     - yum: 
    15         name: ceph-deploy
    16         state: installed
    17     - file: 
    18         path: /root/ceph-cluster
    19         state: directory
    20         mode: '0755'
    21 #给所有ceph节点安装ceph相关软件包
    22 - hosts: ceph
    23   remote_user: root
    24   tasks:
    25     - yum:
    26         name: ceph-osd,ceph-mds
    27         state: installed
    28 #给ceph-0001,ceph-0002,ceph-0003安装ceph-mon
    29 - hosts: ceph-0001,ceph-0002,ceph-0003
    30   remote_user: root
    31   tasks:
    32     - yum:
    33         name: ceph-mon
    34         state: installed
    35 #初始化mon服务
    36 - hosts: ceph-0001
    37   tasks:
    38     - shell: 'chdir=/root/ceph-cluster ceph-deploy new ceph-0001 ceph-0002 ceph-0003'
    39     - shell: 'chdir=/root/ceph-cluster ceph-deploy mon create-initial'
    40 #准备磁盘分区,创建journal盘,并永久修改设备权限,使用ceph-deploy工具初始化数据磁盘,初始化OSD集群,部署ceph文件系统
    41 - hosts: ceph
    42   remote_user: root
    43   tasks:
    44     - shell: parted /dev/vdb mklabel gpt
    45     - shell: parted /dev/vdb mkpart primary 1 100%
    46     - shell: chown  ceph.ceph  /dev/vdb1
    47     - copy: 
    48         src: /etc/udev/rules.d/70-vdb.rules
    49         dest: /etc/udev/rules.d/70-vdb.rules
    50 - hosts: ceph-0001
    51   remote_user: root
    52   tasks:
    53     - shell: 'chdir=/root/ceph-cluster ceph-deploy disk zap ceph-0001:vdc'
    54     - shell: 'chdir=/root/ceph-cluster ceph-deploy disk zap ceph-0002:vdc'
    55     - shell: 'chdir=/root/ceph-cluster ceph-deploy disk zap ceph-0003:vdc'
    56     - shell: 'chdir=/root/ceph-cluster ceph-deploy disk zap ceph-0004:vdc'
    57     - shell: 'chdir=/root/ceph-cluster ceph-deploy disk zap ceph-0005:vdc'
    58     - shell: 'chdir=/root/ceph-cluster ceph-deploy disk zap ceph-0006:vdc'
    59     - shell: 'chdir=/root/ceph-cluster ceph-deploy osd create ceph-0001:vdc:/dev/vdb1'
    60     - shell: 'chdir=/root/ceph-cluster ceph-deploy osd create ceph-0002:vdc:/dev/vdb1'
    61     - shell: 'chdir=/root/ceph-cluster ceph-deploy osd create ceph-0003:vdc:/dev/vdb1'
    62     - shell: 'chdir=/root/ceph-cluster ceph-deploy osd create ceph-0004:vdc:/dev/vdb1'
    63     - shell: 'chdir=/root/ceph-cluster ceph-deploy osd create ceph-0005:vdc:/dev/vdb1'
    64     - shell: 'chdir=/root/ceph-cluster ceph-deploy osd create ceph-0006:vdc:/dev/vdb1'
    65     - shell: 'chdir=/root/ceph-cluster ceph-deploy mds create ceph-0006'
    66     - shell: 'chdir=/root/ceph-cluster ceph osd pool create cephfs_data 128'
    67     - shell: 'chdir=/root/ceph-cluster ceph osd pool create cephfs_metadata 128'
    68     - shell: 'chdir=/root/ceph-cluster ceph fs new myfs1 cephfs_metadata cephfs_data'

    playbook具体执行过程如下:

    前往ceph-0001管理主机上验证:集群已搭建成功

  • 相关阅读:
    nodejs MYSQL数据库执行多表查询
    【BZOJ3994】[SDOI2015]约数个数和 莫比乌斯反演
    【BZOJ2693】jzptab 莫比乌斯反演
    【BZOJ2154】Crash的数字表格 莫比乌斯反演
    【BZOJ2242】[SDOI2011]计算器 BSGS
    【BZOJ2005】[Noi2010]能量采集 欧拉函数
    【BZOJ1408】[Noi2002]Robot DP+数学
    【BZOJ2045】双亲数 莫比乌斯反演
    【BZOJ2186】[Sdoi2008]沙拉公主的困惑 线性筛素数
    【BZOJ4176】Lucas的数论 莫比乌斯反演
  • 原文地址:https://www.cnblogs.com/jrjs/p/11742221.html
Copyright © 2020-2023  润新知