Saturday, January 30, 2010

Run Levels for Various Unices

From Wikipedia Page, The term runlevel refers to a mode of operation in one of the computer operating systems that implement Unix System V-style initialization. Conventionally, seven runlevels exist, numbered from zero to six; though up to ten, from zero to nine, may be used. S is sometimes used as a synonym for one of the levels.

In standard practice, when a computer enters runlevel zero, it halts, and when it enters runlevel six, it reboots. The intermediate runlevels (1-5) differ in terms of which drives are mounted, and which network services are started. Lower run levels are useful for maintenance or emergency repairs, since they usually don’t offer any network services at all. The particular details of runlevel configuration differ widely among operating systems, and slightly among system administrators.

The runlevel system replaced the traditional /etc/rc script used in Version 7 Unix.

Run Levels in Solaris
S, s
Single user mode. Doesn’t require properly formated /etc/inittab. Filesystems required for basic system operation are mounted.

0
Go into firmware (sparc)

1
System Administrator mode. All local filesystems are mounted. Small set of essential system processes are running. Also a single user mode.

2
Put the system in multi-user mode. All multi-user environment terminal processes and daemons are spawned.

3
Extend multi-user mode by making local resources available over the network.

4
Is available to be defined as an alternative multi-user environment configuration. It is not necessary for system operation and is usually not used.

5
Shut the machine down so that it is safe to remove the power. Have the machine remove power, if possible.

6
Reboot

a, b, c
Process only those /etc/inittab entries having the a, b, or c run level set. These are pseudo-states, which may be defined to run certain commands, but which do not cause the current run level to change.

Q, q
Re-examine /etc/inittab.

Run Levels in HP-UX
0
System is completely shut down. All processes are terminated and all file systems are unmounted.

1,s,S
Single-user mode. All system services and daemons are terminated and all file systems are unmounted.

2

Multi-user mode, except NFS is not enabled.

3
Multi-user mode. This is the normal operational default state. NFS is enabled.

4
Multi-user mode with NFS and VUE. (VUE is HP’s desktop, kinda like CDE)

6
Reboot.

Run Levels in OpenBSD
-1
Permanently insecure mode – always run system in level 0 mode.

0
Insecure mode – immutable and append-only flags may be changed. All devices may be read or written subject to their permissions.

1
Secure mode – system immutable and append-only flags may not be turned off; disks for mounted filesystems, /dev/mem, and /dev/kmem are read-only.

2
Highly secure mode – same as secure mode, plus disks are always read-only whether mounted or not and the settimeofday(2) system call can only advance the time.

Run Levels in ULTRIX, Digital UNIX / Tru64
0
System is completely shut down. All processes are terminated and all file systems are unmounted.

1
Single-user mode. All system services and daemons are terminated and all file systems are unmounted.

2
Multi-user mode, except NFS is not enabled.

3
Multi-user mode. This is the normal operational default state. NFS is enabled.

4
Not Used

5
Not Used

6
Reboot

Run Levels in Irix
0
Shut the machine down so it is safe to remove the power. Have the machine remove power if it can.

1
Put the system into system administrator mode. All filesystems are mounted. Only a small set of essential kernel processes run. This mode is for administrative tasks such as installing optional utilities packages. All files are accessible and no users are logged in on the system.

2
Put the system into multi-user state. All multi-user environment terminal processes and daemons are spawned. Default.

3
Start the remote file sharing processes and daemons. Mount and advertise remote resources. Run level 3 extends multi-user mode and is known as the remote-file-sharing state.

4
Define a configuration for an alternative multi-user environment. This state is not necessary for normal system operations; it is usually not used.

5
Stop the IRIX system and enter firmware mode.

6

Stop the IRIX system and reboot to the state defined by the initdefault entry in inittab.

a,b,c
Process only those inittab entries for which the run level is set to a, b, or c. These are pseudo-states that can be defined to run certain commands but do not cause the current run level to change.

Q,q
Re-examine inittab.

S,s
Enter single-user mode. When the system changes to this state as the result of a command, the terminal from which the command was executed becomes the system console.

