Showing posts with label Solaris. Show all posts
Showing posts with label Solaris. Show all posts

Friday, October 23, 2015

Adding Swap Space on a Solaris System

Adding Swap Space on a Solaris System

  1. Become a superuser (root) by typing:
    % su
    Password: root-password
  2. Create a file in a selected directory to add swap space by typing:
    mkfile number[m|k|b] /directory/swap-file-name
    where number is an amount of swap space, followed by either m for megabyte, k for kilobyte, or b for block. The directory is a directory in which you have permission to add swap space. The swap-file-nameis the name of the swap file you are creating.
    For example, to create a 16-megabyte swap file named 16mswapin the foodirectory, type the following:
    mkfile 16m /foo/16mswap
    See the mkfile(1M) man page for more information.
  3. Verify that the file was created by typing:
    ls -l /directory/swap-file-name
    The new file appears in the directory. For example:
    ls -l /foo/16mswap
    -rw------T   1 root     other    16777216 Dec 12 14:24 /foo/16mswap
  4. Run the swap command to specify the additional swap space by typing:
    swap -a /directory/swap-file-name
  5. Verify that the extra swap space was added by typing:
    swap -s
    The output shows the allocated swap space. For example:
    swap -s
    total: 289336k bytes allocated + 27008k reserved = 316344k used, 298336k available

Tuesday, September 11, 2012

Solaris-Remote-RSC-setup-v890

SUN ships the 890s with the rsc disabled.  The easiest way to set it up is
with "rscadm".  To make sure the RSC software is installed:

    cd /local/RSC/
        pkgadd -G -d . SUNWrsc
        pkgadd -G -d . SUNWrscd
        pkgadd -G -d . SUNWrscj

# pkginfo | grep rsc
system      SUNWrsc                          Remote System Control
system      SUNWrscd                         Remote System Control User Guide
system      SUNWrscj                         Remote System Control GUI

Porcedure - I
    To enable the rsc: 
        # pwd
        /usr/platform/SUNW,Sun-Fire-V890/rsc
        # ./rscadm useradd admin
        # ./rscadm userperm admin cuar
        # ./rscadm userpassword admin
            and set a password

        Set the network console's network parameters:
        # ./rscadm set ip_mode config
        # ./rscadm set ip_addr xx.xx.xx.xx
        # ./rscadm set ip_netmask xx.xx.xx.xx
        # ./rscadm set ip_gateway xx.xx.xx.xx
        # ./rscadm set hostname hostname
        # ./rscadm date 113011402005.00
        # ./rscadm set escape_char # .  (note: it is # space .)
        # ./rscadm resetrsc

Porcedure - II
    OR USE rsc-config script to configure above setting--
    Log in as root and run the command:
        #/usr/platform/SUNW,Sun-Fire-880/rsc/rsc-config.
        bash-3.00# /usr/platform/SUNW,Sun-Fire-880/rsc/rsc-config

                Continue with RSC setup (y|n): y

                Set RSC date/time now (y|n|?) [y]:
                Server Hostname [torzone01]:
                Edit customer info field (y|n|?) [n]:
                Enable RSC Ethernet Interface (y|n|s|?) [n]: y
                   RSC IP Mode (config|dhcp|?) [dhcp]: config
                   RSC IP Address []: 10.1.5.34
                   RSC IP Netmask [255.255.255.0]: 255.255.0.0
                   RSC IP Gateway []: 10.1.32.167
                Enable RSC Alerts (y|n|s|?) [n]:
                Enable RSC Serial Port Interface (y|n|s|?) [n]: y
                   Serial port baud rate (9600|19200|38400|57600|115200) [9600]:
                   Serial port data bits (7|8) [8]:
                   Serial port parity (even|odd|none) [none]:
                   Serial port stop bits (1|2) [1]:
                Setup RSC User Account (y|n|?) [y]:
                   Username []: admin
                   User Permissions (c,u,a,r|none|?) [cuar]:

                --------------------
                Verifying Selections
                --------------------
               
                  Is this correct (y|n): y

                This script will now update RSC, continue? (y|n): y
                Updating flash, this takes a few minutes
                ........................................
                ........................................
                ...........................
                Download completed successfully

                Resetting RSC (takes about 90 seconds): DONE
                Setting up server to update RSC date on boot: DONE
                Setting up server hostname: DONE
                Setting up ethernet interface: DONE
                Disabling RSC alert engine: DONE
                Disabling modem interface: DONE
                Setting up serial port interface: DONE
                Adding user to RSC:

                A valid password is between 6 and 8 characters, has at least
                two alphabetic characters, and at least one numeric or special
                character.  The password must differ from the user's login name
                and any reverse or circular shift of that login name.
                Setting User Password Now ...

                Password:
                Re-enter Password:
                User has been added to RSC
                Resetting RSC (takes about 90 seconds):
                Are you sure you want to reboot RSC (y/n)?  y

                DONE
                Setting up RSC date: DONE

                *******************************
                RSC has been successfully setup
                *******************************


