Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1275541
  • 博文数量: 554
  • 博客积分: 10425
  • 博客等级: 上将
  • 技术积分: 7555
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-09 09:49
文章分类

全部博文(554)

文章存档

2012年(1)

2011年(1)

2009年(8)

2008年(544)

分类:

2008-04-15 13:31:23

5.2 系统的关闭

Solaris系统软件总处于连续运行状态,这样电子邮件和网络软件能正常地工作,但在以下几种情况下,系统却必须关闭或停止。

 准备更新电源;

 系统增加或删除硬件;

 进行系统维护,如备份。

5.2.1 关闭系统命令简单介绍
下面介绍关闭系统的命令,它们使用在不同的场合中,如表5-1所示。

表5-1 关闭系统命令介绍

命 令                        描 述                          什么时候使用

shutdown
是调用init程序来关闭系统的可运行shell脚本程序
推荐在服务器运行级别3时使用,因为要通知用户系统将要关闭

init
改变系统运行级别命令
推荐在单机时使用,或者关闭不影响其他用户时使用

reboot
重新启动系统
Init 6是首选的重新启动方法

Halt, poweroff
同步磁盘并停止处理器工作
不推荐使用,因为会强行终止系统进程。只有在紧急事件中才用


5.2.2 如何关闭服务器
服务器的一般运行级别是3,这时系统是多用户操作系统,也有NFS远程服务在运行。这就要求我们关闭服务器要小心,最好先查看一下用户的使用情况。查看谁在使用服务器的命令是who,如例5-1所示。

 例5-1 查看谁在使用服务器。

$ who

holly console May 7 07:30

kryten pts/0 May 7 07:35 (starlite)

lister pts/1 May 7 07:40 (bluemidget)

我们在前面已经介绍过,关闭服务器最好的方法是使用shutdown命令,因为它会给在线用户一个通知。下面我们就介绍几个例子供大家参考。

 例5-2 SPARC:在180秒后切换系统到单用户状态。

# shutdown -g180 –y

Shutdown started. Mon Jun 14 15:46:16 MDT 2005

Broadcast Message from root (pts/4) on venus Mon Jun 14 15:46:16...

The system venus will be shut down in 3 minutes.






Broadcast Message from root (pts/4) on venus Mon Jun 14 15:46:16...

The system venus will be shut down in 30 seconds .






INIT: New run level: S

The system is coming down for administration. Please wait.

Unmounting remote filesystems: /vol nfs done.

Shutting down Solaris Management Console server on port 898.

Print services stopped.

Jun 14 15:49:00 venus syslogd: going down on signal 15

Killing user processes: done.

Requesting System Maintenance Mode

SINGLE USER MODE

Root password for system maintenance (control-d to bypass): xxxxxx

single-user privilege assigned to /dev/console.

Entering System Maintenance Mode

#

 例5-3 SPARC:在300秒后切换系统到可以关闭电源的运行级0。

# shutdown -i0 -g300 –y

Shutdown started. Thu Jun 17 12:40:25 MST 2005

Broadcast Message from root (console) on pretend Thu Jun 17 12:40:25...

The system pretend will be shut down in 5 minutes









Changing to init state 0 - please wait

#

INIT: New run level: 0

The system is coming down. Please wait.

System services are now being stopped.









The system is down.

syncing file systems... done

Program terminated

Type help for more information

ok

 例5-4 在120秒后重新启动系统。

# shutdown -i6 -g120 -y

Shutdown started. Mon Jun 14 15:46:16 MDT 2005

Broadcast Message from root (pts/4) on venus Mon Jun 14 15:46:16...

The system venus will be shut down in 2 minutes

Changing to init state 6 - please wait

#

INIT: New run level: 6

The system is coming down. Please wait.









The system is down.

syncing file systems... done

rebooting...









venus console login:

Regardless of why you shut dow

5.2.3 如何关闭单用户计算机
关闭单用户计算机系统比较简单,我们可以用init命令切换系统运行级。常用Solaris 10运行级别如表5-2所示。

表5-2 Solaris 10常用运行级别

运行级别
SPARC平台提示符
x86平台提示符

S(单用户级)
#
#

2(多用户级)
#
#

0(可关闭电源级)
Ok或者 >
按任意键重新启动

3(多用户和NFS服务)
hostname console login:
hostname console login:


 例5-5 在x86平台上将系统切换到运行级0。

# init 0

#

INIT: New run level: 0

The system is coming down. Please wait.



The system is down.

syncing file systems... [11] [10] [3] done

Press any key to reboot
阅读(558) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~