设为首页 收藏本站
查看: 881|回复: 0

[经验分享] openstack运维实战系列(四)之删除computes节点

[复制链接]

尚未签到

发表于 2018-6-1 11:06:46 | 显示全部楼层 |阅读模式

  •   前言
  因为虚拟机业务的撤销,compute上面的instance越来越少,随着虚拟机的迁移和下线,compute节点可能处于资源空闲的状态,为了进一步利用系统资源,节约成本,需要将空闲的计算节点从openstack中删除。在删除compute节点之前,首先需要确保该计算节点上没有业务,可以通过virsh list --all查看是否还有虚拟机业务,同时保守起见,建议将compute节点的服务关闭关闭,通过service openstack-nova-compute stop && chkconfig openstack-nova-compute off。
  2. 删除nova计算节点
  openstack建议在删除nova节点的时候,建议通过操作nova.instances中的deleted字段来实现,而不是直接将compute节点的条目从数据库中删除,一来是为了安全考虑,而是能够实现快速的回滚操作,具体的操作如下:


  •   校验nova-compute的状态
[root@controller ~]# nova service-list
+------------------+-----------------------+---------------+---------+-------+----------------------------+-----------------+
| Binary           | Host                  | Zone          | Status  | State | Updated_at                 | Disabled Reason |
+------------------+-----------------------+---------------+---------+-------+----------------------------+-----------------+
| nova-scheduler   | controller            | internal      | enabled | up    | 2016-01-20T04:12:33.000000 | -               |
| nova-cert        | controller            | internal      | enabled | up    | 2016-01-20T04:12:31.000000 | -               |
| nova-conductor   | controller            | internal      | enabled | up    | 2016-01-20T04:12:27.000000 | -               |
| nova-consoleauth | controller            | internal      | enabled | up    | 2016-01-20T04:12:33.000000 | -               |
| nova-compute     | YiZhuang_10_1_112_105 | YiZhuangZone2 | enabled | down  | 2016-01-16T09:11:57.000000 | -               |    #已经处于down的状态
| nova-compute     | YiZhuang_10_1_112_106 | YiZhuangZone2 | enabled | up    | 2016-01-20T04:12:24.000000 | -               |  2. 删除compute service节点
mysql> select * from nova.services where host='YiZhuang_10_1_112_105';  
+---------------------+---------------------+------------+----+-----------------------+--------------+---------+--------------+----------+---------+-----------------+
| created_at          | updated_at          | deleted_at | id | host                  | binary       | topic   | report_count | disabled | deleted | disabled_reason |
+---------------------+---------------------+------------+----+-----------------------+--------------+---------+--------------+----------+---------+-----------------+
| 2015-09-21 03:21:40 | 2016-01-16 09:11:57 | NULL       | 37 | YiZhuang_10_1_112_105 | nova-compute | compute |      1011705 |        0 |       0 | NULL            |
+---------------------+---------------------+------------+----+-----------------------+--------------+---------+--------------+----------+---------+-----------------+
1 row in set (0.00 sec)
mysql> update nova.services set deleted=1 where host='YiZhuang_10_1_112_105';             #设置deleted字段,即标志位            
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> select * from nova.services where host='YiZhuang_10_1_112_105';                   #检查deleted字段设置情况
+---------------------+---------------------+------------+----+-----------------------+--------------+---------+--------------+----------+---------+-----------------+
| created_at          | updated_at          | deleted_at | id | host                  | binary       | topic   | report_count | disabled | deleted | disabled_reason |
+---------------------+---------------------+------------+----+-----------------------+--------------+---------+--------------+----------+---------+-----------------+
| 2015-09-21 03:21:40 | 2016-01-16 09:11:57 | NULL       | 37 | YiZhuang_10_1_112_105 | nova-compute | compute |      1011705 |        0 |       1 | NULL            |   
+---------------------+---------------------+------------+----+-----------------------+--------------+---------+--------------+----------+---------+-----------------+
1 row in set (0.00 sec)  3. 确认节点的service状态
[root@controller ~]# nova service-list
+------------------+-----------------------+---------------+---------+-------+----------------------------+-----------------+
| Binary           | Host                  | Zone          | Status  | State | Updated_at                 | Disabled Reason |
+------------------+-----------------------+---------------+---------+-------+----------------------------+-----------------+
| nova-scheduler   | controller            | internal      | enabled | up    | 2016-01-20T04:12:33.000000 | -               |
| nova-cert        | controller            | internal      | enabled | up    | 2016-01-20T04:12:31.000000 | -               |
| nova-conductor   | controller            | internal      | enabled | up    | 2016-01-20T04:12:27.000000 | -               |
| nova-consoleauth | controller            | internal      | enabled | up    | 2016-01-20T04:12:33.000000 | -               |
| nova-compute     | YiZhuang_10_1_112_106 | YiZhuangZone2 | enabled | up    | 2016-01-20T04:12:24.000000 | -               |    #service已经删除  4. 查看hypervisor情况
[root@controller ~]# nova hypervisor-list
+----+-----------------------+
| ID | Hypervisor hostname   |
+----+-----------------------+
| 25 | YiZhuang_10_1_112_105 |          #services已经删除,但hypervisor依旧在,类似的方法,将nova.compute_nodes中的deleted字段修改,查看步骤5   
| 27 | YiZhuang_10_1_112_106 |  5. 删除compute_nodes节点
mysql> update nova.compute_nodes set deleted=1 where hypervisor_hostname='YiZhuang_10_1_112_105'\G;       #设置deleted标志位           
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> select * from nova.compute_nodes where hypervisor_hostname='YiZhuang_10_1_112_105'\G;               #确认设置情况   
*************************** 1. row ***************************
          created_at: 2015-09-21 03:21:40
          updated_at: 2016-01-16 09:11:36
          deleted_at: NULL
                  id: 25
          service_id: 37
               vcpus: 24
           memory_mb: 64396
            local_gb: 3062
          vcpus_used: 0
      memory_mb_used: 1024
       local_gb_used: 20
     hypervisor_type: QEMU
  hypervisor_version: 12001
            cpu_info: {"vendor": "Intel", "model": "SandyBridge", "arch": "x86_64", "features": ["vme", "dtes64", "vmx", "erms", "xtpr", "smep", "pcid", "est", "monitor", "smx", "tm", "acpi", "osxsave", "ht", "dca", "pdcm", "pdpe1gb", "fsgsbase", "f16c", "ds", "tm2", "ss", "pbe", "ds_cpl", "rdrand"], "topology": {"cores": 6, "threads": 2, "sockets": 1}}