STEPS to redirecting console to RSC---

Access the system from physical console to get OK prompt :
    -Type the following commands at the system ok prompt:
        ok diag-console rsc
        ok setenv input-device rsc-console
        ok setenv output-device rsc-console
        ok reset-all
The system permanently stores the new settings. The changes will take effect after the next reset.

Solairs V210 ILOM configuration from OS

sc> setsc sc_escapechars ## (for example)
hostname console login:
#. ---> switch from console to ALOM

Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
Sun(tm) Advanced Lights Out Manager 1.5.4 (hostname)
Please login: admin
Please Enter password: **********

Cannot login to the ALOM?

Try default password which is the last 8 digits of the chassis serial number. Username is admin.
        sc> setsc set if_network true
        sc> setsc netsc_dhcp false
        sc> setsc netsc_ipaddr 192.168.etc.etc
        sc> setsc netsc_ipnetmask 255.255.255.etc
        sc> setsc netsc_ipgateway 192.168.etc.etc
        sc> resetsc
    Are you sure you want to reset the SC [y/n]?  y

For some platforms, like SunFire V240 and V440, ALOM can be configured from OS level using scadm utility.
    To reset the ALOM password for "admin" use:-
--->    /usr/platform/`uname -i`/sbin/scadm userpassword admin

        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm set if_network true
Enable Ethernet link integrity test:
        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm set netsc_tpelinktest true
Enable backup of local user database (username, passwords, permissions) on system configuration card.
        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm set sc_backupuserdata true
        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm set netsc_dhcp false
        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm set netsc_ipaddr 192.168.etc.etc
        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm set netsc_ipnetmask 255.255.255.etc
        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm set netsc_ipgateway 192.168.etc.etc
        /usr/platform/SUNW,Sun-Fire-V240/sbin/scadm resetrsc

    /usr/platform/SUNW,Sun-Fire-V240/sbin> ./scadm shownetwork
        IP Address: 192.168.etc.etc
        Gateway address: 192.168.etc.etc
        Netmask: 255.255.255.etc
        Ethernet address: 00:00:00:00:00:00

Tuesday, March 2, 2010

/tmp and RAM disks in the Solaris OS - Creating Testing and automating

# df -k /tmp
Filesystem kbytes used avail capacity Mounted on
swap 1961928 504 1961424 1% /tmp
This has some advantages:
· the access of /tmp is fast
· there is always a writable directory even if Solaris can not mount the disks in read/write mode or if Solaris is booted from a read-only NFS share
· you do not need to think about cleaning up /tmp after or before a reboot
· It's not neccessary to create a filesystem for tmp - just mount it und use it
On the other hand there are some things to take care of if using /tmp:

Because /tmp is mounted on swap you should not use it for files which should survive a reboot - use the disk based directory for temporary files, /var/tmp, instead for these files.
One very important point:

Every user can write to /tmp. And in the default configuration /tmp is mounted without a size limitation. This fact results in the possibility that every user can use the whole virtual memory of the machine (that is physical memory and swap) by simply filling up /tmp with garbage.
To avoid this situation you should mount /tmp with an upper limit for the size, e.g in /etc/vfstab change the line
swap - /tmp tmpfs - yes -
to
swap - /tmp tmpfs - yes size=1024m
(replace 1024m with an approbiate value for the machine)