Run Levels in SYSV
The following is from a SYSV text book, it’s the generally used run level for SYSV systems.

0
Power-down state. Shuts machine down gracefully so that it can be turned off. Some models turn off automatically.

s
Single user state. This run level should be used when installing or removing software utilities, checking file systems, or using Maintenance (/install) file system. It is similar to run level 1; however, in run level s, multi-user file systems are unmounted and daemons are stopped. The terminal issuing the init s becomes the console.

1
Administrative state. In run level 1, file systems required for multi-user operations are mounted. And loggias requiring access to multi-user file systems can be used.

2
Multi-user state. File systems are mounted and normal user services are started.

3
Network File System (NFS) state. Prepares your system to use NFS.

4
User-defined

5
Virtually the same as System State 6. See /sbin/rc0 script for details. Early versions of UNIX used this as an entry to a firmware interface.

6
Power-down and reboot to the state defined by the initdefault entry in the /etc/inittab file.

Run Levels in Linux
0
Halt the system.

1
Single-user mode.

2-4
Multi-user modes. Usually identical. Level 2 or 3 is default (dependent on distro).

5
Multi-user with graphical environment. This applies to most (but not all) distros.

6
Reboot the system and return to default run level.

Replace disk on SVM

bash-3.00# metadb

flags first blk block count

a m p luo 16 8192 /dev/dsk/c0d0s7

a p luo 8208 8192 /dev/dsk/c0d0s7

a p luo 16400 8192 /dev/dsk/c0d0s7

a p luo 16 8192 /dev/dsk/c0d1s7

a p luo 8208 8192 /dev/dsk/c0d1s7

a p luo 16400 8192 /dev/dsk/c0d1s7

bash-3.00# format

Searching for disks…done

AVAILABLE DISK SELECTIONS:

0. c0d0

/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0

1. c0d1

/pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0

Specify disk (enter its number): ^D

bash-3.00# metastat -p

d3 -m d13 d23 1

d13 1 1 c0d0s3

d23 1 1 c0d1s3

d1 -m d11 d21 1

d11 1 1 c0d0s1

d21 1 1 c0d1s1

d0 -m d10 d20 1

d10 1 1 c0d0s0

d20 1 1 c0d1s0

bash-3.00# metastat

d3: Mirror

Submirror 0: d13

State: Okay

Submirror 1: d23

State: Okay

Pass: 1

Read option: roundrobin (default)

Write option: parallel (default)

Size: 6152895 blocks (2.9 GB)

d13: Submirror of d3

State: Okay

Size: 6152895 blocks (2.9 GB)

Stripe 0:

Device Start Block Dbase State Reloc Hot Spare

c0d0s3 0 No Okay Yes

d23: Submirror of d3

State: Okay

Size: 6152895 blocks (2.9 GB)

Stripe 0:

Device Start Block Dbase State Reloc Hot Spare

c0d1s3 0 No Okay Yes

d1: Mirror

Submirror 0: d11

State: Okay

Submirror 1: d21

State: Okay

Pass: 1

Read option: roundrobin (default)

Write option: parallel (default)

Size: 2104515 blocks (1.0 GB)

d11: Submirror of d1

State: Okay

Size: 2104515 blocks (1.0 GB)

Stripe 0:

Device Start Block Dbase State Reloc Hot Spare

c0d0s1 0 No Okay Yes

d21: Submirror of d1

State: Okay

Size: 2104515 blocks (1.0 GB)

Stripe 0:

Device Start Block Dbase State Reloc Hot Spare

c0d1s1 0 No Okay Yes

d0: Mirror

Submirror 0: d10

State: Okay

Submirror 1: d20

State: Okay

Pass: 1

Read option: roundrobin (default)

Write option: parallel (default)

Size: 16386300 blocks (7.8 GB)

d10: Submirror of d0

State: Okay

Size: 16386300 blocks (7.8 GB)

Stripe 0:

Device Start Block Dbase State Reloc Hot Spare

c0d0s0 0 No Okay Yes

d20: Submirror of d0

State: Okay

Size: 16386300 blocks (7.8 GB)

Stripe 0:

