作为 backup 使用,为 ubuntu server 22.04,首先 sd 卡配置好 config.txt 以及 network-config。树莓派主要用途为 jupyter code-server gitea frp 映射到公网作为计算服务器以及git仓库。
config.txt 备份文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
[all] kernel=vmlinuz cmdline=cmdline.txt initramfs initrd.img followkernel [pi4] max_framebuffers=2 arm_boost=1 [all] # Enable the audio output, I2C and SPI interfaces on the GPIO header. As these # parameters related to the base device-tree they must appear *before* any # other dtoverlay= specification dtparam=audio=on dtparam=i2c_arm=on dtparam=spi=on gpu_mem=256 arm_freq=2100 over_voltage=6 arm_freq_min=1500 # Comment out the following line if the edges of the desktop appear outside # the edges of your display disable_overscan=1 # If you have issues with audio, you may try uncommenting the following line # which forces the HDMI output into HDMI mode instead of DVI (which doesn't # support audio output) #hdmi_drive=2 # Enable the serial pins enable_uart=1 # Autoload overlays for any recognized cameras or displays that are attached # to the CSI/DSI ports. Please note this is for libcamera support, *not* for # the legacy camera stack camera_auto_detect=1 display_auto_detect=1 # Config settings specific to arm64 arm_64bit=1 dtoverlay=dwc2 [cm4] # Enable the USB2 outputs on the IO board (assuming your CM4 is plugged into # such a board) dtoverlay=dwc2,dr_mode=host [all] start_x=1 |
基本操作设置
1 2 3 4 5 6 7 8 9 10 11 |
sudo passwd root su - apt update apt upgrade adduser code adduser code-jupyter adduser --disabled-login --gecos 'pancake' git apt install python3-pip net-tools git mysql-server pip3 config set global.index-url https://pypi.douban.com/simple pip3 install numpy pandas torch torchvision jupyter bs4 requests openpyxl matplotlib scrapy apt install python3-opencv |
Python 及 jupyter 的配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
su code-jupyter mkdir code python3 from notebook.auth import passwd passwd() exit() jupyter notebook --generate-config vim .jupyter/jupyter_notebook_config.py c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.password = ****** c.NotebookApp.notebook_dir = '/home/code-jupyter/code' c.NotebookApp.open_browser = False c.NotebookApp.allow_remote_access = True c.NotebookApp.terminals_enabled = False su - vim /etc/systemd/system/jupyter.service systemctl start jupyter systemctl status jupyter systemctl enable jupyter pip3 config set global.index-url https://pypi.douban.com/simple pip3 install jupyter_contrib_nbextensions pip3 install jupyter_nbextensions_configurator jupyter contrib nbextension install --user systemctl restart jupyter.service |
code-server 的配置
1 2 3 4 5 6 7 8 9 10 11 12 |
cd /home/code wget https://ghproxy.com/https://github.com/coder/code-server/releases/download/v4.5.1/code-server_4.5.1_arm64.deb dpkg -i code-server_4.5.1_arm64.deb rm -f code-server_4.5.1_arm64.deb su code code-server vim .config/code-server/config.yaml su - vim /etc/systemd/system/code.service systemctl start code systemctl status code systemctl enable code |
frp 的配置
1 2 3 4 5 6 7 8 9 10 11 12 |
su ubuntu cd /home/ubuntu wget https://ghproxy.com/https://github.com/fatedier/frp/releases/download/v0.44.0/frp_0.44.0_linux_arm64.tar.gz tar -xvzf frp_0.44.0_linux_arm64.tar.gz rm -f frp_0.44.0_linux_arm64.tar.gz mv frp_0.44.0_linux_arm64/ frp/ cd frp/ vim frpc.ini sudo vim /etc/systemd/system/code.service systemctl start code systemctl status code systemctl enable code |
frp code-server jupyter 自启脚本
1 2 3 4 5 6 7 8 9 10 |
[Unit] Description=jupyter After=network.target [Service] User=code-jupyter ExecStart=/usr/local/bin/jupyter-notebook [Install] WantedBy=multi-user.target |
1 2 3 4 5 6 7 8 9 10 |
[Unit] Description=code-server After=network.target [Service] User=code ExecStart=/bin/code-server [Install] WantedBy=multi-user.target |
1 2 3 4 5 6 7 8 9 10 |
[Unit] Description=frp After=network.target [Service] User=ubuntu ExecStart=/home/ubuntu/frp/frpc -c /home/ubuntu/frp/frpc.ini [Install] WantedBy=multi-user.target |
1 2 3 4 5 6 7 8 9 10 11 |
[Unit] Description=gitea After=network.target [Service] User=git ExecStart=/home/git/gitea web HOME=/home/git [Install] WantedBy=multi-user.target |
gitea 的配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
su - mysql ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码'; exit; mysql_secure_installation 不修改密码 y # 删除匿名用户 y # Disallow root remotely y # 删除测试数据库 exit; mysql -u root -p CREATE DATABASE pancake; ALTER USER 'pancake'@'localhost' IDENTIFIED BY '新密码'; GRANT ALL PRIVILEGES ON pancake.* TO 'pancake'@'localhost'; FLUSH PRIVILEGES; exit; su git cd ~/ wget https://dl.gitea.io/gitea/1.17.2/gitea-1.17.2-linux-arm-6 -O gitea chmod +x gieta su - vim /etc/systemd/system/gitea.service systemctl start gitea.service systemctl status gitea.service systemctl enable gitea.service |
frpc 具体配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[common] server_addr = xxxxx server_port = 7000 token = xxxxx [git] type = tcp local_ip = localhost local_port = 3000 remote_port = 4545 [ssh] type = tcp local_ip = 127.0.0.1 local_port = 22 remote_port = 4546 [jupyter] type = http local_ip = 127.0.0.1 local_port = 8888 custom_domains = xxxxx [code] type = http local_ip = 127.0.0.1 local_port = 8080 custom_domains = xxxxx |