Unfortunately you cannot change the size for /tmp while Solaris is running:
# lockfs /tmp
/tmp: Inappropriate ioctl for device
# mount -o remount,size=512m swap /tmp
mount: Operation not supported
Therefore you must reboot the machine to activate the change.
Because of the fact that tmpfs is a "normal" filesystem in Solaris you can always add additional memory based file systems, e.g.
to create another tmpfs on the fly use:
# mkdir /mytmp
# mount -o size=100m -F tmpfs swap /mytmp
# df -k /mytmp
Filesystem kbytes used avail capacity Mounted on
swap 102400 0 102400 0% /mytmp
To create this new filesystem every time the machine boots up simply add another line to the /etc/vfstab:
swap - /mytmp tmpfs - yes size=1024m
There are some restrictions for tmpfs Filesystems:
· There is not really a device for a memory based filesystems like /dev/dsk/c#t#d#s#.. for harddisks or /dev/lofi/# for lofi mounts. Especially there is no raw device for the memory based filesystems.
· There are some restrictions in tmpfs (see tmpfs(7FS) )
· And you can only use the tmpfs filesystem on memory based file systems; you can not use for example ufs or vxfs on these kind of file systems.
But because Solaris is a real Operating system there is a solution for this problem also:
Instead of using tmpfs to create a memory based file system, use ramdiskadm. ramdiskadm is part of the Solaris OS since (at least) version 9.
ramdiskadm is part of the SUNWcsu package and therefore should be installed on every Solaris machine (x86 and SPARC, of course).
ramdiskadm can be used to create real ramdisk devices which can be used like any other disk device, e.g:
# create the ramdisk
#
# ramdiskadm -a mydisk 40m
/dev/ramdisk/mydisk
# check the result
#
# ls -l /dev/ramdisk/mydisk
lrwxrwxrwx 1 root root 40 Mar 17 22:15 /dev/ramdisk/mydisk -> ../../devices/pseudo/ramdisk@1024:mydisk
# ls -l /dev/rramdisk/mydisk
lrwxrwxrwx 1 root root 44 Mar 17 22:15 /dev/rramdisk/mydisk -> ../../devices/pseudo/ramdisk@1024:mydisk,raw
# check the fstype
#
# fstyp /dev/rramdisk/mydisk
unknown_fstyp (no matches)
# create a filesystem on the ramdisk
#
# newfs /dev/rramdisk/mydisk
/dev/rramdisk/mydisk: Unable to find Media type. Proceeding with system determined parameters.
newfs: construct a new file system /dev/rramdisk/mydisk: (y/n)? y
/dev/rramdisk/mydisk: 81872 sectors in 136 cylinders of 1 tracks, 602 sectors
40.0MB in 9 cyl groups (16 c/g, 4.70MB/g, 2240 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 9664, 19296, 28928, 38560, 48192, 57824, 67456, 77088,
# mount the ramdisk
#
# mkdir /myramdisk
# mount /dev/ramdisk/mydisk /myramdisk
# df -k /myramdisk
Filesystem kbytes used avail capacity Mounted on
/dev/ramdisk/mydisk 38255 1041 33389 4% /myramdisk
Be aware that these ramdisks are also gone after a reboot. If you need them permanent you should create an init script or an SMF service to recreate them while booting the machine.
There is a restriction for the size of ramdisk.
From manual page of ramdisk(7D) from a Solaris 10 8/07 box :
The percentage of available physical memory that can be
allocated to ramdisks is constrained by the variable
rd_percent_physmem. You can tune the rd_percent_physmem
variable in /etc/system. By default, the percentage of
available physical memory that can be allocated to ramdisks
is fixed at 25%.
The percentage can be increased by issuing following commands :
#cp /etc/system /etc/system.bck
#echo "set ramdisk:rd_percent_physmem=50" >> /etc/system
#reboot
A simple init script to create a ramdisk while booting the machine:
#!/sbin/sh
RAMDISK_NAME="ramdisk1"
RAMDISK_SIZE="40m"
MOUNT_POINT="/ramdisk1"
# check the status
#
ramdiskadm | grep -v grep | grep /dev/ramdisk/${RAMDISK_NAME} >/dev/null
RAMDISK_CONFIGURED=$?
case $1 in
start )
if [ ${RAMDISK_CONFIGURED} = 0 ] ; then
echo "The ramdisk \"${RAMDISK_NAME}\" is already defined"
exit 10
fi
# create the ramdisk
ramdiskadm -a ${RAMDISK_NAME} ${RAMDISK_SIZE} && \
yes | newfs /dev/rramdisk/${RAMDISK_NAME} && \
mount /dev/ramdisk/${RAMDISK_NAME} ${MOUNT_POINT}
;;
stop )
if [ ${RAMDISK_CONFIGURED} != 0 ] ; then
echo "The ramdisk \"${RAMDISK_NAME}\" is not defined"
exit 10
fi
umount -f ${MOUNT_POINT} 2>/dev/null
ramdiskadm -d ${RAMDISK_NAME}
;;
* )
echo "Usage: ` basename $0 ` [start|stop]"
exit 1
;;
esac
To get an idea of what's going on when a RAM disk is created, let's use the Solaris kstat(1m) kernel statitics utility to see how memory is being allocated. First let's see what memory looks like before creating a RAM disk:
# pagesize
4096
# kstat -n system_pages | grep pagesfree
pagesfree 96334
# kstat -n system_pages | grep pageslocke
pageslocked 26170
So, on this particular system, where a page is 4096 bytes, there are currently 96334 pages free, and 26170 pages that are locked. Now let's create a 50MB RAM disk:
# ramdiskadm -a rd 50m
/dev/ramdisk/rd
# ramdiskadm
Block Device Size
Removable
/dev/ramdisk/rd 52428800 Yes
# kstat -n system_pages | grep pagesfree
pagesfree 83507
# kstat -n system_pages | grep pageslocked
pageslocked 38988
Let's subtract the original number of pageslocked from the latest value and multiply by the pagesize:
# pagesize
4096
# bc
(38988-26170)*4096
52502528
^D
The increase in locked pages can be attributed to the creation of the RAM disk (50m + a small amount of overhead). So yes, these pages are locked into memory.

