前言
自打小神獸落地以后,個人數據存儲需求是越發的強烈,故打算整合一下現有資源,打造一個家庭服務器,以下是我的幾個痛點:
找圖片麻煩:日積月累的數據太多,需要查找的時候非常麻煩,手機存儲的照片視頻成千上萬,找一張照片如同大海撈針
存儲焦慮:無論換再多手機,容量始終是有上限的,即便是換了更大容量的手機,數據始終是要遷移的,現在一臺手機容量上限也就1T
數據安全:各個網盤廠家都是沖著馬內去的,且數據在他們手上,被拿過去了,誰知道會用于什么途徑,去做什么事情
性能下降:手機存儲<25%卡頓會非常嚴重
PC功耗太高:設想過使用x86架構的設備搭建NAS服務,但考慮到作為家庭服務器需要常年開機,再一尋思功耗及散熱問題的便放棄了,但是不得不說x86架構的設備生態是很友好的,黑群暉、飛牛os等,在我了解這些產品的時候,飛牛已經有了超越黑群暉的趨勢
總的來說,我對家庭服務器的需求如下:
低功耗
大容量,支持擴容
支持AI搜索
支持硬編解碼
多線程,大內存(需要部署多個服務)
硬件選擇:
SOC:這里選擇的是ARM架構的RK3588,8核心(1.8Ghz-2.4Ghz)、6TOPS算力、8K硬編解碼
內存(RAM):32G
eMMC(板載ROM):256G
外置存儲(外置ROM):拼夕夕14T硬盤
散熱:板載被動散熱
軟件選擇:
immich:自動備份照片和視頻到自建服務器。支持多客戶端上傳,提供便捷的Web界面管理媒體文件。
nginx:高性能HTTP服務器與反向代理,擅長處理高并發請求,低資源消耗,并支持SSL/TLS加密。
ddns-go:簡單易用的動態域名解析工具,自動更新域名指向最新的公網IP地址,無需復雜配置。
portainer:輕量級Docker管理UI,輕松管理容器、鏡像和網絡,支持Swarm集群管理,提升運維效率。
certd:自動化獲取和更新SSL/TLS證書,確保網站和服務的安全通信,簡化HTTPS部署流程。
halo:現代化的個人出版平臺,專為博客設計,支持Markdown寫作,擁有豐富的主題和插件,易于搭建個人網站。
相比起x86架構生態的完善方便快捷,這里選擇的路線更為折騰和定制化,下面開始搞起。



