• ansible部署ceph集群


    一.  环境准备:

    1.  环境分配:

    192.168.188.112 node2
    192.168.188.113 node3
    192.168.188.114 node4

    2.  配置hosts解析,三个节点都要配置:

    1. [root@node2 ~]# cat /etc/hosts
    2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
    4. 192.168.188.112 node2
    5. 192.168.188.113 node3
    6. 192.168.188.114 node4

    3.  关闭防火墙和selinux:

    1. [root@node2 ~]# selinuxsystemctl stop firewalld
    2. [root@node2 ~]# systemctl disable firewalld
    3. [root@node2 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
    4. [root@node2 ~]# setenforce 0

    4.  设置三个节点时间同步

    1. [root@node3 ~]# yum install chrony -y
    2. [root@node3 ~]# cat /etc/chrony.conf
    3. # Use public servers from the pool.ntp.org project.
    4. # Please consider joining the pool (http://www.pool.ntp.org/join.html).
    5. #server 0.centos.pool.ntp.org iburst
    6. #server 1.centos.pool.ntp.org iburst
    7. #server 2.centos.pool.ntp.org iburst
    8. #server 3.centos.pool.ntp.org iburst
    9. server ntp1.aliyun.com iburst
    10. [root@node3 ~]# systemctl enable chronyd --now
    11. [root@node3 ~]# chronyc sources
    12. 210 Number of sources = 1
    13. MS Name/IP address Stratum Poll Reach LastRx Last sample
    14. ===============================================================================
    15. ^* 120.25.115.20 2 10 137 500 -1643us[-1954us] +/- 26ms

    5.  配置三个节点的免密登录:

    1. ## 生成密钥文件
    2. [root@node2 ~]# ssh-keygen -f ~/.ssh/id_rsa -P '' -q
    3. [root@node2 ~]# ssh-copy-id node2
    4. [root@node2 ~]# ssh-copy-id node3
    5. [root@node2 ~]# ssh-copy-id node4

    6.  配置扩展源:

    1. [root@node2 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com
    2. /repo/epel-7.repo

    7.  安装python2-pip,ansible,git:

    [root@node2 ~]# yum install python2-pip ansible git -y

    二.  部署ceph集群,在一个节点操作即可:

    1.  克隆存储库:

    1. [root@node2 ~]# git clone https://github.com/ceph/ceph-ansible.git
    2. [root@node2 ~]# cd ceph-ansible
    3. [root@node2 ceph-ansible]# git checkout stable-4.0

    2.  安装ansible依赖包:

    [root@node2 ceph-ansible]# yum install python-netaddr python-six -y

    3.  修改hosts文件,添加主机清单:

    1. [root@node2 ceph-ansible]# vim /etc/ansible/hosts
    2. [mons]
    3. node[2:4]
    4. [osds]
    5. node[2:4]
    6. [mgrs]
    7. node2
    8. [mdss]
    9. node[2:4]
    10. [clients]
    11. node[2:4]
    12. [rgws]
    13. node[2:4]
    14. [grafana-server]
    15. node2

    4.  将" ceph-ansible/group_vars/ "下的文件全部备份,修改" ceph-ansible/group_vars/all.yml "配置:

    1. [root@node2 ceph-ansible]# cd group_vars/
    2. [root@node2 group_vars]# egrep -v '#|^$' all.yml
    3. 修改后的内容:
    4. ---
    5. dummy:
    6. mon_group_name: mons
    7. osd_group_name: osds
    8. rgw_group_name: rgws
    9. mds_group_name: mdss
    10. client_group_name: clients
    11. mgr_group_name: mgrs
    12. grafana_server_group_name: grafana-server
    13. configure_firewall: False
    14. ceph_origin: repository
    15. ceph_origin: repository
    16. ceph_repository: community
    17. ceph_mirror: http://mirrors.aliyun.com/ceph
    18. ceph_stable_key: http://mirrors.aliyun.com/ceph/keys/release.asc
    19. ceph_stable_release: nautilus
    20. ceph_stable_repo: "{{ ceph_mirror }}/rpm-{{ ceph_stable_release }}"
    21. public_network: "192.168.188.0/24"
    22. cluster_network: "192.168.188.0/24"
    23. monitor_interface: eth0
    24. osd_auto_discovery: true
    25. osd_objectstore: filestore
    26. radosgw_interface: eth0
    27. dashboard_admin_password: ans123456
    28. grafana_admin_password: admin
    29. pg_autoscale_mode: True

    5.  修改 " ceph-ansible/group_vars/osds.yml "配置:

    1. [root@node2 group_vars]# vim osds.yml
    2. .......
    3. devices:
    4. - /dev/sdb
    5. .......

    6.  先备份" ceph-ansible/site.yml ",再修改" ceph-ansible/site.yml "配置:

    1. [root@node2 ceph-ansible]# vim site.yml
    2. ---
    3. - hosts:
    4. - mons
    5. - osds
    6. - mdss
    7. - rgws
    8. #- nfss
    9. #- rbdmirrors
    10. - clients
    11. - mgrs
    12. #- iscsigws
    13. - grafana-server
    14. ......

    7.  运行" ceph-ansible/site.yml "文件即可:

    [root@node2 ceph-ansible]# ansible-playbook -i /etc/ansible/hosts site.yml

    8.  查看集群健康状态

    1. ## 查看集群健康状态时,可能会出现两个错误
    2. [root@node2 cephy-ansible]# ceph health
    3. HEALTH_WARN 1 pools have too few placement groups; mons are allowing insecure
    4. global_id reclaim
    5. 1、HEALTH_WARN:pools have too many placement groups
    6. 解决方法∶ceph mgr module disable pg_autoscaler
    7. 2、HEALTH_WARN: mons are allowing insecure global_id reclaim
    8. 需要禁用掉不安全的模式,使用如下命令:
    9. ceph config set mon auth_allow_insecure_global_id_reclaim false
    10. [root@node2 cephy-ansible]# ceph health
    11. HEALTH_OK
    12. ## 查看集群配置:
    13. [root@node2 cephy-ansible]# ceph -s

    9.  查看访问ceph的web页面的方式:

    [root@node2 cephy-ansible]# ceph mgr services

  • 相关阅读:
    闭关之 C++ 并发编程笔记(一):线程与锁
    【从零开始学习 SystemVerilog】6.6、SystemVerilog 接口—— Clocking Blocks(下)
    走进上海交大丨用 DolphinDB 开启你的量化交易职业生涯
    goland报错:“package command-line-arguments is not a main package”解决方案
    springboot启动后和停止前执行方法
    138.【JUC并发编程- 03】
    如何确定你访问的网站的真实性——证书体系
    详细了解关于sentinel的实际应用
    深入理解Git
    采购策略中的合同支付类型
  • 原文地址:https://blog.csdn.net/NancyLCL/article/details/126917134