Solaris Run States Introduction

.!.

divx 007 from russia with love Solaris运行级别表示系统的运行状态,每个level具体运行哪些服务和进程是由/etc/rc#.d目录下面的脚本决定的。举例来说,在有SunCluster的RAC环境下,对Oracle UDLM (ORCLudlm) 进行升级就需要先进入单用户模式,卸载老的ORCLudlm,然后安装新版本。 这个时候就需要boot -s
默认的服务的运行级别列表如下:

* 0: The system is at the PROM monitor (ok>) or security monitor (>) prompt. It is safe to shut down the system when it is at this init state.
* 1, s or S: This state is known as “single-user” or “system administrator” mode. Root is the only user on the system, and only basic kernel functions are enabled. A limited number of filesystems (usually only root and /usr) are mounted. This init state is often used for sensitive functions (such as kernel libc patches) or while troubleshooting a problem that is keeping the system from booting into multiuser mode.
* 2: Multiple users can log in. Most system services (except for NFS server and printer resource sharing) are enabled.
* 3: Normal operating state. NFS and printer sharing is enabled, where appropriate.
* 4: Usually undefined.
* 5: Associated with the boot -a command. The system is taken to init 0 and an interactive boot is started.
* 6: Reboot. This state takes the system to init state 0 and then to the default init state (usually 3, but can be redefined in the /etc/inittab file).

The init states are defined in the /etc/inittab file, which usually points at the scripts in /sbin/rcrun-level. These scripts in turn examine the contents of the /etc/rcrun-level directories. The scripts in these directories whose names begin with the letter K are run in “stop” mode first in alphabetical order. Then the scripts whose names begin with the letter S are run in “start” mode in alphabetical order.

To get to a desired run level n, each of the rc (run control) scripts from 1 to n is run. To get to run level 0, the K scripts are run in each rc#.d directory between the current run level and 0 in reverse numerical order.

In the default configuration, the rc scripts accomplish the following tasks:

* /sbin/rc0
o Stop system services/daemons.
o Terminate running processes.
o Unmount all file systems.
* /sbin/rc1
o Stop system services/daemons.
o Terminate running processes.
o Unmount all file systems.
o Bring up the system in single-user mode.
* /sbin/rc2
o Set the TIMEZONE variable.
o Stop the print and NFS services.
o Stop the vold daemon.
o Mount local filesystems, enable disk quotas (as appropriate).
o Remove temporary files.
o Create new device entries if this is the result of a boot -r.
o Save a core file if enabled.
o Configure system accounting, (as appropriate).
o Set the default router.
o Set the NIS domain.
o Set up the network interfaces appropriately.
o Start inetd.
o Start named, if appopriate.
o Start rpcbind.
o Start kerbd (the Kerberos client daemon) if appropriate.
o Start ypbind or rpc.nisd as appropriate.
o Start keyserv.
o Start statd and lockd.
o Mount NFS filesystems from /etc/vfstab.
o Start the automounter.
o Start cron.
o Start lp daemons, as appropriate.
o Start sendmail.
* /sbin/rc3
o Clean up sharetab.
o Start nfsd and mountd.
o Start rarpd and rpc.bootparamd, as appropriate.
* /sbin/rc4 is usually not defined. It can be used in a non-default configuration to achieve a tailored run level.
* /sbin/rc5
o Kill print daemons.
o Unmount local file systems.
o Kill syslogd.
o Unmount NFS file systems.
o Stop NFS services.
o Stop NIS services.
o Stop RPC services.
o Stop cron services.
o Stop statd and lockd (NFS client services).
o Kill active processes.
o Initiate an interactive boot.
* /sbin/rc6
o Stop system services/daemons.
o Terminate running processes.
o Unmount all file systems.
o Boots to the initdefault level from the /etc/inittab
* /sbin/rcS: This run level differs from 1 in the following particulars:
o Minimal network is established.
o System name is set.
o root, /usr and /usr/kvm filesystems are checked and mounted (if necessary).
o Pseudo file systems proc and /dev/ are started.
o Rebuilds device entries (for reconfiguration reboots only).

Solaris Run level change
I need to find out runlevel related information, as you may need to change runlevel for following causes:

1. Halt/reboot system when shutdown command don’t work
2. Troubleshooting or repairing system

The first thing I noticed was /etc/inittab file is different from the Linux version. However, runlevel are quite identical

Default Solaris Run Level

* S : Single user state (useful for recovery)
* 0 : Access Sun Firmware ( ok> prompt)
* 1 : System administrator mode
* 2 : Multi-user w/o NFS
* 3 : Multi-user with NFS
* 4 : Unused
* 5 : Completely shutdown the host (like performing a power-off @ OBP) [ thanks to Marco ]
* 6 : Reboot but depend upon initdefault entry in /etc/inittab

Solaris Find out runlevel
To find out current runlevel use who command:

$ who -r
Output:

. run-level 3 Mar 3 14:04 3 0 S

Solaris changing runlevels after bootup
You need to use init command, for example change runlevel to 2.

# /sbin/init 2
Solaris changing the default runlevel
An entry with initdefault (in /etc/inittab file) is scanned only when init is initially invoked. init uses this entry to determine which run level to enter initially.

Open /etc/inittab file:

# vi /etc/inittab
Find out this entry:

is:3:initdefault:
Change is:3 to number you want, don’t use S, 0, 6 ;). Save file.

download resident evil dvd

This entry was posted in 主机 and tagged . Bookmark the permalink.

One Response to Solaris Run States Introduction

  1. Pingback: Solaris IPMP

Leave a Reply

Your email address will not be published. Required fields are marked *