系統安裝
鏡像選擇
香橙派官方鏡像:Orange Pi - Orangepi
更高RKNPU版本的鏡像:Release Armbian 24.11 with NPU driver 0.9.8 · Pelochus/armbian-build-rknpu-updates
如果沒有特殊的需求,就選擇官方的鏡像下載就好了。
比如說immich如果想要開啟硬件加速機器學習,就需要rknpu打到v0.9.8的版本及以上Hardware-Accelerated Machine Learning | Immich,但是香橙派最新的官方鏡像支持到的rknpu的版本只到0.9.6,而上面提供的鏡像,RKNPU driver的版本為:v0.9.8,雖然只差了兩個小版本,但是二者的差別還是挺大的。
rknpu driver 0.9.8 相對于 0.9.6 主要有以下一些區別:
更好的芯片適配性3:0.9.8 版本主要是為了更好地適配 rk3588 和 rk3576 芯片對大模型端的支持。在 0.9.8 版本的內核代碼中存在一段對 rk3576 的一個類型的引用,不過在驅動源碼中一開始未定義,需要將其注釋掉或修改為提示的
MONITOR_TPYE_DEV(作者內核版本是 5.10),以解決編譯報錯問題,而 0.9.6 版本可能在這些芯片的大模型支持方面存在不足。功能完善與優化:通常情況下,驅動程序的版本升級會對一些功能進行完善和優化,可能包括提高 NPU 的性能、穩定性,或者修復了 0.9.6 版本中存在的一些漏洞和問題,使 NPU 在處理神經網絡推理計算等任務時更加高效和可靠。例如,可能優化了數據傳輸、處理的流程,減少了延遲或提高了運算速度,但具體的優化細節可能因芯片廠商的更新日志和實際測試情況而異。
下載到所需的鏡像后,下面就開始正式進行系統的安裝,這里使用的是內存卡進行安裝鏡像系統,你需要準備以下東西:
內存卡(>8G)
SD Card Formatter(SD Memory Card Formatter for Windows/Mac - SD Association)
usbimager(bzt / usbimager · GitLab)
安裝過程
執行過程:
使用SD Card Formatter將內存卡快速格式化
使用usbimager將下載好的鏡像文件燒錄到格式化的內存卡中,注意:只支持.xz或img后綴的鏡像,若你的下載的鏡像是上面提供的高rknpu driver的版本,那么你得到的可能是個.gz的壓縮文件,你需要解壓并得到.img的文件,以便于鏡像的安裝
安裝完成后,將內存卡插入開發板,稍等片刻,便會出現登錄窗口
配置系統
香橙派默認賬號密碼:
root:orangepi
orangepi:orangepi
armbian默認賬號密碼:
root:1234
若希望將系統安裝到emmc中,請參考這里:
Armbian:入門 - Armbian Documentation
期間,可能需要apt update和apt upgrade,可以替換為國內的鏡像源,這里使用清華大學的鏡像源,注意選擇自己系統對應的鏡像源,當前系統是armbian:armbian | 鏡像站使用幫助 | 清華大學開源軟件鏡像站 | Tsinghua Open Source Mirror
環境配置
系統信息
root@orangepi5plus:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
root@orangepi5plus:/# uname -r
6.1.43-rockchip-rk3588
root@orangepi5plus:/# lscpu
Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
root@orangepi5plus:/# docker --version
Docker version 28.0.4, build b8034c0
root@orangepi5plus:/# docker compose version
Docker Compose version v2.34.0
root@orangepi5plus:/# cat /sys/kernel/debug/rknpu/version
RKNPU driver: v0.9.6更改鏡像源
這里選擇Ubuntu Ports鏡像,Ubuntu Ports是Arm64,Armhf等平臺的Ubuntu軟件倉庫
官方鏡像地址:https://developer.aliyun.com/mirror/ubuntu-ports?spm=a2c6h.13651102.0.0.1ecc1b11fC2McV
修改鏡像源文件:/etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu-ports/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble main restricted universe multiverse
?
deb https://mirrors.aliyun.com/ubuntu-ports/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-security main restricted universe multiverse
?
deb https://mirrors.aliyun.com/ubuntu-ports/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-updates main restricted universe multiverse
?
# deb https://mirrors.aliyun.com/ubuntu-ports/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-proposed main restricted universe multiverse
?
deb https://mirrors.aliyun.com/ubuntu-ports/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ noble-backports main restricted universe multiverse隨后執行apt update更新鏡像源包
掛載硬盤
下載掛載硬盤所需包:exfat-fuse以及exfatprogs
root@orangepi5plus:/etc/apt# apt-get install exfat-fuse
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
exfat-fuse
0 upgraded, 1 newly installed, 0 to remove and 324 not upgraded.
Need to get 25.6 kB of archives.
After this operation, 82.9 kB of additional disk space will be used.
Get:1 https://mirrors.aliyun.com/ubuntu-ports noble/universe arm64 exfat-fuse arm64 1.4.0-2 [25.6 kB]
Fetched 25.6 kB in 0s (88.2 kB/s)
Selecting previously unselected package exfat-fuse.
(Reading database ... 39869 files and directories currently installed.)
Preparing to unpack .../exfat-fuse_1.4.0-2_arm64.deb ...
Unpacking exfat-fuse (1.4.0-2) ...
Setting up exfat-fuse (1.4.0-2) ...
Processing triggers for man-db (2.10.2-1) ...
?root@orangepi5plus:/etc/apt# sudo apt-get install exfatprogs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
exfatprogs
0 upgraded, 1 newly installed, 0 to remove and 324 not upgraded.
Need to get 64.9 kB of archives.
After this operation, 435 kB of additional disk space will be used.
Get:1 https://mirrors.aliyun.com/ubuntu-ports noble/universe arm64 exfatprogs arm64 1.2.2-1build1 [64.9 kB]
Fetched 64.9 kB in 0s (244 kB/s)
Selecting previously unselected package exfatprogs.
(Reading database ... 39854 files and directories currently installed.)
Preparing to unpack .../exfatprogs_1.2.2-1build1_arm64.deb ...
Unpacking exfatprogs (1.2.2-1build1) ...
Setting up exfatprogs (1.2.2-1build1) ...
Processing triggers for man-db (2.10.2-1) ...
?查看硬盤設備地址,找到最大的分區,這里是sda2,一會兒就用它掛載到系統
root@orangepi5plus:/etc/apt# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 12.7T 0 disk
├─sda1 8:1 0 16M 0 part
└─sda2 8:2 0 12.7T 0 part
mtdblock0 31:0 0 16M 0 disk
mmcblk0 179:0 0 233.3G 0 disk
├─mmcblk0p1 179:1 0 1G 0 part /boot
└─mmcblk0p2 179:2 0 229.9G 0 part /var/log.hdd創建硬盤要掛載到系統的目錄,并掛載
root@orangepi5plus:/etc/apt# mkdir -m 777 /mnt/wukongroot@orangepi5plus:/etc/apt# mount -t exfat-fuse /dev/sda2 /mnt/wukong/
FUSE exfat 1.4.0 (libfuse3)
WARN: volume was not unmounted cleanly.查看/dev/sda2分區是否掛載到/mnt/wukong
root@orangepi5plus:/etc/apt# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 3.2G 17M 3.1G 1% /run
/dev/mmcblk0p2 227G 2.2G 222G 1% /
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 16G 4.0K 16G 1% /tmp
/dev/mmcblk0p1 1022M 120M 903M 12% /boot
/dev/zram1 188M 2.6M 171M 2% /var/log
tmpfs 3.2G 0 3.2G 0% /run/user/1000
tmpfs 3.2G 0 3.2G 0% /run/user/0
/dev/sda2 13T 267G 13T 3% /mnt/wukong開機自動掛載硬盤
獲取分區UUID
root@orangepi5plus:~# sudo blkid /dev/sda2
/dev/sda2: LABEL="EXFAT_14T" UUID="3A34-BB7F" BLOCK_SIZE="512" TYPE="exfat" PARTLABEL="Basic data partition" PARTUUID="3d6c752f-c336-405e-ab51-2eb0966a0e84"編輯/etc/fstab,追加以下內容
UUID=3A34-BB7F /mnt/wukong exfat-fuse defaults,uid=1000,gid=1000,umask=0000,allow_other 0 0完整內容
root@orangepi5plus:~# cat /etc/fstab
UUID=4694b5ee-9f59-4564-8f67-d51ccf671fe4 / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1
UUID=B7B5-A91A /boot vfat defaults 0 2
tmpfs /tmp tmpfs defaults,nosuid 0 0
UUID=3A34-BB7F /mnt/wukong exfat-fuse defaults,uid=1000,gid=1000,umask=0000,allow_other 0 0定時掛載
由于某些特殊情況,如磁盤高溫保護,斷電,磁盤掛載延時等情況,磁盤可能未能正常掛載到系統,這里設定每隔五分鐘自動掛載設備,編輯/etc/crontab文件,追加以下內容:
*/5 * * * * root mount -a >> /var/log/mount_a.log 2>&1完整內容:
root@orangepi5-plus:/var/log# cat /etc/cron
cron.d/ cron.daily/ cron.hourly/ cron.monthly/ crontab cron.weekly/
root@orangepi5-plus:/var/log# cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
# You can also override PATH, but by default, newer versions inherit it from the environment
#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
# 每天凌晨3點自動備份
0 3 * * * root RESTIC_PASSWORD=****** restic backup --repo /mnt/wukong/os/backup/ / --exclude /dev --exclude /proc --exclude /sys --exclude /tmp --exclude /run --exclude /mnt >> /var/log/restic_backup.log 2>&1
# 每隔五分鐘自動掛載設備
*/5 * * * * root mount -a >> /var/log/mount_a.log 2>&1指令詳解:
mount -a是 Linux 系統中的一個命令,用于掛載/etc/fstab文件中列出的所有文件系統。- *
mount:** 是 Linux 中用于掛載文件系統的命令。掛載是指將一個文件系統 (例如硬盤分區、USB 設備、網絡共享) 連接到文件系統樹中的一個目錄 (稱為掛載點),使得可以通過該目錄訪問文件系統中的文件和目錄。- *
-a:** 是mount命令的一個選項,表示 "all",即掛載所有在/etc/fstab文件中定義的文件系統。執行
mount -a命令后,系統會讀取/etc/fstab文件,并嘗試掛載其中列出的所有文件系統。如果某個文件系統已經掛載,則mount -a會跳過該文件系統。系統啟動時會自動執行
mount -a命令,掛載/etc/fstab中定義的所有文件系統。如果某些文件系統由于某種原因未正確掛載,可以使用
mount -a命令嘗試重新掛載。
關于是否需要手動重啟服務:
tips:
cron守護進程會定期掃描/etc/crontab文件以及/etc/cron.d/目錄下的所有文件,以查找新的或修改過的定時任務。當cron守護進程檢測到文件發生更改時,它會自動重新加載配置文件,而無需手動重啟服務。
安裝代理客戶端
在服務搭建的過程中,很多時候我們所用到的資源,如:鏡像、模型、開源項目等,這些資源不可避免的很多都在國外,在搭建自己的服務過程中,最頭疼的也是這個問題,很多時候,尤其是在linux服務器上,經常會因為網絡受限,導致服務器軟件包更新失敗、源碼拉取失敗、鏡像拉取失敗等等問題,為了解決這些問題,這里找到一個基于Linux系統的代理軟件
開始安裝,clone項目
root@orangepi5plus:/app/docker/immich# cd /etc/
root@orangepi5plus:/etc# mkdir -m 777 clash
root@orangepi5plus:/etc# cd clash/
root@orangepi5plus:/etc/clash# $ git clone https://github.com/Elegycloud/clash-for-linux-backup.git clash-for-linux
Cloning into 'clash-for-linux'...
remote: Enumerating objects: 681, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 681 (delta 49), reused 37 (delta 37), pack-reused 622 (from 2)
Receiving objects: 100% (681/681), 18.42 MiB | 7.95 MiB/s, done.
Resolving deltas: 100% (243/243), done.
root@orangepi5plus:/etc/clash# cd clash-for-linux/編輯.env文件,添加訂閱url,由于各大vpn廠商提供的代理節點列表格式不統一,這里需要將地址轉換為clash需要json格式
轉換地址網站:SoCloud 訂閱轉換、飛鳥云
訂閱地址:https://fn1.476579.xyz/api/v1/client/subscribe?token=s9d9c3c1a7h4e3b9n7q0f4g9t1r5e8j6
轉換后的地址:
root@orangepi5plus:/etc/clash/clash-for-linux# nano .env修改代理啟動腳本,找到sed -n 開頭的代碼替換:
## Clash 配置文件重新格式化及配置
# 取出代理相關配置
#sed -n '/^proxies:/,$p' $Temp_Dir/clash.yaml > $Temp_Dir/proxy.txt
sed -n '/^proxies:/,$p' $Temp_Dir/clash_config.yaml > $Temp_Dir/proxy.txt
?
# 合并形成新的config.yaml
cat $Temp_Dir/templete_config.yaml > $Temp_Dir/config.yaml
cat $Temp_Dir/proxy.txt >> $Temp_Dir/config.yaml
\cp $Temp_Dir/config.yaml $Conf_Dir/啟動代理:
root@orangepi5plus:/etc/clash/clash-for-linux# bash start.sh
CPU architecture: arm64
?
正在檢測訂閱地址...
Clash訂閱地址可訪問! [ OK ]
?
正在下載Clash配置文件...
配置文件config.yaml下載成功! [ OK ]
?
判斷訂閱內容是否符合clash配置文件標準:
訂閱內容符合clash標準
?
正在啟動Clash服務...
服務啟動成功! [ OK ]
?
Clash Dashboard 訪問地址: http://<ip>:9090/ui
Secret: a2s7m4l7b4e5t2s7b1j0t1m2t6v5j5r8r7a0m1g7d4s2w1z0i9a2a9o9e4o6n5b5
?
く__,.ヘヽ. / ,ー? 〉
\ ', !-─‐-i / /′
/`?' L//`ヽ?
/ /, /| , , ',
? / /-‐/ i L_ ? ヽ! i
? ? 7?`? ?'?-??!ハ| |
!,/7 '0' ′0iソ| |
|.從 _ ,,,, / |./ |
?'| i>.?,,__ _,.イ / .i |
?'| | / k_7_/?'ヽ, ?. |
| |/i 〈|/ i ,.? | i |
.|/ / i: ?! \ |
kヽ>?? _,.?? /?!
!'〈//`T′', \ `'7'?r'
?'ヽL__|___i,___,ン?|ノ
?-,/ |___./
'?' !_,.:
本項目完全免費,若你是收費買的,恭喜您,您被騙了!
項目地址:https://github.com/Elegycloud/clash-for-linux-backup
項目隨時會寄,且行且珍惜!
請執行以下命令加載環境變量: source /etc/profile.d/clash.sh
?
請執行以下命令開啟系統代理: proxy_on
?
若要臨時關閉系統代理,請執行: proxy_off
root@orangepi5plus:/etc/clash/clash-for-linux# source /etc/profile.d/clash.sh
root@orangepi5plus:/etc/clash/clash-for-linux# proxy_on
[√] 已開啟代理
?安裝GPU驅動
根據immich官網提供的資料,若我們想要開啟immich的硬件轉碼功能,需要設備擁有GPU驅動,詳細介紹如下