Monday, August 11, 2008

Renaming or moving a solaris host

Follow these steps to rename the system:
  • Change the name in /etc/nodename.
  • Change the name in /etc/hostname.xl0 (where xl0 is the name of your network interface)
  • Change the name in /etc/hosts.
  • /etc/dumpadm.conf
  • Move Crash Area
    mv /var/crash/OLDNAME /var/crash/NEWNAME
  • Run the command: hostname new_hostname
Moving to a New Network


Naming Services
Ensure your server has entries in naming services (such as DNS, NIS and LDAP) on the new network. Don't forget to remove the entries on the old network once the server has moved.

Disconnect from Old Network

IP Networking

  • Update IP address(es) in: /etc/hosts, /etc/inet/ipnodes(This is new in Solaris 10) and /etc/hostname.*.
  • Edit /etc/netmasks to reflect the new network.
  • Update the default router (gateway) in /etc/defaultrouter.
  • Update any static routes. You can view the current routing table with netstat -r.

DNS Resolver & Domain Configuration

The domain, name servers and domain searches path are all configured in /etc/resolv.conf. You also need to update /etc/defaultdomain if present (used by NIS, NIS+ and LDAP).

Network Time Configuration

If you use ntpd, you can update the time server in /etc/inet/ntp.conf.

Update Mail (MTA) Configuration

If you use a smarthost this is probably as simple as updating the DS line in /etc/mail/sendmail.cf (this file is generated, so you should update the template in /etc/mail/cf then regenerate it, rather than edit it directly). For more complex configurations refer to the Sendmail documentation: man sendmail.cf is a good start.

NFS Mounts

If your server automatically mounts network shares on other servers you should check they're available on the new network. If they're not, it's best to comment out references to them in /etc/vfstab.

Profile Configuration

You may have web proxies, CVS server roots etc. configured in profile files. It's a good idea to check /etc/.profile, /etc/skel and the profile files of any users.

Connect to New Network

Reboot the Server or Solaris 10 you can use: svcadm restart svc:/network/physical.
Once the server is up on the new network, you should test it thoroughly and ensure monitoring systems can see it

Reboot the server or do the following if you are on console-

OR--
bash-2.05# ifconfig ce0(interface) down
bash-2.05# ifconfig ce0 10.129.0.48 netmask 255.255.0.0
bash-2.05# ifconfig ce0 up

Saturday, August 9, 2008

system diagnostic commands (Sun Solaris)

Diagnostic Command - (Sun Solaris)
by Jeff Hunter, Sr. Database Administrator
prtdiag
Use the following command to obtain detailed diagnostics information about your system configuration and hardware state :
# /usr/platform/`uname -i`/sbin/prtdiag -v
 
It will display you:
System Configuration: Sun Microsystems  sun4u 
Memory size: 1.75GB
CPU details , I/O devices
Memory Configuration 
usb Devices 
keyboard      mouse
Environmental Status Fan Speeds:
HW Revisions 
System PROM revisions:
----------------------
OBP 4.6.5 2002/06/03 16:49
POST 2.0.1 2001/08/23 17:13
prtconf
Use the following command to obtain detailed system information about your Sun Solaris installation:
# /usr/sbin/prtconf
 
System Configuration:  Sun Microsystems  sun4u
Memory size: --Megabytes
System Peripherals (Software Nodes):
# uptime
uptime reports load averages over 1-, 5- and 15-minute intervals. Typically, load averages are divided by the number of CPU cores to find the load per CPU. Load averages above 1 per CPU indicate that the CPUs are fully utilized. A general rule of thumb is that load averages that are persistently above 4 times the number of CPUs will result in sluggish performance.
# prstat –mL è Solaris 10 allows us to directly monitor the amount of time threads wait for a processor via the prstat -mL command in the LAT category
# psrinfo –v èwill provide the number of CPU and there speed

