Raspberry Pi 安装备份 2

安装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

https://ksummersill.medium.com/raspberry-pi-4-with-influx-telegraf-and-grafana-to-monitor-sensor-data-6487efbef42b

Raspberry Pi 安装备份

就是个流程backup

  1. 到https://www.raspberrypi.org/software/operating-systems/ 下载OS
  2. 用Win32 Disk Imager把下载的img镜像烧到microSD/SD卡里
    1. Win32 Disk Imager的portable 可以在https://sourceforge.net/projects/win32diskimager/files/Archive/ 下载
  3. 烧好后在/boot 下添加设置文档
    1. 名为ssh的空文档,无后缀,开启SSH
    2. 名为wpa_supplicant.conf的文档,开启wifi,内容为:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
     ssid="<SSID>"
     psk="<PASSWORD>"
     scan_ssid=1
}

其中SSID为无线网络名称,psk就是连接密码

然后把microSD/SD卡放入Raspberry Pi, 连接上电源就可以开始折腾了。

配置文件设置相关见https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

安装pihole

按照https://docs.pi-hole.net/main/basic-install/ 安装

如果是跑 docker的话按照https://github.com/pi-hole/docker-pi-hole/#running-pi-hole-docker 来

pihole设置

处理默认的adlist外,可以添加其他的list

比如https://github.com/privacy-protection-tools/anti-AD

换浏览器了

终于还是从Waterfox换成了Firefox。

几年前Firefox刚刚出新版的时候就曾经尝试过迁移,但还是被当时还比较缺少的插件给劝退了,特别是我习惯用的几个,基本新版都不支持,也没有替代品, 所以就老老实实的继续使用waterfox。

结果waterfox越来越卡越来越慢,本着试试的心态重新捡起了Firefox,结果发现…真香!

基本上几个插件满足我所有需求。另外tree style tab配合上隐藏tab条的css好用到爆,非常符合我的使用习惯。

唉,应该早点换的 :P

树莓派的废物利用

手头上还有个古早的raspberry pi 一代的B型,当时的热劲过去了后一直在储藏室里吃灰。

正好心血来潮装了pi-hole来拦截广告和追踪。也算是废物利用吧。

重新刷了SD里的系统,用puttySSH后按说明一步步装了pi-hole,更新了pi-hole list,添加了几个支持中国用户的广告过滤规则进去, 也算是借用现有资源,把adblock里的受欢迎的easylist,easylist china,fanboy-social内的网站信息规整了一下 (方法来源: https://wp.gxnas.com/1734.html)

curl -s -L https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt https://easylist-downloads.adblockplus.org/malwaredomains_full.txt https://easylist-downloads.adblockplus.org/fanboy-social.txt > adblock.unsorted
sort -u adblock.unsorted | grep ^\|\|.*\^$ | grep -v \/ > adblock.sorted
sed 's/[\|^]//g' < adblock.sorted > adblock.hosts
rm adblock.unsorted adblock.sorted

效果不错👍

然后mi UI不愧其广告UI之称,各种广告追踪不断

相关资源:

  • https://www.raspberrypi.org/downloads/raspbian/
  • https://github.com/pi-hole/pi-hole/#one-step-automated-install
  • https://wp.gxnas.com/1734.html