Ubuntu 系统初始化
# 设置系统进程和文件描述符限制
echo '* soft noproc 655350' | sudo tee -a /etc/security/limits.conf
echo '* hard noproc 655350' | sudo tee -a /etc/security/limits.conf
echo '* soft nofile 655350' | sudo tee -a /etc/security/limits.conf
echo '* hard nofile 655350' | sudo tee -a /etc/security/limits.conf
# 为 root 用户设置进程和文件描述符限制
echo 'root soft noproc 655350' | sudo tee -a /etc/security/limits.conf
echo 'root hard noproc 655350' | sudo tee -a /etc/security/limits.conf
echo 'root soft nofile 655350' | sudo tee -a /etc/security/limits.conf
echo 'root hard nofile 655350' | sudo tee -a /etc/security/limits.conf
# 设置 systemd 的文件描述符限制
echo 'DefaultLimitNOFILE=655360' | sudo tee -a /etc/systemd/user.conf
echo 'DefaultLimitNOFILE=655360' | sudo tee -a /etc/systemd/system.conf
echo "session required pam_limits.so" >> /etc/pam.d/common-session
echo "session required pam_limits.so" >> /etc/pam.d/common-session-noninteractive
# 设置 ulimit 限制
echo 'ulimit -HSn 1024000' | sudo tee -a /etc/profile.d/limits.sh
chmod +x /etc/profile.d/limits.shLast updated