Device Start Block Dbase State Reloc Hot Spare

c0d1s0 0 No Okay Yes

Device Relocation Information:

Device Reloc Device ID

c0d1 Yes id1,cmdk@AVBOX_HARDDISK=VBff26b95e-f100ab63

c0d0 Yes id1,cmdk@AVBOX_HARDDISK=VB9296a814-953892af

bash-3.00#

—————————–

REPLACE DISK c0d0 – Test1

root@solaris10 # metastat -p

d3 -m d13 d23 1

d13 1 1 c0d0s3

d23 1 1 c0d1s3

d1 -m d11 d21 1

d11 1 1 c0d0s1

d21 1 1 c0d1s1

d0 -m d10 1

d10 1 1 c0d0s0

d20 1 1 c0d1s0

root@solaris10 #

—————————

root@solaris10 # metadetach -f d0 d20

d0: submirror d20 is detached

root@solaris10 # metadetach -f d1 d21

d1: submirror d21 is detached

root@solaris10 # metadetach -f d3 d23

d3: submirror d23 is detached

root@solaris10 # metaclear d20

d20: Concat/Stripe is cleared

root@solaris10 # metaclear d21

d21: Concat/Stripe is cleared

root@solaris10 # metaclear d23

d23: Concat/Stripe is cleared

root@solaris10 #

>>>>If there are any replicas on this disk, remove them using:

#metadb -d c#t#d#s#

>>>>>If there are any open filesystems on this disk (not under Solaris VM control),unmount them

>>>>>Run the ‘cfgadm’ command to remove the failed disk

#cfgadm -c unconfigure c#::dsk/c#t#d#

———–

root@solaris10 # metadb -a c1d1s7

———–

root@solaris10 # metainit d20 1 1 c1d1s0

d20: Concat/Stripe is setup

root@solaris10 # metainit d21 1 1 c1d1s1

d21: Concat/Stripe is setup

root@solaris10 # metainit d23 1 1 c1d1s3

d23: Concat/Stripe is setup

root@solaris10 #

======================================

More Investigation:

d3: Mirror (disk asli, partisi “/Home” 2,9GB)

d13: Submirror of d3 (database mirror di c0d0s3)

d23: Submirror of d3 (database mirror di c0d1s3)

d1: Mirror (disk asli, partisi “swap”, 1GB)

d11: Submirror of d1 (database mirror di c0d0s1)

d21: SUbmirror of d1 (database mirror di c0d1s1)

d0: Mirror (disk alsi, partisi “root, 7,8GB) >>Need Maintenance

d10: SUbmirror of d0 (database mirror di c0d0s0)

d20: Submirror of d0 (database mirror di c0d1s0) >>Need Maintenance

root@solaris10 # metastat -p

d3 -m d13 d23 1

d13 1 1 c0d0s3

d23 1 1 c0d1s3

d1 -m d11 d21 1

d11 1 1 c0d0s1

d21 1 1 c0d1s1

d0 -m d10 d20 1

d10 1 1 c0d0s0

d20 1 1 c0d1s0

root@solaris10 #

