Wednesday, 29 February 2012

ALOM network configuration

We decommissioned all our older Solaris servers recently and decided to keep a couple to "play" with. Being older models the Service Processors hadn't been configured for network use plus they were a different bit of kit compared to our new ones which either used ILOM or XSCF operating systems, so.....

These are the commands I used to configure the ALOM which doesn't include NTP (being a test server I didn't go that far).

To set a static IP address:
setsc netsc_dhcp false
setsc netsc_ipaddr <IP address>
setsc netsc_ipnetmask <Subnet mask>
setsc netsc_ipgateway <Gateway address>

To check that the settings have taken:
shownetwork

You may have to reset the ALOM for the settings to take affect:
resetsc -y

The ALOM should be on the network now......  

NTP settings

The file that you need to be edit should be located at:
/etc/inet/ntp.conf

The file should read something like:
# multicastclient 224.0.1.1
server <FQDN of your Time server>
logfile /var/ntp/ntp.log
driftfile /var/ntp/ntp.drift

First line relates to your time service, the second makes the service use a logfile and the third a drift file - which helps with any time drift.

Run the following command to enable the service:
svcadm enable ntp

Then check to see if the NTP service has kicked in by running the following:
ntpq -p




What you are looking for is a 377 entry under the reach heading - if you don't you're not getting a connection and will have to start troubleshooting

vSphere - List of VMs from Virtual Center

We had a need to obtain a list of VMs to Hosts due updating from 4.1 u1 to 4.1 u2 - the VC would be done for a projected couple of hours so just in case we needed to access a VM console we needed this list.

How we got this information was by doing the following:

1. Go to Home > Inventory > VMs and Templates.
2. In the left pane click on the level of reporting you want - in this case it was at the Datacenter level.
3. In the right hand pane choose the Virtual Machines tab.
4. Then click on File > Export > Export List.
5. I choose the xls format and then save it somewhere (in this case a shared location).

You can use other tools for this - one of my favourites is RVTools written by Rob de Veij and can be found at http://www.robware.net/

Thursday, 23 February 2012

Solaris - Automated FTP job

I had a request come in to transfer a file from a Solaris box to a Windows VM. It needed to copy at 6am and only run on Tuesday to Saturday - being new to Solaris I thought I'd log this one for future reference......

Basic steps
1. create a user account on the receiving (Windows) box
2. create a user account on the sending (Solaris) box
3. create a .netrc file
4. create a batch file
5. edit the crontab file (Solaris account)
6. store passwords in a secure location

Step 1
Create the Windows user account and give it permissions to required area - in this case a FTP site was setup on a IIS box with the account having rights to the site.

Step 2
I created a user account, ftpjob, on the Solaris box and made sure the account had rights on the relevant area.
 ls -al (will show you permissions)
In this case the account created belonged to the group that had ownership along the full path.
It's home area was /export/home/ftpjob

Step 3
create the .netrc file in the root of the accounts home area (which allows for automating of the job).
 touch .netrc

Change the file permissions
 chmod 600 .netrc

I added the following text to the file:
 machine <name or ip> login <windows user account> password <windows user account> macdef init
 bin
 lcd /<solaris-local-file-path>
 cd /<non-root-path-on-windows-box>
 put <file-name>
 quit
<press enter twice then save file :wq!>

Step 4
Create a file, I'll call it ftpbatch with the following text in the home area
#!/usr/bin/ksh
 # Comments.....

 # links to the .netrc file in the ftpuser home area
 echo "`date` : Start script"
 ftp <IPAddress> <Port number if different from default>
 echo "`date` : Finish script"


Make sure you set the correct permissions on the file:
 chmod 755 ftpbatch
If you don't want anyone else to read the contents set the permissions as:
 chmod 700 ftpbatch

Step 5
To schedule the task crontab needs to used - by default I've found that a text editor is not specified in the user environment. I enabled this by editing the .profile file of ftpuser (in the accounts home directory).
To obtain the vi path type:
which vi
Output was:
/usr/bin/vi

Either make a temporary change so crontab uses vi or permenately add the entry in the .profile  export EDITOR=/usr/bin/vi

If you add the entry into the .profile then run: . .profilewhich will reload the environmental settings.

You can now edit the crontab settings by running: crontab -e

The request is for the job to run at 0600hrs every week (Tuesday - Saturday) and the crontab has edited as follows:
 # Comments 
