OVH独服布署记录

By | 2026-01-07

服务器配置为OVH 的 ADVANCE-1 | AMD EPYC 4244P 独立服务器

CPUAMD EPYC 4244P – 6c/12t – 3.8 GHz/5.1 GHz
RAM32 GB 5200 MHz
Data disks2×960 GB SSD NVMe Soft RAID
Operating system (OS)Debian 13 (Trixie)

安装服务器时,自定义SWAP为 2 x 4.0 GiB

调整 Systemd 的限制
echo "DefaultLimitNOFILE=1048576" | sudo tee -a /etc/systemd/system.conf
echo "DefaultLimitNOFILESoft=1048576" | sudo tee -a /etc/systemd/system.conf
echo "DefaultLimitNOFILE=1048576" | sudo tee -a /etc/systemd/user.conf
echo "DefaultLimitNOFILESoft=1048576" | sudo tee -a /etc/systemd/user.conf

# 重载配置
sudo systemctl daemon-reexec
优化SWAP
# 优化SWAP写入顺序为并行模式运行,读写速度翻倍

# 查看当前的 UUID
root@clicks:~# lsblk -f | grep swap

# 核对 UUID, 将对应的defaults 修改为 sw,pri=5
root@clicks:~# sudo nano /etc/fstab

root@clicks:~# cat /etc/fstab
UUID=9174cff0-4272-4f74-913d-c23d96b0644e	/	ext4	defaults	0	1
UUID=48570f04-c841-4ef2-ad82-8873bf3d38b1	/boot	ext4	defaults	0	0
LABEL=EFI_SYSPART	/boot/efi	vfat	defaults	0	1
UUID=e4f8999f-2210-46d0-a178-7cdaf6c79332	swap	swap	sw,pri=5	0	0
UUID=ba26ebad-52a6-4185-949e-f7ada7d3d675	swap	swap	sw,pri=5	0	0

# 重新加载 Swap 以生效
root@clicks:~# sudo swapoff -a && sudo swapon -a

# 验证
root@clicks:~# swapon --show
NAME           TYPE      SIZE USED PRIO
/dev/nvme1n1p4 partition   4G   0B    5
/dev/nvme0n1p4 partition   4G   0B    5
SSD和CPU电源性能
# 启用定期 TRIM: 这能保持 SSD 的长期读写性能
root@clicks:~# sudo systemctl enable --now fstrim.timer

# 安装 linux-cpupower CPU 电源管理工具
sudo apt update
sudo apt install -y linux-cpupower

# 设置所有核心进入性能模式
sudo cpupower frequency-set -g performance
内核网络参数优化 (sysctl)
# 使用更现代的目录方式
root@clicks:~# nano /etc/sysctl.d/optimization.conf

# -------------------------------粘贴以下优化内容-------------------
fs.file-max = 2097152
# 增加并发连接处理能力
net.core.somaxconn = 2048
net.ipv4.tcp_max_syn_backlog = 2048

# 开启 BBR 拥塞控制算法 (极大提升长距离连接速度)
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

# 优化端口回收
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65535
# ------------------------------粘贴结束--------------------------

# 应用配置
root@clicks:~# sysctl --system

# 验证生效
root@clicks:~# sysctl net.ipv4.tcp_congestion_control
net.ipv4.tcp_congestion_control = bbr

保存并退出: 按 Ctrl + O 然后 回车 保存,按 Ctrl + X 退出

系统资源限制 (ulimit)
root@clicks:~# nano /etc/security/limits.conf

# -------------------------------粘贴以下优化内容-------------------
* soft nofile 65535
* hard nofile 65535
debian soft nofile 65535
debian hard nofile 65535
# ------------------------------粘贴结束--------------------------

# 验证
root@clicks:~# ulimit -a
root@clicks:~# ulimit -n
优化时间同步
root@clicks:~# apt update
root@clicks:~# apt install -y chrony
root@clicks:~# nano /etc/chrony/conf.d/custom.conf
# -------------------粘贴以下内容,添加全球通用且快速的服务器-----------
# 使用 Cloudflare 和 Google 的 NTP 服务器,速度快且稳定
server time.cloudflare.com iburst prefer
server time.google.com iburst
server pool.ntp.org iburst
server time.nist.gov iburst
server ptbtime1.ptb.de iburst
server ntp.ripe.net iburst
server 0.europe.pool.ntp.org iburst
server 1.north-america.pool.ntp.org iburst

# 允许系统时钟在偏差较大时快速调整(前 3 次同步)
makestep 1.0 3

# 即使在没有网络连接的情况下,也通过漂移文件记录时钟误差
driftfile /var/lib/chrony/drift

# 提高实时性
rtcsync
# -------------------粘贴结束 -----------

# 重启服务
root@clicks:~# systemctl restart chrony

# 查看同步源的状态
root@clicks:~# chronyc sources -v

# 设置时区
root@clicks:~# timedatectl set-timezone Asia/Shanghai

# 查看当前时区
root@clicks:~# timedatectl
让xshell 和 xsftp同步
# 让xshell 和 xsftp同步
cat <<'EOF' >> /root/.bashrc
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
EOF
source /root/.bashrc
ShellScript
# 升级
sudo apt update && sudo apt full-upgrade -y
#安装必要的软件包
sudo apt install -y zip unzip wget curl screen build-essential libevent-dev gcc make libc6-dev gpg gnupg2 ca-certificates lsb-release debian-archive-keyring git socat chrony apache2-utils
# 清理
sudo apt autoremove -y && sudo apt autoclean
# 重启
sudo reboot

下面就是布署服务器环境了

Debian, 安装lnmp及配置多PHP实例记录

Leave a Reply

Your email address will not be published. Required fields are marked *