在群晖虚拟机中安装Debian12及python
填坑,构建自己的指数历史数据库。
一开始想利用群晖自带的python和计划任务来提取股价信息,但失败了,因为群晖界面和SSH后台的python是不同的,如果想执行复杂的任务,需要进入后台执行,前台的计划是无法完成的。我想应该是群晖的安全考虑,让外部的requests包之类的都无法运行,避免被黑客利用,Docker也是只能在后台执行,大概是相同的考虑。虽然后台SSH能执行,但风险太大了,所以放弃。利用虚拟机曲线救国w
群晖的虚拟机视频卡要选择cirrus,否则安装完成后会卡在光标界面无法进入系统。至少需要2核2G。数据库使用的sqlite3,python自带,保存在工程文件夹里面,省很多事。
Debian12可以到他们的官网下载,选择下载列表里的种子文件,按照提示安装就可以了,/home独立安装,这样重装的时候会保留,磁盘选择LVM,安装介质和网络镜像都选否,否则要多安装大概5个小时(亲测OTZ ,在查到的信息里说语言最好选英文,因为中文有各种问题,没有测照做了。桌面环境取消GNOME选择KDE(据说更好用 ,选择SSH和网站服务。GRUB选上,是选择系统的引导界面。
更新软件源
sudo nano /etc/apt/sources.list
添加清华的镜像,如下几行,如果有CDROM的注释掉。
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware # 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换 deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
群晖开NFS服务和共享文件夹,虚拟机安装NFS服务,将NAS的文件夹挂载上来
sudo apt-get update
sudo apt-get nfs-common
sudo mkdir /mnt/给挂载文件夹起个名字
sudo mount -t nfs 群晖IP:群晖文件夹 /mnt/给挂载文件夹起个名字
自动挂载
sudo nano /etc/fstab
增加一行
群晖IP:群晖文件夹 /mnt/给挂载文件夹起个名字 nfs defaults 0 0
验证
sudo mount -a
Debian12自带python3,这里需要schedule库,使用如下指令
sudo apt-get install python3-schedule
打完收工,未完待续w
以上。
参考文献
Debian系统上通过NFS挂载远程服务器硬盘_debian 自动挂载磁盘-CSDN博客
debian | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
debian系统启动卡住,需要等待大约90秒才能进系统的解决办法
Debian 镜像提示 does not have a Release file. 404错误
评论