linux常用系统管理经验谈

2020-01-30 11:17:39刘景俊

8. 确认/boot下初始的虚拟盘镜像中包含了必要的ext3模块和jbd日志模块。如果/data是你的机器上的第一个ext3文件系统,很可能initrd中并不包含这些模块。这种情况只当我们需要ext3的支持而在initrd中又不包括相关的模块时非常重要。假设出现了这种情况,我们可以制作一个/boot/initrd-<version>.img文件:
mkinitrd –f –v /boot/initrd-$(uname –r).img $(uname –r)
9. 键入sync,然后手动重启动系统。
10. 观察启动过程。系统检查了哪个文件系统?在/data文件系统,是否看到了“recovering journal”提示信息?当不正常重启时,使用ext3的日志恢复是否比ext2的fsck快了?

步骤三:使用autofs自动加载系统
1. 确认iptables已经关闭
2. 编辑/etc/auto.master文件,去掉对/misc一行的注释
3. 在/etc/auto.misc文件中增加一行,用于加载server1.example.com的/var/ftp/pub目录到本机的目的/server1. 可以参考ftp.example.com行的示例.
4. 重启autofs服务 service autofs restart
5. 测试/misc/server1目录


Lab 3 管理启动
目标: 定制系统服务的技巧

步骤一: 使用chkconfig禁用服务
1. 使用chkconfig检查系统服务的状态: chkconfig --list
2. 使用以下示例将isdn在所有runlevel关闭
chkconfig --del <service name>
3. 使用--help 查看chkconfig语法信息 chkconfig --help. 关闭runlevel3和runlevel5的kudzu服务
4. 观察 on 和 --add 的差异, off 和 --de 的差异
chkconfig isdn --list
chkconfig isdn on
chkconfig isdn --list
chkconfig isdn off
chkconfig isdn --list
chkconfig isdn --del
chkconfig isdn --list
chkconfig isdn --add
chkconfig isdn --list
5. 使用chkconfig查看系统服务的状态和改变状态

步骤二: 更改系统登录标题
1. 我们将设置rc.local脚本用于每次重启时出现登录标题. 打开/etc/rc.local文件找到以下行:
touch /var/lock/subsys/local
2. 在后面插入以下行:
echo “ Welcome to n” > /etc/issue
echo “All access to this computer is monitored” >> /etc/issue
echo “Unauthorized access is prohibited” >> /etc/issue
echo >> /etc/issue
echo “Last reboot complete at $(/bin/date)” >> /etc/issue
3. 保存文件,把/etc/issue复制为/etc/issue.orig
4. 重启动系统
5. 当系统启动后,切换到虚拟控制台确认登录标题出现了. 打开/etc/issue, 注意mingetty把n扩展为你的主机名

步骤三: 更改默认runlevel
1. 编辑/etc/inittab文件,将默认runlevel从5改为3,如下:
id:3:initdefault:
2. 重启动系统.发生了什么?
3. 把默认runlevel改为5,重启动系统

步骤四: 增加当天的消息
1. 编辑/etc/motd文件,默认应为空. 增加以下行: