Appearance
服务器初始化运维
安装程序
更新配置
- 初始化镜像源
- 配置 pip 源
安装软件
bash
sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list.d/debian.sources
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
apt install btop screen zstd
调整配置
bash
sysctl -w vm.swappiness=1
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
python -m pip install --upgrade pip
配置私钥
bash
#私钥文件
~/.ssh/id_rsa
# 公钥文件
~/.ssh/authorized_keys
# 调整允许私钥登录,一般不用
systemctl restart sshd
程序配置
bash
# 配置docker下载代理
# /etc/systemd/system/docker.service.d/proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
Environment="NO_PROXY=localhost,127.0.0.1"
bash
# 初始化脚本
# /etc/systemd/system/init-jobs.service
[Unit]
Description=Init Bash
After=network.target network-online.target
Wants=network-online.target
Documentation=https://hqshi.cn
[Service]
Type=forking
TimeoutStartSec=600
TimeoutStopSec=30
WorkingDirectory=/script/admin
ExecStart=/bin/bash init.sh
User=root
Group=root
Restart=no
[Install]
WantedBy=multi-user.target
数据库维护
常用脚本
bash
# 查找当前占用前十的目录
du -h --max-depth=1 | sort -hr | head -n 10
winserver 不知道什么时候开始默认禁止 ping 了。可以打开防火墙里的文件和打印机共享就能访问了
powershell
# 启用winrm
WinRM quickconfig
# 开放端口,存疑
# Set-NetFirewallRule -Name WINRM-HTTP-In-TCP -RemoteAddress Any
# 打开公用链接的防火墙
# win + s 搜索防火墙,找到 Windows 远程管理(HTTP-In) 选择允许
# 将所有磁盘设置为自动挂载
Get-VirtualDisk | Set-VirtualDisk -ismanualattach $false
# 将网络适配器设置为私有
Get-NetConnectionProfile
Set-NetConnectionProfile -Name "NetworkName" -NetworkCategory Private
bash
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/username/repository.git
常用命令
bash
# 对比变更内容
git diff --name-only HEAD^ HEAD