首页 > 数据库 > 数据库开发技术 > Linux系统初始化脚本(新版)
先放个链接,万一有人关注呢
↓ ↓ ↓ ↓ ↓
根据一位大神的建议,优化了Linux系统初始化脚本:

ntpd -q &使用一些高效的命令,如sed、awk、grep等,来替换一些复杂的脚本,以提高脚本的执行速度。
通过一些优化配置来提高系统的性能,例如调整内核参数等。
# 设置时区并同步时间ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtimentpd -q &# 禁用selinuxsed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config# 关闭防火墙systemctl stop firewalldsystemctl disable firewalld# 历史命令显示操作时间echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/bashrc# SSH超时时间echo "export TMOUT=600" >> /etc/profile# 禁止root远程登录sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config# 禁止定时任务向发送邮件sed -i 's/^MAILTO=root/MAILTO=""/g' /etc/crontab# 设置最大打开文件数cat <<EOF >> /etc/security/limits.conf* soft nofile 65535* hard nofile 65535EOF# 系统内核优化cat <<EOF >> /etc/sysctl.confnet.ipv4.tcp_syncookies = 1net.ipv4.tcp_max_tw_buckets = 20480net.ipv4.tcp_max_syn_backlog = 20480net.core.netdev_max_backlog = 262144net.ipv4.tcp_fin_timeout = 20EOF# 减少SWAP使用echo "vm.swappiness = 0" >> /etc/sysctl.confsysctl -p# 安装系统性能分析工具及其他yum install -y gcc make autoconf vim sysstat net-tools iostat iftop# 获取MQ堆积量QUEUE_NAME="example_queue"QUEUE_DEPTH=$(echo "dis qstatus($QUEUE_NAME) queue" | runmqsc | grep "CURDEPTH" | awk '{print $3}')echo "MQ堆积量:$QUEUE_DEPTH"
如有不足之处,欢迎指正!
谢谢你这么好看还关注我

原文作者:运维book思议;如有侵权,请联系管理员删除。