一元网络论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 165|回复: 0

VPS到手必设的几项配置

[复制链接]

1万

主题

1万

帖子

5万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
57317
发表于 2024-7-28 05:12:52 | 显示全部楼层 |阅读模式
Recently, I came across similar posts from experienced users but felt there were more efficient ways to configure certain settings. Here, I'll share my optimization strategy (I'll update this if I find improvements).
Note: Most of my systems run Debian or similar distributions, so if any commands don't work for you, feel free to ask in the comments.
System Configuration
Update Software Repositories
apt update -y && apt upgrade -y
Install Essential Software
apt install sudo curl wget nano
Set System Time Zone to Shanghai
sudo timedatectl set-timezone Asia/Shanghai
To view the current time zone:
timedatectl
To list all available time zones:
timedatectl list-timezones
System Parameter Optimization
This involves adjusting various system and network parameters to improve server performance.
Implementation Methods:
  • Kernel Parameter Tuning: Increase TCP buffer sizes, modify system queue lengths, etc., to enhance network throughput and reduce latency.
  • Performance Optimization: Install and configure tools like Tuned to automatically adjust and optimize the server's operating state.
  • Resource Limitations: Set limits on the number of open files to prevent resource exhaustion attacks.

    These optimizations help manage resources more effectively and protect against external threats, ensuring stable system operation.
    bash
    Better Bandwidth and RTT (BBR)
    BBR is a congestion control algorithm developed by Google designed to optimize network performance and reduce latency.
    Enable BBRX Acceleration
    bash
    Restart the VPS to apply kernel updates and BBR settings:
    sudo reboot
    To verify BBR is enabled:
    lsmod | grep bbr
    The output should include:
    tcp_bbrx
    tcp_bbr
    If only tcp_bbr appears, wait a few minutes and reboot again.
    Add SWAP Space
    SWAP space is a designated disk area used as additional memory when RAM is low. This can significantly boost performance on servers with limited RAM.
    Here's how to add SWAP using a script:
    wget -O swap.sh https://raw.githubusercontent.com/eros520/Script/main/swap.sh && chmod +x swap.sh && ./swap.sh
    To check current memory usage:
    free -m
    Install Docker and Docker Compose
    Docker Installation
    Non-Mainland Servers
    wget -qO- get.docker.com | bash
    Alternatively:
    curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
    Mainland Servers
    curl -sSL https://get.daocloud.io/docker | sh
    Verify Docker Version
    docker -v
    Enable Auto Start at Boot
    systemctl enable docker
    Uninstall Docker
    sudo apt-get purge docker-ce docker-ce-cli containerd.io
    sudo apt-get remove docker docker-engine
    sudo rm -rf /var/lib/docker
    sudo rm -rf /var/lib/containerd
    Docker Compose Installation
    Download Docker Compose
    For non-mainland servers:
    curl -L "https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    For mainland servers:
    curl -L https://get.daocloud.io/docker/compose/releases/download/v2.1.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
    Grant Permissions to Docker Compose
    chmod +x /usr/local/bin/docker-compose
    Check Docker Compose Version
    docker-compose --version
  • 回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|一元网络论坛

    GMT+8, 2024-9-21 15:39 , Processed in 0.211376 second(s), 20 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表