1 / 23

第 10 章

第 10 章. 常用系统管理技术. 本章内容. 监测系统性能 进程管理 实现进程自动化 系统备份和恢复. 10.1 系统监测. 用户监测 系统信息查看 性能监测 优化系统性能. 10.1.1 用户监测. 列出系统上登录的用户: who 查看用户执行的进程: w 查看历史登录信息: last. 10.1.2 系统信息查看. 了解 proc 文件系统 查看 /proc 目录中的文件 使用图形化工具: 主菜单中选择 【 系统工具 】|【 系统监视器 】. 10.1.3 性能监测. CPU 性能监测: sar mpstat

nolen
Download Presentation

第 10 章

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第10章 常用系统管理技术

  2. 本章内容 • 监测系统性能 • 进程管理 • 实现进程自动化 • 系统备份和恢复

  3. 10.1 系统监测 • 用户监测 • 系统信息查看 • 性能监测 • 优化系统性能

  4. 10.1.1 用户监测 • 列出系统上登录的用户: • who • 查看用户执行的进程: • w • 查看历史登录信息: • last

  5. 10.1.2 系统信息查看 • 了解proc文件系统 • 查看/proc目录中的文件 • 使用图形化工具: • 主菜单中选择【系统工具】|【系统监视器】

  6. 10.1.3 性能监测 • CPU性能监测: • sar • mpstat • 内存使用情况: • free • vmstat • 磁盘性能情况: • iostat

  7. 命令实例 • free命令实例 # free total used free shared buffers cached Mem: 109896 106660 3236 0 7868 65888 -/+ buffers/cache: 32904 76992 Swap: 192740 9068 183672 • iostat命令实例 # iostat Linux 2.4.20-8 (Linux-server) 2005年08月14日  avg-cpu: %user %nice %sys %idle 0.69 0.00 0.19 99.12  Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn dev3-0 0.91 8.33 9.04 2214616 2401722

  8. 10.1.4 优化系统性能 • 硬件配置的提高对性能的影响往往是立竿见影的 • 有时考虑到有限的财务预算,只能通过对原有系统的调整来优化系统的性能 • 优化系统性能的基本步骤可以归纳为: • 使用监测工具监视系统的活动; • 分析得到的性能数据,找出不能满足性能要求的环节; • 分析造成性能降低的原因,采取相应的优化措施。

  9. 10.2 进程管理 • 监视进程 • 调整进程运行

  10. 10.2.1 监测进程 • 使用ps命令 • ps –aux • ps -ef • 使用pstree命令 • 使用X Window中的系统监视器

  11. 使用top命令 11:19:30 up 3 days, 1:43, 2 users, load average: 0.00, 0.00, 0.00 41 processes: 39 sleeping, 2 running, 0 zombie, 0 stopped CPU states: 0.1% user 0.0% system 0.0% nice 0.0% iowait 99.8% idle Mem: 109896k av, 104060k used, 5836k free, 0k shrd, 7508k buff 72352k actv, 336k in_d, 760k in_c Swap: 192740k av, 26176k used, 166564k free 76644k cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 24432 root 15 0 1124 1124 852 R 0.1 1.0 0:00 0 top 1 root 15 0 104 76 56 S 0.0 0.0 0:04 0 init 2 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 keventd 3 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 kapmd 4 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 ksoftirqd_CPU0 9 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 bdflush

  12. 10.2.2 调整进程运行 • 关闭进程: • kill • 调整优先级: • nice • renice • 在后台运行进程: • command & • Ctrl+Z • jobs • bg fg

  13. 10.3 实现进程自动化 • Linux中的任务计划工具 • 使用crond建立任务计划 • 使用at、batch工具

  14. 10.3.1 Linux中的任务计划工具 • Linux中的任务计划工具: • crond:周期性作业 • atd:一次性作业 • batch:系统负载低于0.8时执行作业

  15. 10.3.2 使用cron建立任务计划 • 检查crond服务运行状态: • service crond status • 考察crond服务配置文件: # cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly

  16. 10.3.2 使用cron建立任务计划 • 使用crontab命令编辑任务计划 • 命令格式: • rontab [-u user] { -e | -l | -r } • 选项含义: • -e:编辑某个用户的cron服务 • -l:列出某个用户cron服务的详细内容 • -r:删除没个用户的cron服务 • Note: 重点理解crontab配置中关于时间的定义

  17. 10.3.3 使用at、batch工具 • at命令与cron不同的地方在于,at命令要在某一指定时间内调度一项一次性作业 • 实例: # at 23:53 warning: commands will be executed using (in order) a) $SHELL b) login shell c) /bin/sh at> ping 192.168.0.1 at> <EOT>(Ctrl+d) job 1 at 2005-09-06 23:53 # atq 1 2005-09-06 23:53 a root # atrm 2 # atq

  18. 10.4 系统备份与恢复 • 需要备份的内容 • 备份介质 • 备份策略 • 备份工具

  19. 10.4.1 需要备份的内容 • 备份需要花费一定的人力和财力,如何在备份所取得的收益与备份消耗的资源上做一个权衡是管理工作者需要考虑的一个问题 • 系统的/etc、/var、/home、/root、/bin、/sbin等目录通常是备份的重点对象 • /proc、/tmp、/dev通常不需要备份

  20. 10.4.2 备份介质 • 常用备份介质: • 软盘:只能备份少量数据,已不再使用 • 光盘:可以备份几百MB到十几GB的数据 • 活动硬盘:容量大,存取速度快 • 磁带:容量大,价格低廉

  21. 10.4.3 备份策略 • 完全备份 • 增量备份 • 差异备份

  22. 10.4.4 备份工具 • 光盘备份: • mkisofs • cdrecorder • dump工具 • # dump 0f /dev/nst0 /boot • # dump 1f /dev/nst0 /boot • # dump 2f /dev/nst0 /boot • 使用restore命令从dump备份中恢复数据

  23. 本章小结 • 掌握常用系统监测命令 • 熟练掌握常用进程查看和进程管理命令 • 熟练掌握crontab任务管理工具 • 掌握常用备份工具

More Related