Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1749962
  • 博文数量: 117
  • 博客积分: 2559
  • 博客等级: 少校
  • 技术积分: 4385
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-13 20:08
个人简介

作为初学者,要想取得进步,成为高手,首先应该了解自己的不足之处.

文章分类

全部博文(117)

文章存档

2014年(1)

2013年(25)

2012年(13)

2011年(77)

2010年(1)

分类: 系统运维

2013-07-25 23:53:49

很简单的脚本(dbc.sh),供参考参考


  1. #!/bin/bash
  2. # ########################################################################
  3. # License: GPL
  4. # Authors:
  5. # ########################################################################
  6. usage() {
  7. cat << EOF
  8. 新手指南:
  9. 1. 用于DBA数据库初始化检查
  10. 2. 脚本必须用root权限执行
  11. sudo $(basename $0)
  12. 3. 被检查的系统必须是CentOS 
  13. EOF
  14. #
  15. # 判断sudo权限
  16. #
  17. if [ $USER != "root" ]; then
  18. echo "请用root用户执行"
  19. exit
  20. fi
  21. #
  22. # ops 安装的系统是 CentOS 
  23. #
  24. if [ -e "/usr/bin/lsb_release" ]; then
  25. rele=$(lsb_release -r|gawk '{print $2}')
  26. if [ "$rele" != '6.2' ]; then
  27. echo "# Current system is not CentOS 6.2 "
  28. exit
  29. fi
  30. else
  31. echo "# No lsb_release modules are available."
  32. echo "$ sudo yum install lsb"
  33. exit
  34. fi
  35. #
  36. read -p "Are you sure (yes/no): " sure
  37. if [ "$sure" != 'yes' ]; then
  38. echo "# The script is exist."
  39. exit
  40. fi
  41. }
  42. # call
  43. usage
  44. setup_deppack() {
  45. cat << EOF
  46. #==============================================================================
  47. # 安装依赖包:
  48. # mysql-mmm
  49. # git
  50. #==============================================================================
  51. EOF
  52. # 清除本地的rpm包,更新本地缓存
  53. yum clean all
  54. yum makecache
  55. # 安装mysql-mmm依赖
  56. # 注意,参数选项不能写在一起(probably due to merging: -yq != -y -q)
  57. yum -y -q install coreutils iproute perl-Algorithm-Diff perl-Class-Singleton perl-DBD-MySQL perl-DBI perl-Log-Log4perl perl-Net-ARP perl-Path-Class perl-Proc-Daemon perl-Time-HiRes
  58. # 安装git
  59. yum -y -q install git
  60. }
  61. # call
  62. setup_deppack
  63. sleep 1
  64. setup_system() {
  65. cat << EOF
  66. #==============================================================================
  67. # 系统配置
  68. # ulimit
  69. # sysctl
  70. #==============================================================================
  71. EOF
  72. #set ulimit
  73. openfiles=$(ulimit -n)
  74. maxusers=$(ulimit -u)
  75. if [ "$openfiles" -lt "60000" ]; then
  76. echo "* soft nofile 65536" >> /etc/security/limits.conf
  77. echo "* hard nofile 65536" >> /etc/security/limits.conf
  78. if [ "$maxusers" -lt "60000" ]; then
  79. echo "* soft nproc 65536" >> /etc/security/limits.d/90-nproc.conf
  80. fi
  81. fi
  82. #set sysctl
  83. /sbin/sysctl -w vm.swappiness=0 > /dev/null
  84. #write sysctl.conf
  85. echo "vm.swappiness = 0" >> /etc/sysctl.conf
  86. #set secure
  87. #sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
  88. #grep 'SELINUX' /etc/selinux/config
  89. }
  90. # call
  91. setup_system
  92. sleep 1
  93. setup_display() {
  94. cat << EOF
  95. #==============================================================================
  96. # The results show
  97. #==============================================================================
  98. EOF
  99. #
  100. echo "open files: "$(ulimit -n)
  101. echo "max user processes: "$(ulimit -u)
  102. echo $(/sbin/sysctl vm.swappiness)
  103. }
  104. # call
  105. setup_display





阅读(2284) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~