1. 程式人生 > >openstack內存占用清理

openstack內存占用清理

openstack 內存清理


公司使用openstack定制開發了雲桌面平臺提供給客戶使用,架構是3臺控制節點+N臺計算節點+N臺CEPH+cinder。使用一直較為穩定,今天部份客戶反映雙擊雲主機圖標無法進入雲桌面、或者需要多次點擊方可進入雲桌面。經過檢查是因為2臺控制節點內存占用過高導致,需要清理。下面是詳細操作過程。

1、查看控制節點內存占用

[[email protected] ~]# top
top - 15:29:40 up 18 days, 17:15,  1 user,  load average: 1.27, 1.83, 2.09
Tasks: 1062 total,   6 running, 1056 sleeping,   0 stopped,   0 zombie
Cpu(s): 12.2%us,  1.1%sy,  0.0%ni, 86.4%id,  0.1%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:  99032136k total, 97932848k used,  1099288k free,   233100k buffers
Swap: 33554428k total,   295916k used, 33258512k free, 38017888k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                        2926 rabbitmq  20   0 2904m 449m 2676 S 97.4  0.5   0:12.85 beam.smp                     1868 root      10 -10 44932  11m 7240 S 15.0  0.0   2149:53 ovs-vswitchd                 7982 mysql     -2   0 24.8g 2.8g 138m S  9.4  3.0   4617:11 mysqld                        ......

"Mem: 99032136k total, 97932848k used",可以看到 控制節點內存已用滿


控制節點查看nova服務狀態:

[[email protected] ~]# nova-manage service list
Binary           Host                                 Zone             Status     State Updated_At
nova-consoleauth node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:39
nova-scheduler   node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:40
nova-conductor   node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:49
nova-cert        node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:47
nova-consoleauth node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:43
nova-scheduler   node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:48
nova-conductor   node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:48
nova-consoleauth node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:39
nova-scheduler   node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:42
nova-conductor   node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:48
nova-cert        node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:41
nova-cert        node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:26:39
nova-compute     node-4.domain.tld                    nova             disabled   :-)   2017-05-04 07:26:40
nova-compute     node-10.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:47
nova-compute     node-15.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:44
nova-compute     node-16.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:45
nova-compute     node-11.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:41
nova-compute     node-17.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:39
nova-compute     node-5.domain.tld                    nova             enabled    :-)   2017-05-04 07:26:46
nova-compute     node-9.domain.tld                    nova             enabled    :-)   2017-05-04 07:26:41
nova-compute     node-13.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:42
nova-compute     node-14.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:46
nova-compute     node-12.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:41
nova-compute     node-26.domain.tld                   nova             enabled    :-)   2017-05-04 07:26:48


在控制節點查看了內存占用及nova服務狀態控制。node-4 libvirtd服務disabled,一般在該計算節點用“/etc/init.d/libvirtd restart”重啟即可。雖然linux有內存管理機制,但目前服務器內存用滿不會自動下降,卻容易導致各節點通訊失敗。導致用戶“雙擊雲主機圖標無法進入雲桌面”,只能人工介入處理清理內存。


當前的處理過程是 清理控制節點內存-->重啟控制節點rabbitmy-server服務--> 重啟各計算節點nova-compute服務。當然清理內存也有風險,可能導致在用用戶雲主機斷開影響操作體驗。


2、第一臺控制節點清理內存,重啟rabbitmy-server服務

[[email protected] ~]# sync
[[email protected] ~]# echo 3 > /proc/sys/vm/drop_caches
[[email protected] ~]# top
top - 15:30:47 up 18 days, 17:16,  1 user,  load average: 1.29, 1.73, 2.04
Tasks: 1063 total,   4 running, 1059 sleeping,   0 stopped,   0 zombie
Cpu(s): 12.2%us,  1.1%sy,  0.0%ni, 86.4%id,  0.1%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:  99032136k total, 59740848k used, 39291288k free,     9576k buffers
Swap: 33554428k total,   295916k used, 33258512k free,   214468k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                         2926 rabbitmq  20   0 3222m 735m 2676 S 35.4  0.8   0:19.17 beam.smp                     
 8392 keystone  20   0  423m  66m 3524 S 20.5  0.1  15:43.19 keystone-all             
 1868 root      10 -10 44932  11m 7240 S 14.9  0.0   2150:02 ovs-vswitchd             
 7982 mysql     -2   0 24.8g 2.8g 138m S  9.3  3.0   4617:44 mysqld                           ......                                                                                                                    
 [[email protected] ~]# /etc/init.d/rabbitmq-server restart
Restarting rabbitmq-server: FAILED - check /var/log/rabbitmq/shutdown_log, _err
RabbitMQ is going to make 3 attempts to find master node and start.
3 attempts left to start RabbitMQ Server before consider start failed.
SUCCESS
Setting policy "ha-all" for pattern "." to "{\"ha-mode\":\"all\", \"ha-sync-mode\":\"automatic\"}" with priority "0" ...
...done.
rabbitmq-server.
 
 [[email protected] ~]# ssh node-7
Warning: Permanently added ‘node-7,192.168.10.6‘ (RSA) to the list of known hosts.
Last login: Tue May  2 09:40:05 2017 from 192.168.10.4


3、第二臺控制節點清理內存:

[[email protected] ~]# top
top - 15:30:53 up 44 days, 6 min,  1 user,  load average: 1.33, 1.44, 1.63
Tasks: 1081 total,   5 running, 1076 sleeping,   0 stopped,   0 zombie
Cpu(s): 11.3%us,  1.0%sy,  0.0%ni, 87.5%id,  0.1%wa,  0.0%hi,  0.1%si,  0.0%st
Mem:  99032136k total, 98589812k used,   442324k free,   273588k buffers
Swap: 33554428k total,   141844k used, 33412584k free, 35998936k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                       
12728 neutron   20   0  549m 216m 2016 S 37.7  0.2  15:41.11 neutron-server              26690 keystone  20   0  327m  66m 3428 R 24.5  0.1  13:40.80 keystone-all            
26698 keystone  20   0  327m  67m 3428 S 16.9  0.1  12:57.10 keystone-all         
19852 nova      20   0  555m 197m 3332 S 15.1  0.2 502:36.04 nova-api                    
1936 root      10 -10 47608  14m 7220 S  9.4  0.0   3790:59 ovs-vswitchd                                                                                                          [[email protected] ~]# sync  
[[email protected] ~]# echo 3 > /proc/sys/vm/drop_caches
[[email protected] ~]# /etc/init.d/rabbitmq-server restart
Restarting rabbitmq-server: rmdir: failed to remove `/var/run/rabbitmq‘: Directory not empty
RabbitMQ is going to make 3 attempts to find master node and start.
3 attempts left to start RabbitMQ Server before consider start failed.
SUCCESS
Setting policy "ha-all" for pattern "." to "{\"ha-mode\":\"all\", \"ha-sync-mode\":\"automatic\"}" with priority "0" ...
...done.
rabbitmq-server.


4、重啟計算節點的nova-compute服務。

[[email protected] ~]# ssh node-4
Warning: Permanently added ‘node-4,192.168.10.2‘ (RSA) to the list of known hosts.
Last login: Thu May  4 15:31:29 2017 from 192.168.10.6
[[email protected] ~]# /etc/init.d/libvirtd restart
Stopping libvirtd daemon:                                  [FAILED]
Starting libvirtd daemon:                                  [  OK  ]
[[email protected] ~]# /etc/init.d/openstack-nova-compute restart
Stopping openstack-nova-compute:                           [FAILED]
Starting openstack-nova-compute:                           [  OK  ]
[[email protected] ~]# exit
logout
Connection to node-4 closed.


5、在控制節點上查看各節點nova服務狀態

[root@
Binary           Host                                 Zone             Status     State Updated_At
nova-consoleauth node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:09
nova-scheduler   node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:10
nova-conductor   node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:16
nova-cert        node-6.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:07
nova-consoleauth node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:13
nova-scheduler   node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:08
nova-conductor   node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:16
nova-consoleauth node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:09
nova-scheduler   node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:12
nova-conductor   node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:16
nova-cert        node-7.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:11
nova-cert        node-8.domain.tld                    internal         enabled    :-)   2017-05-04 07:32:09
nova-compute     node-4.domain.tld                    nova             enabled    :-)   2017-05-04 07:32:05
nova-compute     node-10.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:07
nova-compute     node-15.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:06
nova-compute     node-16.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:10
nova-compute     node-11.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:12
nova-compute     node-17.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:14
nova-compute     node-5.domain.tld                    nova             enabled    :-)   2017-05-04 07:32:16
nova-compute     node-9.domain.tld                    nova             enabled    :-)   2017-05-04 07:32:11
nova-compute     node-13.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:12
nova-compute     node-14.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:13
nova-compute     node-12.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:15
nova-compute     node-26.domain.tld                   nova             enabled    :-)   2017-05-04 07:32:11

6、各節點nova服務已正常。一般來說,重啟了控制的rabbitmq-server,也可以重啟各計算的nova-compute服務,以重新建立連接(根據實際情況判斷是否需要)。


計算節點node-5重啟libvirtd及openstack-nova-compute服務

[[email protected] ~]# ssh node-5
Warning: Permanently added ‘node-5,192.168.10.3‘ (RSA) to the list of known hosts.
Last login: Sat Apr 22 10:37:43 2017 from 192.168.10.4
[[email protected] ~]# /etc/init.d/libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]
[[email protected] ~]# /etc/init.d/open
openstack-nova-compute  openvswitch             
[[email protected] ~]# /etc/init.d/openstack-nova-compute restart
Stopping openstack-nova-compute:                           [  OK  ]
Starting openstack-nova-compute:                           [  OK  ]

計算節點node-9重啟libvirtd及openstack-nova-compute服務

[[email protected] ~]# /etc/init.d/libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]
[[email protected] ~]# /etc/init.d/openstack-nova-compute restart
Stopping openstack-nova-compute:                           [  OK  ]
Starting openstack-nova-compute:                           [  OK  ]

計算節點node-10重啟libvirtd及openstack-nova-compute服務

[[email protected] ~]# ssh node-10
Warning: Permanently added ‘node-10,192.168.10.9‘ (RSA) to the list of known hosts.
Last login: Tue Apr 25 16:30:26 2017 from 192.168.10.6
[[email protected] ~]# /etc/init.d/libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]
[[email protected] ~]# /etc/init.d/openstack-nova-compute restart
Stopping openstack-nova-compute:                           [  OK  ]
Starting openstack-nova-compute:                           [  OK  ]

......重復操作。


本文出自 “福州恒達電腦” 博客,請務必保留此出處http://fzhddn.blog.51cto.com/12650899/1922090

openstack內存占用清理