使用kolla部署openstack虚拟机的监控组件collectd influxdb prometheus等时,不知道什么原因,无法收集虚拟机的内存使用信息,只能获取到分配给虚拟机的总内存。
https://blog.csdn.net/dandanfengyun/article/details/114540296
docker exec -it influxdb bash
influx -host 192.168.199.90
> use collectd
Using database collectd
> precision rfc3339
> select * from virt_value where type = 'memory' limit 20 tz('Asia/Shanghai')
name: virt_value
time host instance type type_instance value
---- ---- -------- ---- ------------- -----
2021-04-02T14:47:23.551858532+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:47:23.552356249+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:47:33.54492979+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:47:33.546790044+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:47:43.545691568+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:47:43.54638634+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:47:53.549820556+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:47:53.550247993+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:48:03.544801779+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:48:03.545858786+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:48:13.546268688+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:48:13.546725578+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:48:23.553362081+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:48:23.553795653+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:48:33.547019894+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:48:33.547937342+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:48:43.545029437+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:48:43.546119972+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
2021-04-02T14:48:53.54527576+08:00 ALLInOne-Kolla 15092e1c-b964-4b1e-b8f7-24710a2f2f53 memory total 67108864
2021-04-02T14:48:53.545761462+08:00 ALLInOne-Kolla b910e3c2-7448-4532-ba04-f86cbf7dbf76 memory total 67108864
除了collectd,其余的监控组件依然使用kolla安装部署。
由于collectd本身在kolla部署中就是安装在各个节点收集宿主机信息的组件,原就未通过kolla部署的keepalived和haproxy设置高可用,当前宿主机宕机,当前宿主机的collectd也就无法继续收集信息传送到influxdb。
所以使用yum直接软件安装和使用kolla当作docker容器组件安装区别不大。只用设置collectd服务开机启动即可。
只是使用yum安装时需要在每个openstack关联的宿主机上手动安装collectd软件,并修改配置文件,这点就不如通过kolla部署安装。
即使是手动安装的collectd,比kolla部署安装的collectd容器仅仅多收集了虚拟实例的内存使用信息,所以如果有其他方式收集虚拟实例的内存使用情况,或者不想监听内存实例的使用。。。那么还是别使用yum方式安装collectd监控openstack虚拟机
vim /etc/kolla/globals.yml
enable_grafana: "yes"
enable_influxdb: "yes"
kolla-ansible deploy -i /etc/kolla/all-in-one
安装collectd
yum -y install collectd
这里不像docker容器那样,直接安装了各种插件,使用yum安装时,需要手动安装所用的插件,如virt rrdtool等。可使用yum search collectd命令查看有何collectd种插件
yum search collectd
准备监控虚拟机,所以安装virt插件。
yum -y install collectd-virt
collectd配置文件设置。
virt插件是虚拟机相关,可以设置监听本机的libvirt服务来监控虚拟机信息。
如果不止希望监听虚拟机信息,还想监听宿主机的各种信息,collectd还可以加载cpu,interface等默认安装的插件。
然后通过network插件将收集到的信息发送到influxdb中,有多个influxdb服务时,network的需设置多个server保证influxdb数据库数据一致。
mv /etc/collectd.conf /etc/collectd.conf.bak
vim /etc/collectd.conf
FQDNLookup false
LoadPlugin syslog
LoadPlugin cpu
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin network
LoadPlugin logfile
LoadPlugin virt
# 数据发送,到192.168.199.90 的25826端口,也就是influxdb收集collectd数据的端口
# 多个influxdb服务 Server可以设置多个
<Plugin network>
Server "192.168.199.90" "25826"
</Plugin>
<Plugin logfile>
LogLevel info
File "/var/log/kolla/collectd/collectd.log"
Timestamp true
PrintSeverity false
</Plugin>
# 虚拟机监控插件,监控本机的libvirtd
<Plugin virt>
Connection "qemu+tcp://192.168.199.90/system"
HostnameFormat hostname
PluginInstanceFormat uuid
BlockDeviceFormat target
InterfaceFormat name
ExtraStats "cpu_util"
</Plugin>
systemctl enable collectd
systemctl restart collectd
日志文件 /var/log/kolla/collectd/collectd.log
influxdb 配置文件设置。
添加collectd段设置,使influxdb接收collectd发来的数据。
mkdir /etc/kolla/config
cp /etc/kolla/influxdb/influxdb.conf /etc/kolla/config/
vim /etc/kolla/config/influxdb.conf
复制types.db文件到influxdb容器的docker卷中。
cp /usr/share/collectd/types.db /var/lib/docker/volumes/influxdb/_data/
[root@ALLInOne-Kolla ~]# cp /usr/share/collectd/types.db /var/lib/docker/volumes/influxdb/_data/
[root@ALLInOne-Kolla ~]# ls /var/lib/docker/volumes/influxdb/_data/
data meta types.db wal
注,如果是通过kolla部署安装的collectd,那么宿主机中是没有/usr/share/collectd/types.db 文件的,需要从collectd容器中导出该文件不过这里并不是使用的collectd容器。
docker exec collectd cat /usr/share/collectd/type.db > /var/lib/docker/volumes/influxdb/_data/type.db
reporting-disabled = true
[logging]
level = "info"
file = "/var/log/kolla/influxdb/influxdb.log"
[meta]
dir = "/var/lib/influxdb/meta"
retention-autocreate = true
logging-enabled = true
[data]
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
wal-logging-enabled = true
data-logging-enabled = true
index-version = "tsi1"
[coordinator]
write-timeout = "10s"
max-concurrent-queries = 0
query-timeout = "0s"
max-select-point = 0
max-select-series = 0
max-select-buckets = 0
[retention]
enabled = true
check-interval = "30m"
[shard-precreation]
enabled = true
check-interval = "10m"
advance-period = "30m"
[monitor]
store-enabled = true
store-database = "_internal"
store-interval = "10s"
[http]
enabled = true
bind-address = "192.168.199.90:8086"
auth-enabled = false
log-enabled = true
write-tracing = false
pprof-enabled = false
https-enabled = false
[[graphite]]
enabled = false
[[opentsdb]]
enabled = false
[[udp]]
enabled = false
[continuous_queries]
log-enabled = true
enabled = true
# 只添加该段。用来收集collectd发送的数据。
[[collectd]]
enabled = true
bind-address = "192.168.199.90:25826"
database = "collectd"
typesdb = "/var/lib/influxdb/types.db"
grafana配置文件设置
此时不需要修改什么设置。
kolla加载新配置
kolla-ansible deploy -i /etc/kolla/all-in-one
查看 influxdb中数据。
查看库
curl -G 'http://192.168.199.90:8086/query?q=SHOW+DATABASES'
查看measurements
curl -G 'http://192.168.199.90:8086/query' --data-urlencode "db=collectd" --data-urlencode 'q=show measurements'
查看某一表具体数据
curl -G 'http://192.168.199.90:8086/query' --data-urlencode "db=collectd" --data-urlencode 'q=select * from virt_value limit 10'
进入influxdb容器查看更方便。
docker exec -it influxdb bash
influx -host 192.168.199.90
> use collectd
Using database collectd
> precision rfc3339
> select * from virt_value where type = 'memory' limit 20 tz('Asia/Shanghai')
name: virt_value
time host instance type type_instance value
---- ---- -------- ---- ------------- -----
2021-04-13T16:59:21.147698504+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory total 536870912
2021-04-13T16:59:21.189902706+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory actual_balloon 536870912
2021-04-13T16:59:21.189955452+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory last_update 0
2021-04-13T16:59:21.189976288+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory rss 362242048
2021-04-13T16:59:31.03053087+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory total 536870912
2021-04-13T16:59:31.304921996+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory actual_balloon 536870912
2021-04-13T16:59:31.304996146+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory last_update 0
2021-04-13T16:59:31.305016164+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory rss 366247936
2021-04-13T16:59:41.006997735+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory total 536870912
2021-04-13T16:59:41.014379052+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory actual_balloon 536870912
2021-04-13T16:59:41.014450803+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory last_update 0
2021-04-13T16:59:41.014496388+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory rss 375971840
2021-04-13T16:59:51.005750326+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory total 536870912
2021-04-13T16:59:51.014321392+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory actual_balloon 536870912
2021-04-13T16:59:51.014332929+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory last_update 0
2021-04-13T16:59:51.014341664+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory rss 376197120
2021-04-13T17:00:01.052461894+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory total 536870912
2021-04-13T17:00:01.073020079+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory actual_balloon 536870912
2021-04-13T17:00:01.073031135+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory last_update 0
2021-04-13T17:00:01.073038953+08:00 ALLInOne-Kolla 6785f139-c9aa-4317-a8ef-73b4e27ad998 memory rss 385085440
grafana 的Panel设置和之前的没什么区别。。。
不过好像 collectd收集的虚拟机内存使用信息也没多大用。。。
各个参数具体意义也不明
有用的可能就是total和usable 两项了吧
total表示分配给虚拟实例的总内存。未内存超配的情况下等于actual_balloon
usable表示虚拟实例现在可用内存。相当于 虚拟实例内free -h 查看的available。