disk_available_least: 2671
         free_ram_mb: 63372
        free_disk_gb: 3042
    current_workload: 0
         running_vms: 0
hypervisor_hostname: YiZhuang_10_1_112_105
             deleted: 1                        #设置成功
             host_ip: 0.0.0.0
supported_instances: [["i686", "qemu", "hvm"], ["i686", "kvm", "hvm"], ["x86_64", "qemu", "hvm"], ["x86_64", "kvm", "hvm"]]
           pci_stats: []
             metrics: []
     extra_resources: NULL
               stats: {"num_task_None": 2, "io_workload": 0, "num_instances": 2, "num_vm_stopped": 2, "num_proj_a49b16d5324a4d20bde2217b17200485": 2, "num_vcpus_used": 8, "num_os_type_None": 2}
1 row in set (0.00 sec)  6. 确认hypervisor node是否删除
[root@controller ~]# nova hypervisor-list        #YiZhuang_10_1_112_105已被删除
+----+-----------------------+
| ID | Hypervisor hostname   |
+----+-----------------------+  
| 27 | YiZhuang_10_1_112_106 |  3. 删除neutron agent服务
  以上将nova的service和hypervisor从数据库中删除,但是compute节点在安装过程中,neutron-openvswitch-agent会建立一个OVS的agent,该agent也记录在数据库中,通过neutron agent-list可以查看到agent的情况,当compute node删除之后,neutron也应该删除,方法和上面相类似,具体如下:


  •   确认agent的情况
[root@controller ~]# neutron agent-list
+--------------------------------------+--------------------+-----------------------+-------+----------------+
| id                                   | agent_type         | host                  | alive | admin_state_up |
+--------------------------------------+--------------------+-----------------------+-------+----------------+
| 0160e0b7-22fb-42d9-8e43-0d13d98db594 | L3 agent           | LuGu_10_1_81_209      | :-)   | True           |
| 4e1c9957-98e5-4516-af2d-6c67a00ecd77 | Open vSwitch agent | YiZhuang_10_1_112_105 | xxx   | True           |    #计算节点已经关闭,所以agent状态变为xxx,即不可用,:-)可用
| 6a9e2647-6eed-459d-8f60-e9ea40ae04df | Open vSwitch agent | YiZhuang_10_1_112_106 | :-)   | True           |  2. 删除OVS agent
mysql> select * from neutron.agents where host='YiZhuang_10_1_112_105'\G;        #没有deleted标志位,所以只能从数据库中删除
*************************** 1. row ***************************
                 id: 4e1c9957-98e5-4516-af2d-6c67a00ecd77
         agent_type: Open vSwitch agent
             binary: neutron-openvswitch-agent
              topic: N/A
               host: YiZhuang_10_1_112_105
     admin_state_up: 1
         created_at: 2015-09-21 03:22:01
         started_at: 2016-01-19 09:15:45
heartbeat_timestamp: 2016-01-19 09:15:45
        description: NULL
     configurations: {"tunnel_types": [], "tunneling_ip": "", "bridge_mappings": {"physnet1": "br-eth1", "physnet0": "br-eth0"}, "l2_population": false, "devices": 0}
1 row in set (0.00 sec)

mysql> delete from neutron.agents where host='YiZhuang_10_1_112_105'\G;         #删除         
Query OK, 1 row affected (0.00 sec)
校验:
[root@controller ~]# neutron agent-list
+--------------------------------------+--------------------+-----------------------+-------+----------------+
| id                                   | agent_type         | host                  | alive | admin_state_up |
+--------------------------------------+--------------------+-----------------------+-------+----------------+
| 0160e0b7-22fb-42d9-8e43-0d13d98db594 | L3 agent           | LuGu_10_1_81_209      | :-)   | True           |
| 6a9e2647-6eed-459d-8f60-e9ea40ae04df | Open vSwitch agent | YiZhuang_10_1_112_106 | :-)   | True           |  4. 总结
  以上是将compute_nodes从opentack中删除的方法,在Juno以上的版本,可以通过nova service-delete <hostname> 的方式将compute nodes删除,在Icehouse以下的版本,暂时未能提供,解决的方法可以通过调用nova db的api,将其删除,后续再补充。或者通过编写的脚本的方式,也可以实现,建议通过调用API的方式,直接修改数据库,而不建议直接修改数据库的方法。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-498195-1-1.html 上篇帖子: openstack运维实战系列(三)之cinder磁盘挂载 下篇帖子: openstack运维实战系列(五)之nova quota调整
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表