Chinaunix首页 | 论坛 | 博客
  • 博客访问: 50263
  • 博文数量: 4
  • 博客积分: 75
  • 博客等级: 民兵
  • 技术积分: 67
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-17 00:23
文章分类

全部博文(4)

文章存档

2016年(1)

2013年(2)

2012年(1)

我的朋友

分类: 系统运维

2013-03-15 10:44:51

文中的xxx.xxx.xxx.xxx 表示某一个ip

点击(此处)折叠或打开

  1. 1 ifconfig
  2. 装完发现网络不通,查看IP
  3. 2 ping xxx.xxx.xxx.xxx
  4. ping自己,能通,网卡没问题。
  5. 3 netstat -rn
  6. 看路由信息,网关写错了。
  7. 4 setup
  8. 用setup修改网络配置
  9. 5 netstat -rn
  10. 6 service network restart
  11. 改好,重启网络服务,网络ok了。
  12. 7 exit
  13. 退出。 以上操作是在本地控制台做的,期间还修改了时间服务器(NTP)。
  14. 8 passwd
  15. 修改root的密码
  16. 9 last -10
  17. 习惯的看看,最后10个登录系统的记录。(这是一个神经质的操作)
  18. 10 date
  19. 11 date
  20. 看了两下服务器的时间,看看是不是时间改准了
  21. 12 ping ntp.google.com
  22. 13 ping time.google.com
  23. 看看google有没有提供NTP服务,发现没有。
  24. 14 ping ntp.nasa.gov
  25. 嗯。美国宇航局有提供NTP服务,真好!
  26. 15 vim /etc/ntp.conf
  27. 看看NTP服务的配置,之前在安装系统时已经加了一堆可以用的NTP服务器了,NASA的就不加了。
  28. 16 who
  29. 看看服务器上有什么人在(这又是一个神经质的操作,明明是新装的系统,有别人在就有鬼了!)
  30. 17 vim /etc/ssh/sshd_config
  31. 修改ssh服务器的配置,修改:“PermitRootLogin no ”限制root通过ssh登录系统。
  32. 18 service sshd restart
  33. 重启ssh服务使改动生效。
  34. 19 su - chz
  35. 切换回自己的用户,用自己的用户去别的服务器拖一些安装文件回来。
  36. 20 vim /etc/security/limits.conf
  37. 准备去修改文件句柄数
  38. 21 vim /etc/ssh/sshd_config
  39. 神经质的又去看了一下sshd的配置文件。
  40. 22 vim /etc/security/limits.conf
  41. 在文件后增加
  42. * hard nofile 65535
  43. * soft nofile 65535
  44. 改大文件句柄数。
  45. 23 ulimit -a
  46. 看看最大文件句柄数是否生效了。这时看肯定没生效的,因为已经这个登录的环境变量是从没修改过的环境中继承来的。
  47. 24 exit
  48. 25 ulimit -a
  49. 可以看到:open files (-n) 65535
  50. 退出,重新登录进来看到已经生效了。确认修改成功。
  51. 26 vim /etc/sysconfig/network
  52. 27 vim /etc/hosts
  53. 去这两个地方看看主机名是不是已经叫QE了,还可以用hostname命令看和修改主机名的,主机名不弄好系统就不好看了!
  54. 28 su - chz
  55. 切换回自己的用户,去折腾那些拖过来的文件(DenyHosts-2.6.tar.gz,nagios-plugins-1.4.15.tar.gz,nrpe-2.13.tar.gz,tsar-2.1.0.tar.gz)。
  56. 29 cd ~chz/
  57. 又变成root回来,进入自己的目录准备安装软件
  58. 30 ls
  59. 查看目录文件(手贱,其实不看也知道的。)
  60. # 开始安装tsar,淘宝公司的开源产品,用于记录服务器资源使用情况的。
  61. 31 tar zxvf tsar-2.1.0.tar.gz
  62. 解压
  63. 32 cd tsar-2.1.0
  64. 进入
  65. 33 ./configure
  66. 编译准备(编译检查)
  67. 34 make
  68. 编译
  69. 35 make install
  70. 安装
  71. 36 ls
  72. 列出当前目录文件,手贱!
  73. 37 tsar -l -i 1
  74. 用tsar的live模式看看tsar是否安装成功。
  75. # tsar安装完成,它自动会运行在cron的模式。
  76. 38 cd ..
  77. 退回上一层目录
  78. # 安装DenyHosts,用于防止暴力破解ssh密码的。
  79. 39 tar zxvf DenyHosts-2.6.tar.gz
  80. 40 cd DenyHosts-2.6
  81. 41 python -V
  82. 查看python的版本,其实不用看也知道的……
  83. 42 python setup.py install
  84. 安装,这玩意是用Python写的,所以要用python的命令安装
  85. 43 cd /usr/share/denyhosts/
  86. 进入安装的路径
  87. 44 mv daemon-control-dist daemon-control
  88. 修改守护进程控制文件的名字
  89. 45 mv denyhosts.cfg-dist denyhosts.cfg
  90. 修改配置文件的名字
  91. 46 vim denyhosts.cfg
  92. 编辑配置文件
  93. 修改PURGE_DENY = 1h,意思就是将非法的IP加入/etc/hosts.deny,1小时后才移除。
  94. 何为非法的IP,请看配置文件的注释。
  95. 47 chmod 700 daemon-control
  96. 修改控制文件只为root所有
  97. 48 cd /etc/init.d/
  98. 进入系统服务目录,这里没的脚本都是可以作为系统服务运作的,即service xxx start什么的都是在这里的
  99. 49 ln -s /usr/share/denyhosts/daemon-control denyhosts
  100. 在/etc/init.d/创建控制文件的链接
  101. 50 chkconfig --add denyhosts
  102. 将denyhost加入到系统服务中
  103. 51 service denyhosts start
  104. 启动denyhost服务
  105. 52 tail -f /var/log/denyhosts
  106. 查看Denyhosts的日志,确认它已经启动成功。
  107. # DenyHosts安装完成
  108. 53 cd ~chz/
  109. 进入我的主目录
  110. #安装Nagios的NRPE端
  111. 54 tar -zxvf nagios-plugins-1.4.15.tar.gz
  112. 55 tar zxvf nrpe-2.13.tar.gz
  113. 56 useradd -M nagios
  114. 增加用于Nagios的系统用户nagios -M参数是不创建该用户home目录的
  115. 57 cd nagios-plugins-1.4.15
  116. 58 make clean
  117. 手贱
  118. 59 ./configure --prefix=/usr/local/nagios/ --enable-redhat-pthread-workaround
  119. 编译准备,redhat的有点特别,要加多个参数的
  120. 60 make;make install
  121. 编译安装
  122. 61 chown nagios:nagios /usr/local/nagios
  123. 62 chown -R nagios:nagios /usr/local/nagios/libexec
  124. 修改一些目录的所有者
  125. 63 cd ../nrpe-2.13
  126. 64 ./configure
  127. 65 make all
  128. 66 make install-plugin
  129. 67 make install-daemon
  130. 68 make install-daemon-config
  131. 69 make install-xinetd
  132. NRPE是编译后按需安装的,看字眼就知道装来什么插件进去。
  133. 70 vim /etc/services
  134. 修改系统服务列表,给NRPE和它的端口加个名字。
  135. 71 cd /usr/local/nagios/libexec/
  136. 72 scp chz@xxx.xxx.xxx.xxx:/usr/local/nagios/libexec/mem.sh ./
  137. 去231拖一个自己写的内存监控脚本过来。
  138. 73 chown nagios:nagios mem.sh
  139. 把mem.sh这个脚本的所有权给nagios
  140. 74 ll
  141. 75 vim ../etc/nrpe.cfg
  142. 修改nrpe配置文件,增加以下配置。根据实际情况监控的内容可能有所不同
  143. command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10 # 监控系统用户的
  144. command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20 # 监控系统负载的
  145. command[check_root_partition]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p / # 监控 / 挂载的硬盘的使用容量的
  146. command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z # 监控僵尸进程的
  147. command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 350 -c 500 # 监控系统总进程数的
  148. command[check_http]=/usr/local/nagios/libexec/check_http -I 127.0.0.1 # 监控系统http服务的,默认只监控80端口
  149. command[check_memory]=/usr/local/nagios/libexec/mem.sh # 监控系统内存使用情况的
  150. 76 service xinetd restart
  151. 重启xinetd服务,因为nrpe的服务是绑定在xinetd的
  152. 77 netstat -an|grep 5666
  153. 查看5666端口是否有打开,有打开nrpe就跑起来了。
  154. 78 vim /etc/xinetd.d/nrpe
  155. 刚才忘了修改nrpe这个服务的访问权限,现在修改:only_from = xxx.xxx.xxx.xxx 允许公司某个ip的nagios连接过来检查服务器运行情况
  156. 79 service xinetd restart
  157. 修改后重启
  158. # Nagios的NRPE安装完成,要在公司的服务器上看到这个服务器的运行情况,需要在该服务器在做一些配置。
  159. 80 useradd a_new_user
  160. 给给同事添加一个帐号
  161. 81 passwd a_new_user
  162. 为a_new_user设置初始密码
  163. 82 reboot
  164. 重启系统,看看重启后一切是否自动正常。
  165. 83 ulimit -a
  166. 最大句柄数 OK
  167. 84 last -10
  168. 又神经质的看了一下最后10个登录记录(其实通过这个命令还可以看到系统重启的时间)
  169. 85 tail -20 /var/log/denyhosts
  170. 查看denyhost的日志
  171. 86 ps aux|grep denyhosts
  172. 看看denyhost的进程是否在,嗯,它在。
  173. 87 df -h
  174. 查看硬盘容量
  175. 88 tsar
  176. 查看tsar收集的数据
  177. 89 history > ~chz/what.txt
  178. 导出操作历史用于制作本记录

  以上就是一个新系统安装完成后我干了些什么事情。主要有:
   1.配置网络并保障网络正常
   2.配置服务器时间
   3.修改掉root的ssh权限
   4.修改系统支持的最大句柄数
   5.安装软件防止通过ssh暴力破解系统密码
   6.安装软件记录系统资源使用情况
   7.将服务器运行情况进行集中管理

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