00 6 * * 2-6 /export/home/ftpuser/ftpbatch >> /tmp/error.log 2>&1

The double >> will append an entry to the log file

Step 6
Store the passwords in a safe location

Wednesday, 22 February 2012

Setting auto-boot within Solaris 10

As the example states within the eeprom man page:

eeprom "auto-boot?"=true

When the eeprom command is executed in user mode, the parameters with a trailing question mark (?) need to be enclosed in double quotation marks (" ") to prevent the shell  from interpreting the question mark. Preceding the question mark with an escape character (\) will also prevent the shell

Solaris - Useful commands

This page will grow as I find commands that are useful........

Creating:

Create a group:
# groupadd -g 100 appsup
(Creates a group called appsup with a group ID number of 100)

Check user account:
# cat /etc/passwd

Create a new user:
# useradd - u 1000 -g 100 -d /export/home/newuser -s /usr/bin/bash -c "A new user" -m newuser
(Add a new user with the user ID of 1000, belonging to the group 100, with a home area /export/home/newuser, the default shell of bash, a account description of "A new user", with a username of newuser.

Changing a user account password
# passwd newuser
You will then be prompted to enter a new password, twice.

Changing ownership user and group ownership of a folder:
# chgrp dba /<folder>
# chown dbauser /<folder>

Queries:

To check RAM:
# prtconf -v
OR
# prtconf | head -3 |grep Mem

Check number of CPUs
# psrinfo -vp

Directory size query:
# du -hks /directory1/directory2


To check the version of Solaris:
# cat /etc/release

To check the run level:
# who -r

Check groups:
# cat /etc/groups

Mount Points: 

Creating a NFS mount point:
# mkdir /mp
# mount -F nfs <nfs-server-name>:/vol/mount_point /mp


Mounting and Unmounting an ISO

Mounting:
# mkdir /dvd
# mount -F hsfs -o ro `lofiadm -a /mp/sol-10-u10-ga2-sparc-dvd.iso` /dvd
(All credit for this one goes to http://www.tech-recipes.com/rx/218/mount-an-iso-image-on-a-solaris-filesystem-with-lofiadm/)

Unmounting:
# umount /mnt
# lofiadm -d /<dir>/sol-10-u10-ga2-sparc-dvd.iso

Mounting USB drive

Check that the volfs services are running
# svcs -a | grep volfs
or
# svcs volfs
If the service is enabled then carry on, if not then enable the service
# svcadm enable volfs
Plug in the device
Check that it is mounted
# mount
/rmdisk/unnamed_rmdisk on /vol/dev/dsk/c9t0d0/unnamed_rmdisk:c read/write/setuid/devices/rstchown/hidden/nofoldcase/noatime/timezone=0/dev=16c1003 on Wed Sep 26 12:55:43 2012
Another check (media)
# volcheck -v
media was found


Dismounting USB drives

Check if anything is mounted
# mount
On the system I was using it popped up as
# /rmdisk/unnamed_rmdisk on /vol/dev/dsk/c9t0d0/unnamed_rmdisk:c read/write/setuid/devices/rstchown/hidden/nofoldcase/noatime/timezone=0/dev=16c1003 on Wed Sep 26 12:55:43 2012
Unmount the device
# umount /rmdisk/unnamed_rmdisk
Check media
# volcheck -v 
no media was found

Dismounting a local DVD drive


# cd / (make sure you not in the DVD path)
# umount /cdrom/cdrom0
# eject

Finding files

Finding files (search for a file in the current directory and below):
# find . -type f -name 'explorer'

Finding files (search for a file at the root level and below):
# find / -type f -name 'explorer'

Finding files (search for a file in the /etc directory):
# find /etc -type f -name 'explorer'

Jumpstart - OS install command

Get to the <ok> prompt and type the following:
# <ok> boot net - install


Logical Domains


Check version of LDOM
# pkginfo -l SUNWldm

Solaris - Creating a persistent mount point

On the Host server do the following:
cd /etc/dfs
vi dfstab

Add the following
share -F nfs /<directory>

Restart the NFS service (if the service is running)
Solaris 9
/etc/init.d/nfs.server stop;/etc/init.d/nfs.server start
Solaris 10
svcadm restart network/nfs/server

On the Client do the following:
mkdir /<mount point>
vi /etc/vfstab

Add the following
<host server>:/<shared directory>   -       /<mount point>     nfs     -       yes     rw,bg

After the Client server is rebooted the mount point will appear.