快速业务通道

Linux 基本系统初始化脚本第一版

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-05

继续共享线上脚本,本脚本主要用于新装linux系统初始化工作.

  1. #!/bin/sh
  2. # desc: coralzd modified by www.freebsdsystem.org www.linuxtone.org
  3. #-------------------cut begin-------------------------------------------
  4. #welcome
  5. cat << EOF
  6. --------------------------------------------------------------
  7. | === Welcome to Centos System init === |
  8. --------------http://www.linuxtone.org------------------------
  9. ----------------------Author:NetSeek--------------------------
  10. EOF
  11. #disable ipv6
  12. cat << EOF
  13. --------------------------------------------------------------
  14. | === Welcome to Disable IPV6 === |
  15. --------------------------------------------------------------
  16. EOF
  17. echo "alias net-pf-10 off" >> /etc/modprobe.conf
  18. echo "alias ipv6 off" >> /etc/modprobe.conf
  19. /sbin/chkconfig --level 35 ip6tables off
  20. echo "ipv6 is disabled!"
  21. #disable selinux
  22. sed -i ''/SELINUX/s/enforcing/disabled/'' /etc/selinux/config
  23. echo "selinux is disabled,you must reboot!"
  24. #vim
  25. sed -i "8 s/^/alias vi=''vim''/" /root/.bashrc
  26. echo ''syntax on'' > /root/.vimrc
  27. #zh_cn
  28. sed -i -e ''s/^LANG=.*/LANG="zh_CN.UTF-8"/'' /etc/sysconfig/i18n
  29. # configure file max to 52100
  30. echo "* soft nofile 52100
  31. * soft nofile 52100" >> /etc/security/limits.conf
  32. #tunoff services
  33. #--------------------------------------------------------------------------------
  34. cat << EOF
  35. --------------------------------------------------------------
  36. | === Welcome to Tunoff services === |
  37. --------------------------------------------------------------
  38. EOF
  39. #---------------------------------------------------------------------------------
  40. for i in `ls /etc/rc3.d/S*`
  41. do
  42. CURSRV=`echo $i|cut -c 15-`
  43. echo $CURSRV
  44. case $CURSRV in
  45. crond | irqbalance | microcode_ctl | network | random | sendmail | sshd | syslog | local | mysqld )
  46. echo "Base services, Skip!"
  47. ;;
  48. *)
  49. echo "change $CURSRV to off"
  50. chkconfig --level 235 $CURSRV off
  51. service $CURSRV stop
  52. ;;
  53. esac
  54. done
  55. rm -rf /etc/sysctl.conf
  56. echo "net.ipv4.ip_forward = 0
  57. net.ipv4.conf.default.rp_filter = 1
  58. net.ipv4.conf.default.accept_source_route = 0
  59. kernel.sysrq = 0
  60. kernel.core_uses_pid = 1
  61. net.ipv4.tcp_syncookies = 1
  62. kernel.msgmnb = 65536
  63. kernel.msgmax = 65536
  64. kernel.shmmax = 68719476736
  65. kernel.shmall = 134217728
  66. net.ipv4.ip_local_port_range = 1024 65536
  67. net.core.rmem_max = 16777216
  68. net.core.wmem_max = 16777216
  69. net.ipv4.tcp_rmem = 4096 87380 16777216
  70. net.ipv4.tcp_wmem = 4096 65536 16777216
  71. net.ipv4.tcp_fin_timeout = 3
  72. net.ipv4.tcp_tw_recycle = 1
  73. net.core.netdev_max_backlog = 30000
  74. net.ipv4.tcp_no_metrics_save = 1
  75. net.core.somaxconn = 262144
  76. net.ipv4.tcp_syncookies = 0
  77. net.ipv4.tcp_max_orphans = 262144
  78. net.ipv4.tcp_max_syn_backlog = 262144
  79. net.ipv4.tcp_synack_retries = 2
  80. net.ipv4.tcp_syn_retries = 2
  81. vm.swappiness = 3" >> /etc/sysctl.conf
  82. echo "optimizited kernel configure was done!"

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号