虽然vps也便宜,但还是想买4b
树莓派4b显示器接线为 hdmini,买时没有附赠
所以以下均为mac系统下通过ssh操作
文章来自:http://blog.csdn.net/intbird 转载请说明出处
https://pi.intbird.net/
搭建的部分服务可能会忘,html源码可以方便配置
公开的服务需要加个登录密码
没有密码权限的就不要放公网
map的key作为区分
加个背景好看一点
https://pi.intbird.net/
https://pi.intbird.net/
https://uupdump.net/
https://github.com/Botspot/wor-flasher
~/wor-flasher/install-wor-gui.sh
pi的bios里修改内存限制为 4G(我的是4G内存的pi)
重启到windows即可
https://www.worproject.ml/downloads
https://www.raspberrypi.org/software/
可以在线选择要安装的系统和直接烧录sd卡
sd卡需要8g以上
,否则失败
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md
https://www.tomshardware.com/how-to/boot-raspberry-pi-4-usb
https://peyanski.com/official-raspberry-pi-4-usb-boot/
su root
apt update
apt-get upgrade -y
apt full-upgrade
rpi-update
reboot
su root
sudo rpi-eeprom-update -d -a
reboot
su root
raspi-config
Advanced Options > Boot Order > B1 USB Boot
进入高级设置
选择 boot order
选择boot-loader version
如果ssd不是sdcard等,无法用官方 pi-imager 写入
则可以通过sdcardcpier复制到ssd内
这个东西非常好
这个东西非常好
这个东西非常好
见: [ 4. 将Ubuntu写入SSD ]
树莓派从SSD启动Ubuntu的话
我还没看到直接烧录ubuntu系统的
所以:
简单和上手快的话就用 两个USB设备 + 一块SSD
大意说明:
准备
烧录
启动
复制
重启
问题:
ubuntu系统设备发热明显
CPU负载较高
但是有很多桌面版交互较好
自由取舍吧
挂载一个apfs硬盘到树莓派
// 安装挂载工具
apt-get install libfsapfs-utils
> libfsapfs-utils 已经是最新版 (20190210-1)
// 得到外设标示
fdisk -l
> /dev/sda1 2048 616447 614400 300M EFI System
> /dev/sda2 616448 878591 262144 128M Microsoft reserved
> /dev/sda3 878592 234441607 233563016 111.4G unknown
// 挂载硬盘
mkdir -p /mnt/intbird-sandisk
fsapfsmount -f 1 /dev/sda3 /mnt/intbird-sandisk
> fsapfsmount 20190210
> root@raspberrypi:/home/pi# ls /mnt/intbird-sandisk
> Applications cores home Library mnt opt private sw System Users usr Volumes
看他的最新说明文档
snap set system proxy.http="http://127.0.0.1:1083"
snap set system proxy.https="http://127.0.0.1:1083"
snap get system proxy
root@respberrypi:~# snap get system proxy
Key Value
proxy.http http://127.0.0.1:1083
proxy.https http://127.0.0.1:1083
root@respberrypi:~#
snap unset system proxy.http
snap unset system proxy.https
snap install nextcloud
root@respberrypi:~# snap install nextcloud
nextcloud 20.0.4snap2 from Nextcloud✓ installed
snap run snap-store
ubuntu20.10 vnc 自带屏幕共享,官方文档
所以
ubuntu打开共享
mac: finder -> 连接服务器 -> vnc://respberrypi.local
Ubuntu自带vino,因为没有图形界面
所以通过命令行打开它即可
效果如图
x86的snap商店比树莓派的arm snap商店东西多太多
//更新,桌面也有--no-recomends版的,自行查找
sudo apt update
sudo apt install tasksel
tasksel --list-tasks
tasksel install ubuntu-desktop
reboot
systemctl set-default graphical.target
reboot
//手动开启ubuntu桌面,待我研究他咋开机启动
//也可以开启其他桌面,当然其他桌面需要开启对应的VNC服务
startx &
//命令行配置vino,connections让本地和外网都能访问
gsettings set org.gnome.Vino require-encryption false
gsettings set org.gnome.settings-daemon.plugins.sharing active true
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino authentication-methods "['vnc']"
gsettings set org.gnome.Vino vnc-password $(echo -n '$passwd'|base64)
dconf write /org/gnome/settings-daemon/plugins/sharing/vino-server/enabled-connections "['']"
export DISPLAY=:0 && /usr/lib/vino/vino-server &
开启桌面占用1G+内存,so…
// 服务模式
systemctl set-default multi-user.target
//桌面模式
systemctl set-default graphical.target
1.无法远程连接:
拔掉sd卡, 直接在 sd卡的根目录下 添加一个名为 ssh 的空文件
重启即可
2.可以远程连接:
修改pi密码通过远程连接在root下创建一个ssh文件
3.如果有显示器:
$sudo su
$raspi-config
$enable ssh
记录树莓派ip(如: 192.168.3.107)
su root raspi-config
https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
nano /etc/wpa_supplicant/wpa_supplicant.conf
cat /etc/dhcpcd.conf
本地ip: 192.168.3.107
连接软件: termius , mac终端
ssh命令:
内网登录: ssh [email protected] -p 22
外网登录: ssh [email protected] -p 8002
(外网登录见下面)
工具登录: 如图 termius 的mac版
使用pi登录后,修改root用户密码: sudo passwd root
已添加root用户,切换root用户: su root
or sudo su
root账户被禁用登陆(直接使用root用户远程登录会失败)
cat /etc/ssh/sshd_config
搜索 PermitRootLogin
修改: #PermitRootLogin prohibit-password
变为: PermitRootLogin yes
树莓派在家运行,不可能一直内网访问,可以开启远程登录
已有公网ip (移动现在很少给家庭用户公网ip了, 基本上是废了
)
通过ddns方式直接访问到树莓派的内网地址
ddns的方式: (如: noip)
linux client: [https://my.noip.com/#!/dynamic-dns/duc](https://my.noip.com/#!/dynamic-dns/duc)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20201124181402418.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ludGJpcmQ=,size_16,color_FFFFFF,t_70#pic_center)
没有有公网ip: frp, ngrok等内网穿透
./frpc -c ./frpc.ini
./frps -c ./frps.ini
公网ip远程连接如图: 可以在远程连接中 再次进行 远程连接
frpc.ini
[common]
authentication_method = token
section = xxx
server_addr = intbird.net
server_port = 8001
admin_addr = 127.0.0.1
admin_port = 7400
admin_user = intbird
admin_pwd = xxx
[web]
type = http
local_port = 80
custom_domains = intbird.net
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 8002
use_encryption = true
frps.ini
[common]
authentication_method = token
section = xxx
dashboard_port = 8000
dashboard_user = intbird
dashboard_pwd = xxx
bind_port = 8001
bind_udp_port = 8002
vhost_http_port = 8003
subdomain_host = intbird.net
enable_prometheus = false
没有付费,一次只能连接一个客户端且停止后地址会随机改变
https://dashboard.ngrok.com/get-started/setup
./ngork authtoken $youToken
./ngork tcp 22
在公司访问家庭内网示例,在前面的步骤完成后即可
开启sks5或https( gost)
chomd u+x ./gost
./gost -L socks5+tls:/user:password@:1080
Chrome插件SwitchyOmega: https://github.com/FelisCatus/SwitchyOmega/releases
GOST转发本地指定端口,这样会灵活一点
1080端口 用于从家访问公司内网
1090端口 用于从公司访问家里内网
./gost-linux-armv7-2.11.1 -L=socks5://:1080 -F=socks5+tls://intbird:passwd@$HOST:1080
树莓派的打开的端口 局域网电脑可以直接连接
所以再不使用fly-core进行tproxy的情况下:
将iphone的wifi服务连接到树莓派ip
iphone可以通过树莓派上网
1080端口 用于从家访问公司内网
1090端口 用于从公司访问家里内网
Docker官网
apt-get install -y docker.io
yum install -y docker
docker有自己的管理工具和api,哪个工具都行:
docker本地api
, tls远程api
kitematic
, docker-app
k8s node 也算一个吧
我这里用portainer-ce
ocker run -d -p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /root/intbird/docker/portainer:/data \
--restart always \
portainer/portainer-ce \
--admin-password='$2a$10$752FJIPGCGYal52wccmoj.LY00lGmTnDxSmjeI48a.K6abTL.Zbj6'
docker run -d \
-p 5000:5000 \
--restart=always \
--name registry2 \
-v /root/intbird/docker/registry2/auth:/auth \
-v /root/intbird/docker/registry2/certs:/certs \
-v /root/intbird/docker/registry2/data:/var/lib/registry \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=intbird" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd.config \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.pem \
-e REGISTRY_HTTP_TLS_KEY=/certs/registry.key \
registry:2
/auth: 授权文件所在目录
/certs: registry2 https的证书位置
/var/lib/registry : registry2仓库位置
注意: 1.REALM 为 intbird
即: 登录的用户名
注意: 2. htpasswd
htpasswd: 认证类型
可以使用docker工具(xmartlabs/htpasswd)生成
docker run --rm -ti xmartlabs/htpasswd intbird $passwd@ > htpasswd.config
就用默认的5000端口, 443端口留作他用
docker login dockerhub.intbird.ml:5000
两种push方法都是一样的,选一个用即可
docker commit -p intbird-nodejs intbird-nodejs-snapshot
docker tag intbird-nodejs-snapshot dockerhub.intbird.ml:5000/intbird-nodejs-snapshot
docker push dockerhub.intbird.ml:5000/intbird-nodejs-snapshot
docker login
intbird/$passwd
docker pull dockerhub.intbird.ml:5000/intbird-nodejs-snapshot:latest
关于build产物优化体积 仁者见仁,智者见智
FROM node:14.15.0-alpine
WORKDIR /data/
COPY package*.json ./
COPY ./node .
RUN npm install
EXPOSE 8081
CMD [ "node", "node/node-dev.js" ]
# docker build -t intbird.net/nodejs .
# docker run -p 8081:8081 -d intbird.net/nodejs
docker build -t intbird/intbird-nodejs .
docker run -p 8081:8081 -d intbird/intbird-nodejs
两个常见的参数
--restart always
: 相当于守护进程
--net-alias=intbird-nodejs
: 允许别名访问同一网络
提示磁盘空间占满等
尝试了部分方法,效果我觉得不太理想
更多多待后续跟进尝试后继续…
https://www.webmin.com/deb.html
1.自建的CA证书
2.用自建的CA证书生成raspberrypi证书
3.浏览器设置信任自建的CA证书即可
配置一下 /etc/hosts 加入 $ip raspberry
证书信任一下后续远程连接有些安全保障
postfix + dovecot + spark等邮件客户端(待补充…)
树莓派组建或者挂载磁盘阵列后,
备份服务器或者远程文件到磁盘
或者将磁盘文件备份到远程服务器(百度云,阿里云,onedrive等)
https://wordpress.intbird.net/2021/02/08/syncthing/
# rsync -ahivzPL \
# --delete \
# --include-from="/root/intbird/intbird/rsync-include" \
# --exclude-from="/root/intbird/intbird/rsync-exclude" \
# --progress \
# -e "ssh -i /root/.ssh/id_rsa_c" \
# [email protected]:/root/ /root/clouds/server-c/
1.grsync
https://wordpress.intbird.net/2021/02/08/syncthing/
rclone 过于强大,示例为本人使用的
备份服务器指定文件夹 到 Onedrive云盘
以保证服务器可以随时恢复
当然也可以使用这两个sync工具,直接同步到树莓派
rclone sync \
--copy-links \
--delete-during \
--progress \
localhost:/ OneDrive:/OS-Backup/intbird.net/ \
--filter-from filter-list.txt \
-vv > /rclone/log.log 2>&1 &
如何使用详见文章(https://wordpress.intbird.net):
https://wordpress.intbird.net/2021/08/06/debian-system-backup/
!! 在上传之前可以使用 cryptmator,或者 veacrypt 对文件加密后上传
使用rclone工具或者webdav或者盘对应的linux版本
bypy
bypy info // 获取授权码
<< 填入web页面的授权码
bypy syncup // bypy -h for more help
aliyundriver
java -jar webdav.jar --aliyundrive.refresh-token="Token"
rclone config
如果服务器没有浏览器不好授权
可以在本地授权后,将rclone.conf文件scp到服务器上去
服务直接使用授权过的配置可以直接登录
apt-get install davfs2
mount -t davfs http://127.0.0.1:8025 /media/pi/aliDrive/
!! 硬件什么的都需要单独购买,并不便宜,用python(大多数)去控制硬件api,主要看硬件接口和代码质量
apt-get install cheese
点击摄像机图标切换相机源
DS18B20 + 4.7Ω上拉电阻(部分店家已集成电阻)
gpio readall //如果没有正确输出,请按下面代码重新安装
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
4b是40pin针脚,bcm=4 物理针脚=7
!!如果启动时没有指定默认针脚,可以使用命令开启
dtoverlay w1-gpio gpiopin=17
pi@raspberrypi:~ $ /opt/vc/bin/vcgencmd measure_temp
temp=28.0’C
使用kibana做一个温度监控
echo "'$(vcgencmd measure_temp)'"
curl --location --request PUT 'http://localhost:9200/rasberrypi/_temp/' -H 'Content-Type: application/json' -d '{
"temp": 0,
"temp_text": "'$(vcgencmd measure_temp)'"
}'
刚使用两天, 后续继续补充
个人网站: https://intbird.net
文章来自: http://blog.csdn.net/intbird 转载请说明出处