Disk I/O Components

# iostat

If a disk is more than 60% busy over sustained periods of time, this can indicate overuse of that resource. The %b iostat statistic provides a reasonable measure for utilization of regular disk resources

HD info(vendor, RPM, capacity)

# iostat –E ( it will show you the disk space size and serial number.)
The DTrace Toolkit provides a way to directly measure disk utilization via the iotop -CP command.

Disk Errors


iostat -eE reports on disk error counts since the last reboot. Keep in mind that several types of events (such as ejecting a CD or some volume manager operations) are counted in this output. Once these error messages rise above 10 in any category, further investigation is warranted.

PORT enable / disable

vi /etc/inetd.conf

MOUNT ISO IMAGE UNDER SOLARIS .


To mount /root/sparc.iso file under /mnt directory.
issue the following commands.

# lofiadm -a /root/sparc.iso /dev/lofi/1
# mount -F hsfs -o ro /dev/lofi/1 /mnt
to unmount
# umount /mnt
# lofiadm -d /dev/lofi/1

Note: lofi = loopback file driver

To break lock on NIS server

#imp tsaini [/var/etc] >lockadm -f netgroup -b RCS

Ilom Alom Break
you are connected to the console
alom odr ilom ? standard at the t2210 is the newer ilom
where its like
set /HOST send_break_action=break
and then
start /SP/console
to enter the console
To change the DISPLAY setting in solaris.
To see your current settings and the possible settings...
# fbconfig -prconf
To change it:
# fbconfig -res video-mode -depth 8or24
Memory usuage by process

Display processes with the highest CPU utilization

# ps -eo pid,pcpu,args | sort +1n
# ps aux
ps command reports a snapshot on information of the current active processes. Advantage of ps command is that system admins will be able to see where the memory is used.
To see only the memory resources occupied by each category of processes, such as Apache httpd, MySQL mysqld or Java, use the following command:
# ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort –nr
Sorting the output
#top
* M : sorts the output by memory usage. Pretty handy for figuring out which version of openoffice.org to kill.
* P : sorts the process by the percentage of cpu time they are using.
* T : sorts by cumulative cpu time used
* A : sorts by age of the process, newest process first
Using split and cat to help edit large files.
 
# That's 10Mb
split -b 10000000 filename.txt
# makes xaa  xab  xac  xad  xae  xaf ...
# grep for what you want, edit that file with emacs
cat xaa  xab  xac  xad  xae  xaf > new1.txt
# Using wildcards with cat seems to work fine too: 
cat x?? > new2.txt
Checking whether it's running in 32-bit mode or 64-bit mode

64-bit mode

% isalist -v 
sparcv9+vis sparcv9 sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc
% isainfo -v
64-bit sparcv9 applications
32-bit sparc applications

32-bit mode

% isalist -v 
sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc
% isainfo -v
32-bit sparc applications
 
print the version of OBP
% prtconf -V
OBP 3.3.2 1996/06/28 08:43
% /usr/platform/`uname -i`/sbin/prtdiag -v | grep OBP
OBP 3.11.1 1997/12/03 15:53   POST 3.11.4 1997/05/27 02:26
%
{2} ok .version
Release 3.23 Version 1 created 1999/07/16 12:08
OBP 3.23.1 1999/07/16 12:08
POST 2.0.2 1998/10/19 10:46
{2} ok 
 

print the version of Open Windows

% showrev -w
OpenWindows version: 
OpenWindows Version 3.6.1 25 January 1999

Examining gcc behavior

% gcc -v -x c /dev/null

Display the version of CDE

% /usr/ccs/bin/what /usr/dt/bin/dtmail
/usr/dt/bin/dtmail:
        CDE Version 1.3.4
        CDEVersion1.3.4
To find out top 10 largest file/directories is taking up the most space in a /var directory/file system:
# du -a /var | sort -n -r | head -n 10
If you want more human readable output try:
# du -ha /var | sort -n -r | head -n 10
find / -size +2000 -exec ls -s {} \; | sort -nr | more
find and delete files form specific date-
/usr/bin/find /local/ftp/pub/[Aa]lgo* -type f -mtime +14 -ls -exec /usr/bin/rm -f {} \; > /tmp/cleanftp.algo.cron.log.`/usr/bin/date +\%a` 2>&1