安装grafana
官方教程 https://grafana.com/tutorials/install-grafana-on-raspberry-pi/
1.安装APT key
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
2. add apt grafana repo
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
3.更新apt列表
sudo apt-get update
4. 检查grafana版本
sudo apt-cache madison grafana
5.下载安装想要的版本
sudo apt-get install -y grafana=[specific version]
6.开机同步启动 grafana server
sudo /bin/systemctl enable grafana-server
7.即刻启动grafana server
sudo /bin/systemctl start grafana-server
8. 上 http://[ip]:3000进入grafana ui,初始密码为admin/admin
类似的方法安装influxDB
wget -q -O -
https://repos.influxdata.com/influxdb.key | sudo apt-key add -//
需要根据os版本来确定下载的influx版本echo "deb https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update sudo apt-get install influxdb sudo systemctl enable influxdb sudo systemctl start influxdb
安装好influxDB后修改配置,包括取消influxData的telementry, enable http等。
sudo nano -c /etc/influxdb/influxdb.conf
然后通过influx命令进入服务器创建用户,数据库及数据库的数据保存设置
pi@raspberrypi:/etc/influxdb $ influx Connected to http://localhost:8086 version 1.8.0 InfluxDB shell version: 1.8.0 > create database telegraf > use telegraf Using database telegraf > create user [username] with password '[passpord]' with all privileges > grant all privileges on telegraf to telegrafuser > create retention policy "4Weeks" on "telegraf" duration 4w replication 1 default > exit
类似的方法安装telegraf
因为telegraf也是influx data出品的,apt path是和influxdb通用的,所以直接安装就好
sudo apt-get install telegraf sudo systemctl enable telegraf sudo systemctl start telegraf
然后修改telegraf 设置让输出端指向之前生成的influxdb里的telegraf数据库。配置好用户和密码。
pi@raspberrypi:~ $ sudo nano /etc/telegraf/telegraf.conf
[[outputs.influxdb]] urls = ["http://127.0.0.1:8086"] database = "telegraf" username = "[username]" password = "[password]"
ctrl+X保存后重载telegraf服务的配置使之生效
pi@raspberrypi:~ $ sudo systemctl reload telegraf.service
这个时候应当在influxdb里已经生成了对应的数据表格,可以通过influx命令行查看验证设置
pi@raspberrypi:~ $ influx Connected to http://localhost:8086 version 1.8.0 InfluxDB shell version: 1.8.0 > use telegraf Using database telegraf > select * from system limit 5 name: system time host load1 load15 load5 n_cpus n_users uptime uptime_format ---- ---- ----- ------ ----- ------ ------- ------ ------------- 1594650963000000000 raspberrypi 0.39 0.47 0.65 4 1 13350 3:42 1594650973000000000 raspberrypi 0.33 0.46 0.63 4 1 13360 3:42 1594650983000000000 raspberrypi 0.35 0.46 0.63 4 1 13370 3:42 1594650993000000000 raspberrypi 0.59 0.48 0.67 4 1 13380 3:43 1594651003000000000 raspberrypi 0.5 0.47 0.65 4 1 13390 3:43
参考文献:
https://grafana.com/tutorials/install-grafana-on-raspberry-pi/
https://gist.github.com/boseji/bb71910d43283a1b84ab200bcce43c26