黑帽联盟

 找回密码
 会员注册
查看: 1232|回复: 0
打印 上一主题 下一主题

[集群服务] Openstack高可用之基础环境配置

[复制链接]
yun 黑帽联盟官方人员 

920

主题

37

听众

1364

积分

超级版主

Rank: 8Rank: 8

  • TA的每日心情
    奋斗
    2019-10-18 11:20
  • 签到天数: 678 天

    [LV.9]以坛为家II

    一、操作系统配置
    1.1、准备:
    两个节点ha-node1和ha-node2均按照centos7.0系统
    1. 192.168.8.51 ha-node1
    2. 192.168.8.52 ha-node2
    复制代码
    修改主机名:
    节点1
    1. # hostnamectl set-hostname ha-node1
    2. # su -l
    复制代码
    节点2
    1. # hostnamectl set-hostname ha-node2
    2. # su -l
    复制代码
    1.2、关闭防火墙(每个节点都需执行)
    1. # setenforce 0
    2. # sed -i.bak "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
    3. # systemctl disable firewalld.service
    4. # systemctl stop firewalld.service
    复制代码
    1.3、配置hosts文件
    1. echo '192.168.8.51 ha-node1 ' >>/etc/hosts
    2. echo '192.168.8.52 ha-node2 ' >>/etc/hosts
    复制代码
    1.4、配置ntp(10.139.41.128为ntp服务器)每个节点都需执行
    1. # chkconfig chronyd off
    2. # chkconfig ntpd on
    3. # sed -i "/^server\ 3.centos.pool/a server\ 10.239.41.128 " /etc/ntp.conf
    4. # service ntpd start
    5. # ntpq -p
    复制代码
    二、安装集群软件
    2.1、安装相关软件包
    1. # yum install -y pacemaker pcs psmisc policycoreutils-python
    复制代码
    启动pcs服务并保持开机启动
    1. # systemctl start pcsd.service
    2. # systemctl enable pcsd.service
    复制代码
    2.2修改用户hacluster的密码
    1. # ssh ha-node2 'echo redhat1 | passwd --stdin hacluster'
    2. # echo redhat1 | passwd --stdin hacluster
    复制代码
    注意:redhat1为hacluster用户密码


    三、启动集群软件
    3.1、认证各个节点,并创建集群(注意如果有代理记得取消)
    1. # pcs cluster auth ha-node1 ha-node2
    2. # pcs cluster setup --name mycluster ha-node1 ha-node2
    复制代码
    3.2、启动集群
    1. [root@ha-node1 ~]# pcs cluster start --all
    2. ha-node1: Starting Cluster...
    3. ha-node2: Starting Cluster...
    复制代码
    3.3、验证corosync的安装
    1. [root@ha-node1 ~]# corosync-cfgtool -s
    2. Printing ring status.
    3. Local node ID 1
    4. RING ID 0
    5. id = 192.168.8.51
    6. status = ring 0 active with no faults
    复制代码
    3.4、查看接入成员
    1. #corosync-cmapctl | grep members
    2. runtime.totem.pg.mrp.srp.members.1.config_version (u64) = 0
    3. runtime.totem.pg.mrp.srp.members.1.ip (str) = r(0) ip(192.168.8.51)
    4. runtime.totem.pg.mrp.srp.members.1.join_count (u32) = 1
    5. runtime.totem.pg.mrp.srp.members.1.status (str) = joined
    6. runtime.totem.pg.mrp.srp.members.2.config_version (u64) = 0
    7. runtime.totem.pg.mrp.srp.members.2.ip (str) = r(0) ip(192.168.8.52)
    8. runtime.totem.pg.mrp.srp.members.2.join_count (u32) = 2
    9. runtime.totem.pg.mrp.srp.members.2.status (str) = joined
    复制代码
    3.5、corosync状态
    1. # pcs status corosync
    2. Membership information
    3. --------------------------
    4. Nodeid Votes Name
    5. 1 1 ha-node1(local)
    6. 2 1 ha-node2
    复制代码
    3.6、检查pacemaker的安装
    1. # ps axf
    2. PID TTY STAT TIME COMMAND
    3. 2 ? S 0:00 [kthreadd]
    4. ...lots of processes...
    5. 1362 ? Ssl 0:35 corosync
    6. 1379 ? Ss 0:00 /usr/sbin/pacemakerd -f
    7. 1380 ? Ss 0:00 \_ /usr/libexec/pacemaker/cib
    8. 1381 ? Ss 0:00 \_ /usr/libexec/pacemaker/stonithd
    9. 1382 ? Ss 0:00 \_ /usr/libexec/pacemaker/lrmd
    10. 1383 ? Ss 0:00 \_ /usr/libexec/pacemaker/attrd
    11. 1384 ? Ss 0:00 \_ /usr/libexec/pacemaker/pengine
    12. 1385 ? Ss 0:00 \_ /usr/libexec/pacemaker/crmd
    复制代码
    3.7、检查pcs status
    1. [root@ha-node1 ~]# pcs status
    2. Cluster name: mycluster
    3. WARNING: no stonith devices and stonith-enabled is not false
    4. Last updated: Tue Dec 16 16:15:29 2014
    5. Last change: Tue Dec 16 15:49:47 2014
    6. Stack: corosync
    7. Current DC: ha-node2 (2) - partition with quorum
    8. Version: 1.1.12-a14efad
    9. 2 Nodes configured
    10. 0 Resources configured
    11. Online: [ ha-node1 ha-node2 ]
    12. Full list of resources:
    13. PCSD Status:
    14. ha-node1: Online
    15. ha-node2: Online
    16. Daemon Status:
    17. corosync: active/disabled
    18. pacemaker: active/disabled
    19. pcsd: active/enabled
    复制代码
    3.8、查看系统中error(stonith除外)
    1. # journalctl | grep -i error
    复制代码
    四、配置集群(任选一个节点)
    4.1集群属性
    投票属性
    1. # pcs property set no-quorum-policy=ignore
    复制代码
    集群故障时候服务迁移
    1. # pcs resource defaults migration-threshold=1
    复制代码
    由于两个节点无stonith设备
    1. # pcs property set stonith-enabled=false
    复制代码
    在node1恢复后,为防止node2资源迁回node01(迁来迁去对还是会对业务有一定影响)
    1. # pcs resource defaults resource-stickiness=100
    2. # pcs resource defaults
    复制代码
    设置资源超时时间
    1. # pcs resource op defaults timeout=90s
    2. # pcs resource op defaults
    3. # pcs property set pe-warn-series-max=1000 \
    4.   pe-input-series-max=1000 \
    5.   pe-error-series-max=1000 \
    6.   cluster-recheck-interval=5min
    复制代码
    验证,正常无回显
    1. # crm_verify -L -V
    复制代码
    4.2配置浮动IP
    1. # pcs resource create vip ocf:heartbeat:IPaddr2 ip=192.168.8.53 cidr_netmask=24 op monitor interval=30s
    复制代码
    vip为自定义的一个集群IP的名称,监控时间为30S。


    五、群集操作命令
    5.1、验证群集安装
    1. # pacemakerd -F ## 查看pacemaker组件,ps axf | grep pacemaker
    2. # corosync-cfgtool -s ## 查看corosync序号
    3. # corosync-cmapctl | grep members ## corosync 2.3.x
    4. # corosync-objctl | grep members ## corosync 1.4.x
    复制代码
    5.2、查看群集资源
    1. # pcs resource standards ## 查看支持资源类型
    2. # pcs resource providers ## 查看资源提供商
    3. # pcs resource agents ## 查看所有资源代理
    4. # pcs resource list ## 查看支持资源列表
    5. # pcs stonith list ## 查看支持Fence列表
    6. # pcs property list --all ## 显示群集默认变量参数
    7. # crm_simulate -sL ## 检验资源 score 值
    复制代码
    5.3、使用群集脚本
    1. # pcs cluster cib ra_cfg ## 将群集资源配置信息保存在指定文件
    2. # pcs -f ra_cfg resource create ## 创建群集资源并保存在指定文件中(而非保存在运行配置)
    3. # pcs -f ra_cfg resource show ## 显示指定文件的配置信息,检查无误后
    4. # pcs cluster cib-push ra_cfg ## 将指定配置文件加载到运行配置中
    复制代码
    5.4、STONITH 设备操作
    1. # stonith_admin -I ## 查询fence设备
    2. # stonith_admin -M -a agent_name ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap
    3. # stonith_admin --reboot nodename ## 测试 STONITH 设备
    复制代码
    5.5、查看群集配置
    1. # crm_verify -L -V ## 检查配置有无错误
    2. # pcs property ## 查看群集属性
    3. # pcs stonith ## 查看stonith
    4. # pcs constraint ## 查看资源约束
    5. # pcs config ## 查看群集资源配置
    6. # pcs cluster cib ## 以XML格式显示群集配置
    复制代码
    5.6、管理群集
    1. # pcs status ## 查看群集状态
    2. # pcs status cluster
    3. # pcs status corosync
    4. # pcs cluster stop [node11] ## 停止群集
    5. # pcs cluster start --all ## 启动群集
    6. # pcs cluster standby node11 ## 将节点置为后备standby状态,pcs cluster unstandby node11
    7. # pcs cluster destroy [--all] ## 删除群集,[--all]同时恢复corosync.conf文件
    8. # pcs resource cleanup ClusterIP ## 清除指定资源的状态与错误计数
    9. # pcs stonith cleanup vmware-fencing ## 清除Fence资源的状态与错误计数
    复制代码
    帖子永久地址: 

    黑帽联盟 - 论坛版权1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
    2、本站所有主题由该帖子作者发表,该帖子作者与黑帽联盟享有帖子相关版权
    3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和黑帽联盟的同意
    4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
    5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
    6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
    7、黑帽联盟管理员和版主有权不事先通知发贴者而删除本文

    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部