這里要求我們安裝libmali,根據提供的網址以及我們RK3588所需對應版本(libmali-valhall-g610-g13p0-gbm_1.9-1_arm64.deb),我這里下載的是最新的發布版本

下載完成之后,進入服務器進行安裝。
要安裝 libmali-valhall-g610-g13p0-gbm 并確保 /usr/lib/aarch64-linux-gnu/libmali.so.1 存在,我們按照以下步驟操作:
步驟 1:安裝依賴項
sudo apt update
sudo apt install -f libdrm2 libgbm1 # 確保基礎依賴已安裝步驟 2:安裝下載的 .deb 文件
sudo dpkg -i libmali-valhall-g610-g13p0-gbm_1.9-1_arm64.deb步驟 3:確認庫文件位置
安裝后庫文件默認會出現在以下路徑之一:
/usr/lib/libmali.so.1/usr/lib/aarch64-linux-gnu/libmali.so.1
檢查是否已存在:
ls /usr/lib/aarch64-linux-gnu/libmali.so.1
ls /usr/lib/libmali.so.1步驟 4:若文件不存在,手動創建符號鏈接
如果庫文件在 /usr/lib/libmali.so.1 但不在目標路徑:
sudo ln -s /usr/lib/libmali.so.1 /usr/lib/aarch64-linux-gnu/libmali.so.1步驟 5:更新動態鏈接庫緩存
sudo ldconfig步驟 6:驗證安裝
ls /usr/lib/aarch64-linux-gnu/libmali.so.1 # 確認文件存在
ldconfig -p | grep libmali.so.1 # 檢查是否被緩存識別系統備份
Restic 簡介
Restic 是一個現代化的備份程序,可以備份你的文件:
- 支持 Linux, BSD, macOS 和 Windows 系統 [6](https://restic.net/)
- 支持多種存儲類型,包括本地目錄、遠程服務器、云存儲等 [6](https://restic.net/)
- 易于使用,只需一個可執行文件 [3](https://tech.coe.drexel.edu/data/backups/restic/)
- 執行增量備份,只傳輸更改的部分 [3](https://tech.coe.drexel.edu/data/backups/restic/)
- 數據去重,節省存儲空間 [3](https://tech.coe.drexel.edu/data/backups/restic/)
- 安全,使用加密技術 [3](https://tech.coe.drexel.edu/data/backups/restic/)
- 可以輕松驗證備份,確保文件可以恢復
1. 安裝 Restic
root@orangepi5-plus:~# apt install restic
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關系樹... 完成
正在讀取狀態信息... 完成
下列軟件包是自動安裝的并且現在不需要了:
libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python-pkg-resources python-setuptools python2 python2-minimal python2.7 python2.7-minimal
使用'apt autoremove'來卸載它(它們)。
建議安裝:
libjs-sphinxdoc sphinx-rtd-theme-common
下列【新】軟件包將被安裝:
restic
升級了 0 個軟件包,新安裝了 1 個軟件包,要卸載 0 個軟件包,有 1 個軟件包未被升級。
需要下載 6,859 kB 的歸檔。
解壓縮后會消耗 19.5 MB 的額外空間。
獲取:1 http://ports.ubuntu.com jammy-security/universe arm64 restic arm64 0.12.1-2ubuntu0.3 [6,859 kB]
已下載 6,859 kB,耗時 4秒 (1,923 kB/s)
正在選中未選擇的軟件包 restic。
(正在讀取數據庫 ... 系統當前共安裝有 40382 個文件和目錄。)
準備解壓 .../restic_0.12.1-2ubuntu0.3_arm64.deb ...
進度:[ 0%] [..................................................................................................................................................................................................................................................]
正在解壓 restic (0.12.1-2ubuntu0.3) ...#######################..................................................................................................................................................................................................]
正在設置 restic (0.12.1-2ubuntu0.3) ...#######################################################################..................................................................................................................................................]
進度:[ 60%] [#################################################################################################################################################.................................................................................................]
正在處理用于 man-db (2.10.2-1) 的觸發器 ...####################################################################################################################################################################.................................................] 2. 更新 Restic
root@orangepi5-plus:~# restic version
restic 0.12.1 compiled with go1.18.1 on linux/arm64
root@orangepi5-plus:~# restic self-update
writing restic to /usr/bin/restic
find latest release of restic at GitHub
latest version is 0.18.0
download SHA256SUMS
download SHA256SUMS.asc
GPG signature verification succeeded
download restic_0.18.0_linux_arm64.bz2
downloaded restic_0.18.0_linux_arm64.bz2
saved 28180664 bytes in /usr/bin/restic
successfully updated restic to version 0.18.0
root@orangepi5-plus:~# restic version
restic 0.18.0 compiled with go1.24.1 on linux/arm643. 初始化 Restic 倉庫
root@orangepi5-plus:/mnt/wukong/os/backup# restic init --repo /mnt/wukong/os/backup/
enter password for new repository:
enter password again:
created restic repository c89fe5815b at /mnt/wukong/os/backup/
Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.4. 首次備份
這里使--exclude指定要排除備份的目錄,首次備份大約需要幾分鐘
root@orangepi5-plus:/mnt/wukong/os/backup# restic backup --repo /mnt/wukong/os/backup/ / --exclude /dev --exclude /proc --exclude /sys --exclude /tmp --exclude /run --exclude /mnt
enter password for repository:
repository c89fe581 opened (version 2, compression level auto)
created new cache in /root/.cache/restic
no parent snapshot found, will read all files
[0:00] 0 index files loaded
Files: 431376 new, 0 changed, 0 unmodified
Dirs: 65819 new, 0 changed, 0 unmodified
Added to the repository: 15.391 GiB (10.213 GiB stored)5. 自動備份
后續的自動備份這里使用系統自帶的crontab添加一條任務:
編/etc/crontab文件,追加以下內容:
0 3 * * * root RESTIC_PASSWORD=***** restic backup --repo /mnt/wukong/os/backup/ / --exclude /dev --exclude /proc --exclude /sys --exclude /tmp --exclude /run --exclude /mnt >> /var/log/restic_backup.log 2>&1完整內容:
root@orangepi5-plus:/mnt/wukong/os/backup# cat /etc/cron
cron.d/ cron.daily/ cron.hourly/ cron.monthly/ crontab cron.weekly/
root@orangepi5-plus:/mnt/wukong/os/backup# cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
# You can also override PATH, but by default, newer versions inherit it from the environment
#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
0 3 * * * root RESTIC_PASSWORD=***** restic backup --repo /mnt/wukong/os/backup/ / --exclude /dev --exclude /proc --exclude /sys --exclude /tmp --exclude /run --exclude /mnt >> /var/log/restic_backup.log 2>&1首次備份完后,后續的備份就很快速了,不管是首次還是后續備份,命令都是一樣的。
root@orangepi5-plus:/mnt/wukong/os/backup# RESTIC_PASSWORD=******* restic backup --repo /mnt/wukong/os/backup/ / --exclude /dev --exclude /proc --exclude sys --exclude /tmp --exclude /run --exclude /mnt
repository c89fe581 opened (version 2, compression level auto)
using parent snapshot 60b8b6be
[0:00] 100.00% 5 / 5 index files loaded
Files: 0 new, 16 changed, 431360 unmodified
Dirs: 0 new, 23 changed, 65796 unmodified
Added to the repository: 5.022 MiB (1.457 MiB stored)
processed 431376 files, 45.882 GiB in 0:45
snapshot d1758662 saved6. 恢復系統
要恢復系統,你需要使用 restic restore 命令。
restic restore latest --repo /mnt/wukong/os/backup --target /Docker安裝及配置
由于 Ubuntu 官方倉庫中的 Docker 版本可能不是最新的,我們將從 Docker 官方倉庫安裝 2。
更新軟件包列表:
sudo apt update安裝必要的依賴包,以便 apt 可以通過 HTTPS 使用倉庫:
sudo apt install apt-transport-https ca-certificates curl software-properties-common添加 Docker 官方 GPG 密鑰:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -添加 Docker 倉庫到 APT 源:
sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu jammy stable"注意:這里指定了
arch=arm64,因為您的系統是 aarch64 架構。同時,jammy是 Ubuntu 22.04 的代號。再次更新軟件包列表,以應用新的倉庫:
sudo apt update安裝 Docker Engine:
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin驗證 Docker 是否成功安裝并運行:
sudo systemctl status docker如果 Docker 正在運行,您應該看到類似以下的輸出:
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since ... Docs: https://docs.docker.com(可選) 允許非 root 用戶執行 Docker 命令:
默認情況下,只有 root 用戶或 docker 組的用戶才能運行 Docker 命令。要允許您的用戶執行 Docker 命令而無需 sudo,請執行以下操作:
bashsudo usermod -aG docker $USER newgrp docker注銷并重新登錄,或運行
newgrp docker命令以使更改生效。
步驟 2:安裝 Docker Compose
從 Docker CE 20.10 開始,Docker Compose 已經集成為 Docker 的一個插件。在上面的步驟中,我們已經安裝了 docker-compose-plugin,所以您現在可以使用 docker compose 命令。
驗證 Docker Compose 是否安裝成功:
docker compose version如果安裝成功,您應該看到 Docker Compose 的版本信息。
更改docker鏡像源
sudo nano /etc/docker/daemon.json完整內容
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://0c105db5188026850f80c001def654a0.mirror.swr.myhuaweicloud.com",
"https://5tqw56kt.mirror.aliyuncs.com",
"https://docker.ckyl.me/",
"https://docker.hpcloud.cloud",
"https://docker.m.daocloud.io",
"https://docker.unsee.tech",
"https://docker.1panel.live",
"http://mirrors.ustc.edu.cn",
"https://docker.chenby.cn",
"http://mirror.azure.cn",
"https://dockerpull.org",
"https://dockerhub.icu",
"https://hub.rat.dev",
"https://proxy.1panel.live",
"https://docker.1panel.top",
"https://docker.m.daocloud.io",
"https://docker.1ms.run",
"https://docker.ketches.cn"
]
}保存后,重啟docker服務
sudo systemctl restart docker驗證鏡像源是否修改成功,在輸出信息中,找到 Registry Mirrors 字段,若顯示了你添加的鏡像源地址,則表示修改成功。
sudo docker info自建服務
Portainer服務
Docker Portainer是一個開源的輕量級容器管理界面,用于簡化Docker環境的管理。以下是關于Portainer的簡要介紹:
功能介紹
直觀的Web界面:提供易于使用的圖形界面,無需深入了解Docker命令。
資源管理:管理容器、鏡像、卷、網絡等Docker資源。
多環境支持:支持本地和遠程Docker環境的管理。
訪問控制:提供用戶管理和權限控制,確保安全訪問。
應用模板:支持快速部署常見應用。
Docker配置
創建portainer的docker-compose.yml文件存放目錄:
root@orangepi5plus:/# mkdir -m 777 app
root@orangepi5plus:/# cd app/
root@orangepi5plus:/app# mkdir -m 777 docker
root@orangepi5plus:/app# cd docker/
root@orangepi5plus:/app/docker# mkdir -m 777 portainer
root@orangepi5plus:/app/docker# cd portainer/新增docker-compose.yml配置文件
services:
portainer:
image: 6053537/portainer-ce
container_name: portainer
restart: unless-stopped
ports:
- "9443:9443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
volumes:
portainer_data:運行Portainer容器
docker compose up -d訪問Portainer
https://<your_server_ip>:9443這個網站要求密碼長度必須至少為 12 個字符。
使用該網站生成一個密碼:隨機密碼生成器 | 菜鳥工具
用戶名:admin
密碼:rC4-oO7>iS9)
設置開機自啟
修改docker-compose.yml文件,主要新增:restart: unless-stopped
version: '3.9'
?
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: unless-stopped
ports:
- "9443:9443"
- "8000:8000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
?
volumes:
portainer_data:設置docker自啟
sudo systemctl enable docker檢查是否設置成功
sudo systemctl is-enabled docker # 應返回enabled重啟,檢查是否成功
# 模擬重啟測試
sudo reboot
docker ps | grep portainerImmich服務
簡要介紹
Immich是一款開源的、自托管的照片和視頻備份解決方案,允許用戶在私有服務器上存儲、管理和分享他們的媒體文件。以下是Immich的主要特點:
自托管:所有數據存儲在用戶自己的服務器上,確保數據隱私和安全。
自動備份:支持移動設備中的照片和視頻自動備份,確保數據安全無憂。
跨平臺支持:提供移動端(iOS和Android)和Web端應用,方便用戶隨時隨地訪問和管理備份內容。
隱私保護:由于數據存儲在自己的服務器上,用戶的照片和視頻不會被未經授權的第三方訪問。
開源免費:項目在GitHub上開源,用戶可以自由查看、修改和分發。
易于部署:支持Docker容器化部署,安裝和維護簡單。
安裝配置
安裝方式有很多種,這里使用之前安裝的portainer來安裝immich,以便于管理 參考官網安裝方式:Portainer | Immich
完整配置截圖:

點擊部署后會自動拉取容器并運行,看到下面的服務都啟動后便可使用immich了

常規配置,我們這里不做過多介紹,參考官方文檔即可,下面我們針對兩種特殊情況進行配置。
開啟GPU硬件轉碼
在前面的步驟,我們已經安裝好了GPU驅動,符合immich服務開啟硬件轉碼的條件,下面是關于硬件轉碼的介紹
硬件轉碼:
此功能允許您使用GPU來加速轉碼并減少CPU負載。 請注意,與具有類似設置的軟件轉碼相比,硬件轉碼產生的視頻要大得多,通常質量較低。使用慢速預設和首選更高效的編解碼器可以縮小這一差距。
所以,這里就按照官方的說法,添加immich-server開啟GPU加速的參數(官方示例):
services:
rkmpp:
security_opt: # enables full access to /sys and /proc, still far better than privileged: true
- systempaths=unconfined
- apparmor=unconfined
group_add:
- video
devices:
- /dev/rga:/dev/rga
- /dev/dri:/dev/dri
- /dev/dma_heap:/dev/dma_heap
- /dev/mpp_service:/dev/mpp_service
#- /dev/mali0:/dev/mali0 # only required to enable OpenCL-accelerated HDR -> SDR tonemapping
volumes:
#- /etc/OpenCL:/etc/OpenCL:ro # only required to enable OpenCL-accelerated HDR -> SDR tonemapping
#- /usr/lib/aarch64-linux-gnu/libmali.so.1:/usr/lib/aarch64-linux-gnu/libmali.so.1:ro # only required to enable OpenCL-accelerated HDR -> SDR tonemapping配置完成后,記得重新啟動immich-server服務。
開啟機器學習加速
在安裝當前系統的時候,我們選擇的是Armbian24.11的鏡像,系統自帶NPU 0.9.8的驅動,這里我們天然的具備了immich-machine-learning服務開啟硬件加速機器學習的條件,以下是相關介紹
硬件加速的機器學習:
此功能允許您使用GPU來加速機器學習任務,例如智能搜索和面部識別,同時降低CPU負載。
理論上我們可以使用GPU進行加速的,但是我們使用的SOC是RK3588,它內置了一個NPU芯片,具有6Tops的算力,關于為什么使用NPU加速而不是GPU加速,這里給出我找到的說法:
RKNPU:專為加速人工智能任務,特別是神經網絡計算而設計,針對矩陣乘法、卷積等操作進行優化。
GPU:最初用于圖形渲染,擅長并行計算,適合同時處理大量簡單任務。
以及immich官方給出的說法:
與ARM NN(GPU)相比,RKNPU具有:
更廣泛的模型支持 (包括搜索,其中ARM NN不加速)
更少的熱量產生
精度略低 (RKNPU始終使用FP16,而ARM NN默認情況下使用更高的精度FP32,除非
MACHINE_LEARNING_ANN_FP16_TURBO已啟用)變速 (在RK3588上測試):
如果
MACHINE_LEARNING_RKNN_THREADS默認值為1,則在大多數情況下,RKNPU的ML作業吞吐量將比ARM NN低得多,但延遲相似 (例如在搜索時)如果
MACHINE_LEARNING_RKNN_THREADS設置為3時,它將比FP32處的ARM NN快一些,但比ARM NN慢一些,如果MACHINE_LEARNING_ANN_FP16_TURBO已啟用當其他任務也使用GPU (如轉碼) 時,RKNPU比ARM NN具有顯著優勢,因為它使用其他空閑的NPU而不是競爭GPU使用
降低RAM使用率,如果
MACHINE_LEARNING_RKNN_THREADS默認值為1,但如果大于1 (這是充分利用NPU所必需的,因此速度與ARM NN相當)
所以我們這里選擇的是使用官方提供的rknn驅動而不是armnn(理論上我們擁有GPU驅動,這里是沒問題的,但是沒測)驅動的方式來啟用加速。
添加immich-machine-learning開啟NPU機器加速的參數(官方示例):
更改鏡像名稱,名稱后追加"-rknn"
services: immich-machine-learning: # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag. # Example tag: ${IMMICH_VERSION:-release}-cuda image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-rknn
增加配置
services: rknn: security_opt: - systempaths=unconfined - apparmor=unconfined devices: - /dev/dri:/dev/dri
更改完配置后,需要重新拉取新的immich-machine-learning鏡像并重新部署。
完整配置
#
# WARNING: To install Immich, follow our guide: https://immich.app/docs/install/docker-compose
#
# Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.
?
name: immich
?
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
# extends:
# file: hwaccel.transcoding.yml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
security_opt: # enables full access to /sys and /proc, still far better than privileged: true
- systempaths=unconfined
- apparmor=unconfined
group_add:
- video
devices:
- /dev/rga:/dev/rga
- /dev/dri:/dev/dri
- /dev/dma_heap:/dev/dma_heap
- /dev/mpp_service:/dev/mpp_service
#- /dev/mali0:/dev/mali0 # only required to enable OpenCL-accelerated HDR -> SDR tonemapping
volumes:
# Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
- ${UPLOAD_LOCATION}:/usr/src/app/upload
- /etc/localtime:/etc/localtime:ro
#- /usr/local/etc/OpenCL:/etc/OpenCL:ro # only required to enable OpenCL-accelerated HDR -> SDR tonemapping
#- /usr/local/lib/aarch64-linux-gnu/libmali.so.1:/usr/lib/aarch64-linux-gnu/libmali.so.1:ro # only required to enable OpenCL-accelerated HDR -> SDR tonemapping
?
env_file:
- stack.env
ports:
- '2283:2283'
depends_on:
- redis
- database
restart: always
healthcheck:
disable: false
?
immich-machine-learning:
container_name: immich_machine_learning
# For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
# Example tag: ${IMMICH_VERSION:-release}-cuda
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-rknn
# extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
# file: hwaccel.ml.yml
# service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable
security_opt:
- systempaths=unconfined
- apparmor=unconfined
devices:
- /dev/dri:/dev/dri
volumes:
- /app/immich/cache:/cache
env_file:
- stack.env
restart: always
healthcheck:
disable: false
?
redis:
container_name: immich_redis
image: docker.io/redis:6.2-alpine@sha256:148bb5411c184abd288d9aaed139c98123eeb8824c5d3fce03cf721db58066d8
healthcheck:
test: redis-cli ping || exit 1
restart: always
?
database:
container_name: immich_postgres
image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_INITDB_ARGS: '--data-checksums'
volumes:
# Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
healthcheck:
test: >-
pg_isready --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" || exit 1; Chksum="$$(psql --dbname="$${POSTGRES_DB}" --username="$${POSTGRES_USER}" --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
interval: 5m
start_interval: 30s
start_period: 5m
command: >-
postgres -c shared_preload_libraries=vectors.so -c 'search_path="$$user", public, vectors' -c logging_collector=on -c max_wal_size=2GB -c shared_buffers=512MB -c wal_compression=on
restart: always
?
volumes:
model-cache:
?環境變量:
UPLOAD_LOCATION=/mnt/wukong/immich
DB_DATA_LOCATION=./postgres
IMMICH_VERSION=release
DB_PASSWORD=postgres
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
TZ=Asia/Shanghai
TRANSFORMERS_CACHE=/app/immich/cache訪問Immich:
http://<your_server_ip>:2283地圖主題
模型配置
模型選擇
我們在創建immich服務的時候會涉及到以下幾種模型,主要用于機器學習的設置,當然這些模型也源自于官方推薦的模型:
人臉識別模型(immich-人臉識別-人臉識別模型):
immich-app/antelopev2
immich-app/buffalo_l
智能搜索模型(immich-智能搜索-CLIP模型):
immich-app/XLM-Roberta-Large-Vit-B-16Plus(注意:若為aarch64架構的設備,僅支持cpu運行,不支持RKNN (Rockchip)的硬件加速機器學習)
ViT-L-16-SigLIP2-384__webli(這個模型也是經歷過使用上面的模型遇到的問題,在issue中找到的解決方案,該模型支持RKNN加速)
模型下載
模型下載地址:
1、huggingface鏡像網:HF-Mirror
2、異性島:https://aliendao.cn
3、國內替代:https://modelscope.cn/home
4、模力方舟(Gitee AI)https://ai.gitee.com/
模型下載解決辦法:
參考知乎(https://zhuanlan.zhihu.com/p/663712983)
這里使用推薦的huggingface-cli 進行下載的方式
# 按需修改參數
# 修改1:模型名稱-immich-app/ViT-L-16-SigLIP2-384
# 修改2:模型下載目錄名稱-ViT-L-16-SigLIP2-384__webli
huggingface-cli download immich-app/ViT-L-16-SigLIP2-384__webli --local-dir ViT-L-16-SigLIP2-384__webli部分執行日志如下:
部分情況可能下載不成功,大概率是網絡問題,這里建議使用科學工具下載,并將代理更改為TUN模式(不懂的可以百度:TUN模式和系統代理模式的區別)
PS E:\leeleo\immich模型> huggingface-cli download immich-app/ViT-L-16-SigLIP2-384__webli --local-dir ViT-L-16-SigLIP2-384__webli
?? Warning: 'huggingface-cli download' is deprecated. Use 'hf download' instead.
Fetching 164 files: 1%|▊ | 1/164 [00:00<00:53, 3.07it/s]Downloading 'textual/onnx__MatMul_4693' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\textual\6umd0cxo5zyrYxJ1oQuQ9JrZ0fo=.045527ee754ccf37d05cc3d8e12a4476921efed6bb63c0015079d468288b60f4.incomplete'
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
Downloading 'textual/onnx__MatMul_4651' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\textual\xAPNXXnW_3oVaPjX6ojjYZklE8o=.d3328f759a8a1c78188083313f57a96ae09f03842c531df8e24b9734c2bab5fa.incomplete'
Downloading 'textual/onnx__MatMul_4612' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\textual\mg1mkykMcSkL2Cmo8jlvsRL1tt0=.575e95b60986547dce34e2a663908dc2852cdde5ea7ead78849e5ff8ce7a5ecf.incomplete'
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
Downloading 'textual/onnx__MatMul_4692' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\textual\CaogzFCi0wzG5zDpSi1gGWsQxWU=.6eb18939b8285643d2f762eeaab656166f104a915a53699dd8c3a64143782628.incomplete'
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
Downloading 'textual/onnx__MatMul_4694' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\textual\g2AMHBkBmE2vZEnBWMBhHaLc10c=.72d923170816fc964ec8f5e51bdebddae0ca8c7e2a47108c1342621560abd698.incomplete'
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
Downloading 'textual/onnx__MatMul_4652' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\textual\oLFFiVwLDVvx_4R1Xrzg33LZ0pA=.ebf2a071cb262d814953b09f1ee49976fbf90bd503057cb9a315b99314db6d50.incomplete'
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
Downloading 'README.md' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\Xn7B-BWUGOee2Y6hCZtEhtFu4BE=.0bddbb6d5331139dc8614a4db1273df336f655af.incomplete'
Downloading 'textual/onnx__MatMul_4653' to 'ViT-L-16-SigLIP2-384__webli\.cache\huggingface\download\textual\JvaR6sD9DPwUH3vwOzFIkHubW9Q=.549d4236a1c5fcd1b3449670443d5c739966c734522a62896b7f254c75d23c37.incomplete'
Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. Falling back to regular HTTP download. For better performance, install the package with: `pip install huggingface_hub[hf_xet]` or `pip install hf_xet`
README.md: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 320/320 [00:00<?, ?B/s]
Download complete. Moving file to ViT-L-16-SigLIP2-384__webli\textual\rknpu\rk3568\model.rknn██████████████████████████████████▋ | 965M/1.14G [12:27<01:59, 1.49MB/s]
text.token_embedding.weight: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.05G/1.05G [13:34<00:00, 1.29MB/s]
Download complete. Moving file to ViT-L-16-SigLIP2-384__webli\textual\text.token_embedding.weight████████████████████████████████████████▌ | 1.06G/1.14G [13:28<00:53, 1.54MB/s]
model.rknn: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 674M/674M [05:46<00:00, 1.94MB/s]
Download complete. Moving file to ViT-L-16-SigLIP2-384__webli\visual\rknpu\rk3576\model.rknn██████████████████████████████████████████████▊ | 1.07G/1.14G [13:35<00:46, 1.56MB/s]
model.rknn: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.14G/1.14G [14:24<00:00, 1.32MB/s]
Download complete. Moving file to ViT-L-16-SigLIP2-384__webli\textual\rknpu\rk3588\model.rknn██████████████████████████████████████████████████▌ | 1.11G/1.14G [14:03<00:19, 1.54MB/s]
model.onnx: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.27G/1.27G [12:56<00:00, 1.63MB/s]
Download complete. Moving file to ViT-L-16-SigLIP2-384__webli\visual\model.onnx████████████████████████████████████████████████████████████████████| 1.14G/1.14G [14:24<00:00, 1.52MB/s]
model.rknn: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 653M/653M [06:46<00:00, 1.60MB/s]
Download complete. Moving file to ViT-L-16-SigLIP2-384__webli\visual\rknpu\rk3588\model.rknn
Fetching 164 files: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 164/164 [19:21<00:00, 7.09s/it]模型部署
下載完成后我們需要將模型放置到它該在的位置,以下目錄為所有類型的模型存放位置
immich-machine-learning:
volumes:
- /app/immich/cache:/cache但是需要注意一點,我們不同的模型放到不同的目錄:
人臉識別模型存放位置:/app/immich/cache/facial-recognition
能搜索模型存放位置:/app/immich/cache/clip
拷貝完成后目錄結構如下:

隨后,重啟immich-machine-learning服務。
模型配置
接下來我們要做的就是對immich服務中,對人臉識別以及智能搜索的模型配置了:
這里需要注意的一點就是,模型名稱是與上面拷貝的模型目錄名稱是一致的,不要輸入錯誤了。

Nginx服務
代理配置
nginx.conf:
events {}
?
http {
resolver 223.5.5.5;
upstream immich_server {
server immich_server:2283;
}
?
upstream portainer {
server portainer:9443;
}
?
# yourdomain.com
server {
listen 80;
server_name yourdomain.com;
return 301 https://$host$request_uri;
}
?
server {
listen 443 ssl;
server_name leeleo.cc;
?
ssl_certificate /etc/nginx/certs/yourdomain.com.pem;
ssl_certificate_key /etc/nginx/certs/yourdomain.com.key;
?
return 404; # 或者重定向到其他頁面
}
?
# immich.yourdomain.com:443
server {
listen 443 ssl;
server_name immich.yourdomain.com;
?
ssl_certificate /etc/nginx/certs/immich.yourdomain.com.pem;
ssl_certificate_key /etc/nginx/certs/immich.yourdomain.com.key;
?
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5:!TLSv1.0:!TLSv1.1;
?
location / {
proxy_pass http://immich_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
?
# portainer.yourdomain.com:443
server {
listen 443 ssl;
server_name portainer.yourdomain.com;
?
ssl_certificate /etc/nginx/certs/portainer.yourdomain.com.pem;
ssl_certificate_key /etc/nginx/certs/portainer.yourdomain.com.key;
?
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5:!TLSv1.0:!TLSv1.1;
?
location / {
proxy_pass https://portainer;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}Docker配置
docker-compose.yml
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- "80:80"
- "443:443"
networks:
- immich_default
- portainer_default
- halo_halo_network
dns:
- 223.5.5.5
- 223.6.6.6
- 8.8.8.8
- 8.8.4.4
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./certs:/etc/nginx/certs
restart: unless-stopped
networks:
immich_default: # 聲明 immich_default 網絡為外部網絡
external: true
portainer_default: # 聲明 portainer_default 網絡為外部網絡
external: true
halo_halo_network: # 聲明 halo_halo_network 網絡為外部網絡
external: trueCertd證書服務
Docker配置
mkdir -p -m 777 /app/docker/certd
cd /app/docker/certd
nano docker-compose.yml 基本沒做修改,只改了個版本號
version: '3.3' # 兼容舊版docker-compose
services:
certd:
# 鏡像 # ↓↓↓↓↓ ---- 鏡像版本號,建議改成固定版本號,例如:certd:1.29.0
image: registry.cn-shenzhen.aliyuncs.com/handsfree/certd:1.34.1
container_name: certd # 容器名
restart: unless-stopped # 自動重啟
volumes:
# ↓↓↓↓↓ -------------------------------------------------------- 數據庫以及證書存儲路徑,默認存在宿主機的/data/certd/目錄下,【您需要定時備份此目錄,以保障數據容災】
# 只要修改冒號前面的,冒號后面的/app/data不要動
- /data/certd:/app/data
ports: # 端口映射
# ↓↓↓↓ ---------------------------------------------------------- 如果端口有沖突,可以修改第一個7001為其他不沖突的端口號,第二個7001不要動
- "7001:7001"
# ↓↓↓↓ ---------------------------------------------------------- https端口,可以根據實際情況,是否暴露該端口
- "7002:7002"
#↓↓↓↓ -------------------------------------------------------------- 如果出現getaddrinfo ENOTFOUND錯誤,可以嘗試設置dns
# dns:
# - 223.5.5.5 # 阿里云公共dns
# - 223.6.6.6
# # ↓↓↓↓ --------------------------------------------------------- 如果你服務器在騰訊云,可以用這個替換上面阿里云的公共dns
# - 119.29.29.29 # 騰訊云公共dns
# - 182.254.116.116
# # ↓↓↓↓ --------------------------------------------------------- 如果你服務器部署在國外,可以用這個替換上面阿里云的公共dns
# - 8.8.8.8 # 谷歌公共dns
# - 8.8.4.4
# extra_hosts:
# # ↓↓↓↓ -------------------------------------------------------- 這里可以配置自定義hosts,外網域名可以指向本地局域網ip地址
# - "localdomain.com:192.168.1.3"
# # ↓↓↓↓ ------------------------------------------------ 直接使用主機的網絡,如果網絡問題實在找不到原因,可以嘗試打開此參數
# network_mode: host
labels:
com.centurylinklabs.watchtower.enable: "true"
# ↓↓↓↓ -------------------------------------------------------------- 啟用ipv6網絡,還需要把下面networks的注釋放開
# networks:
# - ip6net
environment:
# 設置環境變量即可自定義certd配置
# 配置項見: packages/ui/certd-server/src/config/config.default.ts
# 配置規則: certd_ + 配置項, 點號用_代替
# #↓↓↓↓ ----------------------------- 如果忘記管理員密碼,可以設置為true,重啟之后,管理員密碼將改成123456,然后請及時修改回false
- certd_system_resetAdminPasswd=false
?
# 默認使用sqlite文件數據庫,如果需要使用其他數據庫,請設置以下環境變量
# 注意: 選定使用一種數據庫之后,不支持更換數據庫。
# 數據庫遷移方法:1、使用新數據庫重新部署一套,然后將舊數據同步過去,注意flyway_history表的數據不要同步
# #↓↓↓↓ ----------------------------- 使用postgresql數據庫,需要提前創建數據庫
# - certd_flyway_scriptDir=./db/migration-pg # 升級腳本目錄
# - certd_typeorm_dataSource_default_type=postgres # 數據庫類型
# - certd_typeorm_dataSource_default_host=localhost # 數據庫地址
# - certd_typeorm_dataSource_default_port=5433 # 數據庫端口
# - certd_typeorm_dataSource_default_username=postgres # 用戶名
# - certd_typeorm_dataSource_default_password=yourpasswd # 密碼
# - certd_typeorm_dataSource_default_database=certd # 數據庫名
?
# #↓↓↓↓ ----------------------------- 使用mysql數據庫,需要提前創建數據庫 charset=utf8mb4, collation=utf8mb4_bin
# - certd_flyway_scriptDir=./db/migration-mysql # 升級腳本目錄
# - certd_typeorm_dataSource_default_type=mysql # 數據庫類型, 或者 mariadb
# - certd_typeorm_dataSource_default_host=localhost # 數據庫地址
# - certd_typeorm_dataSource_default_port=3306 # 數據庫端口
# - certd_typeorm_dataSource_default_username=root # 用戶名
# - certd_typeorm_dataSource_default_password=yourpasswd # 密碼
# - certd_typeorm_dataSource_default_database=certd # 數據庫名
?
# ↓↓↓↓ --------------------------------------------------------- 自動升級,上面certd的版本號要保持為latest
# certd-updater: # 添加 Watchtower 服務
# image: containrrr/watchtower:latest
# container_name: certd-updater
# restart: unless-stopped
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# # 配置 自動更新
# environment:
# - WATCHTOWER_CLEANUP=true # 自動清理舊版本容器
# - WATCHTOWER_INCLUDE_STOPPED=false # 不更新已停止的容器
# - WATCHTOWER_LABEL_ENABLE=true # 根據容器標簽進行更新
# - WATCHTOWER_POLL_INTERVAL=600 # 每 10 分鐘檢查一次更新
?
?
# ↓↓↓↓ -------------------------------------------------------------- 啟用ipv6網絡,還需要把上面networks的注釋放開
#networks:
# ip6net:
# enable_ipv6: true
# ipam:
# config:
# - subnet: 2001:db8::/64
?docker compose up -d
HeadScale服務
官網:https://headscale.net/stable/
搭建HeadScale服務
先建三個文件夾
mkdir -p ./headscale/{config,lib,run} cd ./headscale下載配置文件,并扔到/config目錄中,最終呈現:
./headscale/config/config.yaml,對配置文件稍作修改,結果如下:server_url: https://headscale.leeleo.cc listen_addr: 0.0.0.0:443 metrics_listen_addr: 0.0.0.0:9090 grpc_listen_addr: 0.0.0.0:50443 tls_letsencrypt_challenge_type: TLS-ALPN-01 tls_letsencrypt_listen: ":http" tls_cert_path: "/var/certs/headscale.leeleo.cc.pem" tls_key_path: "/var/certs/headscale.leeleo.cc.key" dns: magic_dns: false
新建
docker-compose.yaml文件到./headscale目錄,內容如下:services: headscale: # 手動指定版本號為:0.26.1 image: docker.io/headscale/headscale:0.26.1 restart: unless-stopped container_name: headscale # 若想遠程訪問需使用0.0.0.0而不是127.0.0.1 # 這里開放80端,不然Lets Encript證書檢報錯很煩 ports: - "0.0.0.0:8080:8080" - "0.0.0.0:9090:9090" - "0.0.0.0:5280:80" volumes: # Please set <HEADSCALE_PATH> to the absolute path # of the previously created headscale directory. - ./config:/etc/headscale - ./lib:/var/lib/headscale - ./run:/var/run/headscale - /app/docker/nginx/certs:/var/certs command: serve部署-驗證
# 部署 docker compose up -d # 跟蹤日志 docker logs --follow headscale # 檢查容器狀態 docker ps # 驗證headscale是否可用: curl http://127.0.0.1:9090/metrics部署完成后需要創建個賬戶給后續客戶端使用
docker exec -it headscale headscale users create admin
這里基本上就算是完成了,官網上還提供了其他的指令,內容比較多,基本用不上,到這就基本滿足咱的使用了
安裝TailScale客戶端
官網:https://tailscale.com/download
可以理解為TailScale是客戶端,而HeadScale是服務端
安裝TailScale客戶端:不同端的下載地址
不同端連接自建HeadScale服務的方式(參考:https://tailscale.com/kb/1507/custom-control-server?q=headscale&tab=windows)
Win:
tailscale login --login-server=https://headscale.leeleo.cc
Android:
點擊Tailscale應用程序右上角的用戶個人資料圖標以打開設置菜單。
如果您尚未登錄任何其他尾網,請點擊登錄。菜單項。否則,點按已登錄的用戶。
點擊右上角的菜單,然后選擇使用備用服務器。
輸入自定義控制服務器URL并點擊登錄。
完事之后,最終都會彈出一個網頁,提供一個命令行,讓在咱的服務端執行,示例如下:

tips:如果上面圖片中的網址并未彈出,那么就需要確認下當前客戶端的DNS是否需要清理一下了,最簡單的辦法是斷開網絡重連一下,不行就手動設置靜態IP地址,指定DNS服務,然后再切回DHCP自動分配。
然后,去服務端執行,出現Node *** registered字樣就算是完成注冊了
root@orangepi5-plus:/app/docker/headscale# docker exec -it headscale headscale nodes register --user admin --key z3lUqUEZ3ydDsm9xQu3mGNDf
Node pc0003 registered
MQTT和WS通訊協議服務
?為什么選擇Mosquitto
在家庭環境的NAS中部署Mosquitto(MQTT服務器)是一個相當實用的選擇,主要基于以下幾個核心需求和優勢:
?? 家庭物聯網中樞的核心價值
1. 解決設備"孤島"問題
統一通信協議:不同品牌的智能設備(如小米傳感器、飛利浦燈泡、ESP32開發板等)可以通過MQTT這個通用協議進行通信
跨平臺集成:作為Home Assistant、Node-RED等智能家居平臺的消息總線,實現設備聯動
2. 數據隱私與本地控制
完全本地化:所有設備數據在家庭內部網絡流轉,不依賴任何云服務
避免廠商鎖定:即使設備廠商的云服務停止,本地自動化仍然正常工作
自定義規則:基于本地消息的自由自動化,不受云服務功能限制
?? 具體應用場景
下面這個表格詳細對比了幾款常見的MQTT服務端,你可以快速了解它們的特點。
對于在NAS的Docker環境中部署,Mosquitto因其輕量和簡單,是目前最省心的選擇。
??Docker配置
使用 Docker Compose 部署服務時,我們通常通過一個 docker-compose.yml 文件來定義服務。這里是一個基礎且功能完整的配置示例,你可以直接使用:
version: '3.8' # 建議使用 3.8 或更高版本
services:
mosquitto:
image: eclipse-mosquitto:2 # 使用 Mosquitto 2.x 版本
container_name: mosquitto_server
restart: unless-stopped # 設置自動重啟
ports:
- "1883:1883" # MQTT 協議默認端口
- "9001:9001" # WebSocket 協議端口,適用于瀏覽器等客戶端
volumes:
- ./mosquitto/config:/mosquitto/config # 掛載配置文件目錄
- ./mosquitto/data:/mosquitto/data # 掛載數據持久化目錄
- ./mosquitto/log:/mosquitto/log # 掛載日志目錄
networks:
- mosquitto_net # 自定義網絡,便于其他容器通信
?
networks:
mosquitto_net:
name: mosquitto_network
driver: bridge鏡像:我們使用了官方的
eclipse-mosquitto:2鏡像。端口映射:
1883端口用于標準的 MQTT 通信,9001端口則用于支持 WebSocket 連接。數據卷:通過
volumes將容器內的配置、數據和日志目錄掛載到宿主機,這樣即使容器被刪除,你的這些重要文件也不會丟失。網絡:創建了一個自定義的橋接網絡
mosquitto_net。如果 Home Assistant 也運行在 Docker 中,并接入同一個網絡,它們之間就可以直接使用容器名mosquitto進行通信,無需通過宿主機的 IP 地址。
?? 創建目錄和配置文件
創建目錄結構
在你存放
docker-compose.yml文件的同級目錄下,執行以下命令來創建所需的目錄:mkdir -p mosquitto/config mosquitto/data mosquitto/log創建基礎配置文件
在
mosquitto/config目錄中創建一個名為mosquitto.conf的文件,并填入以下基本配置:# 啟用數據持久化 persistence true # 設置持久化數據存儲位置 persistence_location /mosquitto/data/ # 設置日志輸出文件 log_dest file /mosquitto/log/mosquitto.log ? # MQTT 協議監聽器 - 1883 端口 listener 1883 0.0.0.0 ? # WebSocket 協議監聽器 - 9001 端口 listener 9001 0.0.0.0 protocol websockets ? # 允許匿名連接(初期測試用,后期建議關閉) allow_anonymous false ? # 指定密碼文件 password_file /mosquitto/config/passwd
?? 啟動與驗證
啟動服務 在
docker-compose.yml文件所在目錄下,執行以下命令來啟動 Mosquitto 服務:docker compose up -d檢查服務狀態 運行
docker compose ps可以查看服務狀態,確認 Mosquitto 容器是否正常啟動。測試連接 你可以使用 MQTTX-1、桌面版 MQTT Explorer 等客戶端工具進行測試。連接時,使用你 Docker 宿主機的 IP 地址,端口為
1883。由于我們目前允許匿名連接,通常可以直接連上。
?? 增強安全性(可選但重要)
設置用戶名和密碼
修改配置文件:編輯
mosquitto/config/mosquitto.conf文件,禁用匿名訪問并指定密碼文件。allow_anonymous false password_file /mosquitto/config/passwd創建用戶和密碼:進入容器內部創建密碼文件并添加用戶(這里以用戶名
myuser,密碼mypassword為例)。# 進入容器 docker exec -it mosquitto sh # 在容器內創建密碼文件并添加用戶 mosquitto_passwd -b -c /mosquitto/config/passwd admin 123456 # 退出容器 exit重啟服務:修改配置后,重啟 Mosquitto 容器使配置生效。
docker compose restart
?? Nginx配置
nginx.conf配置
events {}
?
# TCP/UDP代理配置 (用于MQTT 1883端口)
stream {
upstream mosquitto_mqtt_server {
server mosquitto_server:1883; # 替換為您的Mosquitto容器名
}
?
# mosquitto.leeleo.cc:8883 - MQTT over SSL
server {
listen 8883 ssl;
proxy_pass mosquitto_mqtt_server;
ssl_certificate /etc/nginx/certs/mosquitto.leeleo.cc.pem;
ssl_certificate_key /etc/nginx/certs/mosquitto.leeleo.cc.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5:!TLSv1.0:!TLSv1.1;
# TCP代理相關配置
proxy_connect_timeout 1s;
proxy_timeout 1h; # MQTT連接通常需要長時間保持
proxy_buffer_size 4k;
}
}
?
http {
resolver 127.0.0.11 valid=10s; # 使用Docker內置DNS解析器
upstream mosquitto_ws_server {
server mosquitto_server:9001; # 替換為您的Mosquitto容器名
}
?
# mosquitto.leeleo.cc:443 -> 轉發到Mosquitto的9001
server {
listen 443 ssl; # Nginx在9001端口監聽SSL
server_name mosquitto.leeleo.cc;
?
ssl_certificate /etc/nginx/certs/mosquitto.leeleo.cc.pem;
ssl_certificate_key /etc/nginx/certs/mosquitto.leeleo.cc.key;
ssl_protocols TLSv1.2 TLSv1.3;
?
location / {
proxy_pass http://mosquitto_ws_server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
?
}docker-compose.yml配置
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- "80:80"
- "443:443"
- "8883:8883"
networks:
- mosquitto_network
dns:
- 223.5.5.5
- 223.6.6.6
- 8.8.8.8
- 8.8.4.4
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./certs:/etc/nginx/certs
restart: unless-stopped
networks:
mosquitto_network: # 聲明 mosquitto_network 網絡為外部網絡
external: true?? 客戶端連接方式
配置完成后,客戶端應該這樣連接:
MQTT客戶端:
mqtts://mosquitto.leeleo.cc:8883WebSocket客戶端:
wss://mosquitto.leeleo.cc:443