{Remove all submirror from disk c0d1 (d23, d21 and d20):

#metadetach d3 d23

#metaclear d23

#metadetach d1 d21

#metaclear d21

#metadetach d0 d20

#metaclear d20

Then, remove the database in c0d1s7:

#metadb -d c0d1s7

{replace with new disk, repartition again:

#prtvtoc /dev/rdsk/c0d0s2 |fmthard -s – /dev/rdsk/cd1s2

{then, run ‘metainit’ &’metattach’ to connect them with their submirror:

#metainit d23 1 1 c0d1s3

#metattach d3 d23

#metainit d21 1 1 c0d1s1

#metattach d1 d21

#metainit d20 1 1 c0d1s0

#metattach d0 d20

{Then create replica database:

#metadb -a -c 3 c0d1s7

{Last, if your Box is x86, run “installboot” command to new disk

{jika disk baru partisinya benar dan device namenya sama, command bisa dipersingkat menjadi:

#metareplace -e d23 c0d1s3

#metareplace -e d21 c0d1s1

#metareplace -e d20 c0d1s0

Solaris Link Aggregation

Link aggregation or IEEE 802.1AX-2008, is a computer networking term which describes using multiple network cables/ports in parallel to increase the link speed beyond the limits of any one single cable or port, and to increase the redundancy for higher availability.

Most implementations now conform to what used to be clause 43 of IEEE 802.3-2005 Ethernet standard, usually still referred to by its working group name of “IEEE 802.3ad”. The Link Aggregation definition has since been moved to a standalone IEEE 802.1AX standard. (wikipedia.org)

Here’s the sample of setup aggregation link between :

e1000g0 and e1000g1
e1000g2 and e1000g3

Make sure your eeprom’s local-mac-address? variable is set to true (you don’t need this for x86):

# eeprom local-mac-address?
local-mac-address=false

# eeprom local-mac-address? = true

# eeprom local-mac-address?
local-mac-address?=true

1. Unplumb the interfaces to be aggregated:
# ifconfig e1000g0 down unplumb
# ifconfig e1000g1 down unplumb
# ifconfig e1000g2 down unplumb
# ifconfig e1000g3 down unplumb

2. Create a link-aggregation group with key 1 and 2:

{format= dladm create-aggr -d

interface Represents the device name of the interface to become part of the aggregation.
key Is the number that identifies the aggregation. The lowest key number is 1. Zeroes are not allowed as keys.

{passive mode by default:
# dladm create-aggr -d e1000g0 -d e1000g1 1
# dladm create-aggr -d e1000g2 -d e1000g3 2

{active mode:
# dladm create-aggr -l active -d e1000g0 -d e1000g1 1
# dladm create-aggr -l active -d e1000g2 -d e1000g3 2

*please note that, if you configure LACP passive mode on your switch, you have to configure active mode on your server. if both in passive mode, they do not exchange LACP packets. check your configuration with “dladm show-aggr -L” command.

# dladm show-link aggr1
# dladm show-link aggr2

3. Plumb up the interface aggrkey, add ip address:

# ifconfig aggr1 plumb
# ifconfig aggr2 plumb

# ifconfig aggr1 192.168.1.1 netmask 255.255.255.0 up
# ifconfig aggr2 192.168.1.2 netmask 255.255.255.0 up

4. Show link aggregation status:

# dladm show-aggr >>check the status
# dladm show-aggr -s >>to display statistics
# dladm show-aggr -L >>to display LACP specific information

5. Make the IP configuration of the link aggregation persist across reboots

create “/etc/hostname.aggrkey” file
# vi /etc/hostname.aggr1
192.168.1.1
# vi /etc/hostname.aggr2
192.168.1.2

# dladm modify-aggr -t -l passive 1 {change aggr1 to passive mode; temporary only]
# dladm modify-aggr -t -l active 1 {change aggr1 to active mode; temporary only]

for further reference:

http://docs.sun.com/source/820-3084-10/link_aggregation.html

Thursday, January 7, 2010

Solaris 10 Remote X11,X-Server or CDE Login Problem

Sometimes I got an error after finishing on Solaris 10 box installation. After make some configuration then suddenly I can’t access my Solaris XDMCP remote session on my laptop.. Usually, I use XManager Enterprise to get Solaris GUI remote session XDMCP. here the step-by-step to troubleshoot if you got the same problem:

{Make sure that svc:/application/graphical-login/cde-login is enabled and online.

root@solaris10 # svcs cde-login
STATE STIME FMRI
online Mar_02 svc:/application/graphical-login/cde-login:default

root@solaris10 #netservices limited

restarting syslogd
restarting sendmail
dtlogin needs to be restarted. Restart now? [Y] y
restarting dtlogin
{Check dtlogin process:

root@solaris10 # ps -ef | grep dtlogin

root 29384 1 0 Mar 02 ? 0:00 /usr/dt/bin/dtlogin -daemon -udpPort 0 [should be TCP, not UDP]

{Modify the x11-server service:

—–>Show properties:
#svcprop svc:/application/x11/x11-server

——>Turn on tcp listen:
#svccfg -s svc:/application/x11/x11-server setprop options/tcp_listen=true

{Modify the dtlogin service:

—–>Show properties:
#svcprop svc:/application/graphical-login/cde-login:default
#svccfg -s svc:/application/graphical-login/cde-login setprop dtlogin/args=\”\”

—–>Then restart the X server:
#svcadm refresh svc:/application/graphical-login/cde-login:default;
#svcprop -p dtlogin svc:/application/graphical-login/cde-login:default

root@solaris10 #netservices open

restarting syslogd
restarting sendmail

root@solaris10# svcadm restart cde-login
root@solaris10# ps -ef |grep dtlogin
root 27722 1 0 15:08:37 ? 0:00 /usr/dt/bin/dtlogin -daemon
root 27724 26297 0 15:08:43 pts/3 0:00 grep dtlogin

http://saifulaziz.wordpress.com/2009/04/03/solaris-10-remote-x11-or-cde-login-problem/#comment-1148

Remove Solaris Volume Manager Information

Breaking Solaris SVM is easy, but sometimes if we type wrong command it will become a big trouble and wasting time to troubleshoot, like what I did yesterday, I’m stuck!;-). so, if you stuck with SVM, just remove or clear the whole SVM information on the disk (both mirror and submirror).

CLEAR / Remove Solaris Volume Manager Information:
———————————————————————-
1. All of the Solaris Volume Manager information is stored in three files:
/kernel/drv/md.conf
/etc/lvm/mddb.cf
/etc/lvm/md.cf

So to clear out Solaris Volume Manager, overwrite these files with the files from a system without Solaris Volume Manager or just remove the last entry configuration.

your three files configuration become like this:

bash-3.00# more /kernel/drv/md.conf
#
#pragma ident “@(#)md.conf 2.2 04/04/02 SMI”
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# The parameters nmd and md_nsets are obsolete. The values for these
# parameters no longer have any meaning.
name=”md” parent=”pseudo” nmd=128 md_nsets=4;

bash-3.00# more /etc/lvm/mddb.cf
#pragma ident “@(#)mddb.cf 2.1 00/07/07 SMI”
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#metadevice database location file do not hand edit
#driver minor_t daddr_t checksum

bash-3.00# more /etc/lvm/md.cf
#pragma ident “@(#)md.cf 2.1 00/07/07 SMI”
#
# Copyright (c) 2000 by Sun Microsystems, Inc.
# All rights reserved.
#
# metadevice database configuration file
# do not hand edit

2. and also, there is an entry similar to “rootdev:/pseudo/md@0:0,0,blk” in the “/etc/system” file, dont forget to remove this entry. Do not just comment it out.

3. edit “/etc/vfstab” configuration, then reboot.

4. now, perform mirroring disk again;-)

Enabling or Disabling MPXIO Multipathing per Port

What is MPXIO?

Solaris Multiplexed I/O (MPxIO), known also as Sun StorageTek Traffic Manager (SSTM, earlier Sun StorEdge Traffic Manager), is multipath I/O software for Solaris OS. It enables a storage device to be accessed through multiple host controller interfaces from a single operating system instance. The MPxIO architecture helps protect against I/O outages due to I/O controller failures. Should one I/O controller fail, MPxIO automatically switches to an alternate controller.

This architecture also increases I/O performance by load balancing across multiple I/O channels.

It was integrated within the Solaris operating system beginning in February 2000 with Solaris 8 release.

The file to enable or disable mpxio has been moved in Solaris 10 from /kernel/drv/scsi_vhci.conf to the bottom of the file /kernel/drv/fp.conf and /kernel/drv/mpt.conf.

The easy way to enable/disable global MPXIO On Solaris:
——————————————————————–
# vi /kernel/drv/fp.conf

mpxio-disable=”no”;

CHANGE TO ‘YES’ for Disable and ‘NO’ for Enable

Or, just simply run this command:
#stmsboot -D fp -e >>enable MPXIO
#stmsboot -D fp -d >>disable MPXIO

the, you will prompted to reboot the server.

But, actually Multipathing can be enabled or disabled on specific Fibre Channel Host Bus Adapter (HBA) controller ports. If you enable multipathing on a specific HBA port controller port, all supported devices connected to that controller port will be enabled for multipath operation.

The following procedure applies to both SPARC and x86 based machines:
Port Configuration Considerations

Before you start configuring the software by port, consider the following:

* FC global and per-port multipath settings are specified in the file /kernel/drv/fp.conf.

Per-port multipath settings have priority over the global setting. This means that if global multipathing is enabled by a specific port has been disabled for multipathing, the port will not be available in the multipathing configuration. Conversely, even if global multipathing has been disabled, specific ports may be enabled for multipathing if they are listed in the appropriate driver.conf(4) file.
* Load balancing is controlled by the global load-balance property in /kernel/drv/scsi_vhci.conf file and is not controlled on a per-port basis.
* If a device has more than one path to the host, all paths to the device must be configured with multipathing enabled or disabled.
* Configuring multipathing by port enables the multipathing software to coexist with other multipathing solutions like Symantec (VERITAS) Dynamic Multipathing (DMP), or EMC PowerPath. However, devices and paths should not be shared between the multipathing software and other multipathing solutions.

To Configure Multipathing by Port

Depending on how many ports you want the multipathing software to control, you can enable or disable multipathing globally or for specified ports.

1. Log in as root (su - root).
2. Determine the HBA controller ports that you want the multipathing software to control.

For example, to select the desired device, perform an ls -l command on /dev/cfg directory. The following example shows the ls -l command output.

lrwxrwxrwx 1 root root 50 Jan 29 21:33 c0 ->
../../devices/pci@7c0/pci@0/pci@1/pci@0/ide@8:scsi
lrwxrwxrwx 1 root root 61 Jan 29 21:33 c1 ->
../../devices/pci@7c0/pci@0/pci@1/pci@0,2/LSILogic,sas@1:scsi
lrwxrwxrwx 1 root root 61 Jan 29 21:33 c2 ->
../../devices/pci@7c0/pci@0/pci@1/pci@0,2/LSILogic,sas@2:scsi
lrwxrwxrwx 1 root root 53 Jan 29 21:33 c3 ->
../../devices/pci@7c0/pci@0/pci@9/LSILogic,sas@0:scsi
lrwxrwxrwx 1 root root 54 Apr 16 20:28 c5 ->
../../devices/pci@780/pci@0/pci@8/SUNW,qlc@0/fp@0,0:fc
lrwxrwxrwx 1 root root 56 Apr 16 20:28 c6 ->
../../devices/pci@780/pci@0/pci@8/SUNW,qlc@0,1/fp@0,0:fc

Note – Controllers c5 and c6 are ports A and B on a dual-port FC HBA. Controllers c1 and c3 are single port SAS HBA ports. Controller c2 is the internal SAS controller in a Sun FireTM T2000 server. Once you have determined the port, or ports, you want to explicitly enable or disable multipathing for, go to the next step.
3. Enable or disable specific ports as follows:
* FC HBA ports
1. Edit file /kernel/drv/fp.conf
2. Add the following line for each FC HBA port that is to be enabled:

name="fp" parent="parent name" port=port-number mpxio-disable="no";

where parent name is the port device name, and port-number is the FC HBA port number.

For example, the following entries disable multipathing on all FC HBA controller ports except for the two specified ports:

mpxio-disable="yes";
name="fp" parent="/pci@6,2000/SUNW,qlc@2" port=0 mpxio-disable="no";
name="fp" parent="/pci@13,2000/pci@2/SUNW,qlc@5" port=0 mpxio-disable="no";

3. Add the following line for each FC HBA port that is to be disabled:

name="fp" parent="parent name" port=port-number mpxio-disable="yes";

For example:

name="fp" parent="/pci@6,2000/SUNW,qlc@2" port=0 mpxio-disable="yes";

4. Type stmsboot -u to start the reboot and configuration process.

You are prompted to reboot. During the reboot, the /etc/vfstab file and your dump device configuration are updated to reflect any device name changes.
5. (Optional) After the reboot, if necessary, configure your applications to use new device names as described in Multipathing Considerations.