Friday, June 25, 2010

Installing MYSQL in Solaris10


Getting the binary

Available @ http://www.mysql.com
I have used MYSQL 5.1.34 here.
mysql-5.1.34-solaris10-sparc-64bit.tar.gz

Extracting the binary

bash-3.00# pwd
/export/home/mysql
bash-3.00# ls
mysql-5.1.34-solaris10-sparc-64bit.tar.gz
bash-3.00# gunzip mysql-5.1.34-solaris10-sparc-64bit.tar.gz
bash-3.00# tar -xvf mysql-5.1.34-solaris10-sparc-64bit.tar
bash-3.00# ls
mysql-5.1.34-solaris10-sparc-64bit.tar
mysql-5.1.34-solaris10-sparc-64bit
bash-3.00# cd mysql-5.1.34-solaris10-sparc-64bit
bash-3.00# pwd
/export/home/mysql/mysql-5.1.34-solaris10-sparc-64bit
bash-3.00# ls
COPYING bin lib share
EXCEPTIONS-CLIENT data man sql-bench
INSTALL-BINARY docs mysql-test support-files
README include scripts
bash-3.00# cd bin/
bash-3.00# file mysql
mysql: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped

Adding group and user

bash-3.00# groupadd mysql
bash-3.00# useradd -g mysql mysql

Creating Soft link

bash-3.00# mkdir /usr/local
bash-3.00# cd /usr/local/
bash-3.00# pwd
/usr/local
bash-3.00# ln -s /export/home/mysql/mysql-5.1.34-solaris10-sparc-64bit mysql
bash-3.00# ls -ltr
total 2
lrwxrwxrwx 1 root root 53 Jun 5 13:08 mysql -> /export/home/mysql/mysql-5.1.34-solaris10-sparc-64bit
bash-3.00#
bash-3.00# cd mysql
bash-3.00# chown -R mysql .
bash-3.00# chgrp -R mysql .

Run MYSQL initialization scipts

bash-3.00# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
090605 13:10:51 [Warning] Forcing shutdown of 2 plugins
OK
Filling help tables...
090605 13:10:51 [Warning] Forcing shutdown of 2 plugins
OK

Change Permissions

bash-3.00# chown -R root .
bash-3.00# ls -ltr
total 96
drwxr-xr-x 2 root mysql 512 Apr 1 12:34 docs
drwxr-xr-x 2 root mysql 1024 Apr 1 12:34 include
drwxr-xr-x 4 root mysql 512 Apr 1 12:35 man
drwxr-xr-x 3 root mysql 1024 Apr 1 12:35 lib
drwxr-xr-x 10 root mysql 512 Apr 1 12:40 mysql-test
drwxr-xr-x 27 root mysql 1024 Apr 1 12:40 share
drwxr-xr-x 5 root mysql 1024 Apr 1 12:40 sql-bench
drwxr-xr-x 2 root mysql 512 Apr 1 12:40 support-files
drwxr-xr-x 2 root mysql 512 Apr 1 12:40 scripts
drwxr-xr-x 2 root mysql 1536 Apr 1 12:40 bin
-rw-r--r-- 1 root mysql 1410 Apr 1 12:40 README
-rw-r--r-- 1 root mysql 8769 Apr 1 12:40 INSTALL-BINARY
-rw-r--r-- 1 root mysql 5139 Apr 1 12:40 EXCEPTIONS-CLIENT
-rw-r--r-- 1 root mysql 19071 Apr 1 12:40 COPYING
drwxr-x--- 4 root mysql 512 Jun 5 13:10 data
bash-3.00#
bash-3.00# chown -R mysql data

Selecting required server configuration

bash-3.00# cd support-files/
bash-3.00# ls
binary-configure config.small.ini my-innodb-heavy-4G.cnf my-small.cnf mysqld_multi.server
config.huge.ini magic my-large.cnf mysql-log-rotate ndb-config-2-node.ini
config.medium.ini my-huge.cnf my-medium.cnf mysql.server
bash-3.00#

bash-3.00# cp my-huge.cnf /etc/my.cnf

Here I have used my-huge.cnf configuration.

Start MYSQL

bash-3.00# bin/mysqld_safe --user=mysql &
[1] 5458
bash-3.00# 090605 13:28:01 mysqld_safe Logging to '/export/home/mysql/mysql-5.1.34-solaris10-sparc-64bit/data/deepakraja.err'.
090605 13:28:01 mysqld_safe Starting mysqld daemon with databases from /export/home/mysql/mysql-5.1.34-solaris10-sparc-64bit/data

Login to MYSQL

bash-3.00# ./mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.34-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

Change mysql root user password

mysql> use mysql
Database changed

mysql> update user set password=PASSWORD('adminadmin') where user='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 3 Changed: 2 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
bash-3.00# ./mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
bash-3.00# ./mysql -uroot -padminadmin
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.34-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Wednesday, June 23, 2010

Setting up CVS on Solaris 10





     Having worked on multiple workstations,I often have issues related to versioning of data, availability of data. Have tried on many windows freewares for file sychonization. But that introduced lot of compatibility issues between OS and were relatively very slow to work. So, switched to the traditional way ie, the CVS way. Having setting up the CVS successfully, I am sharing the steps here.

Getting the dependency packages


1. libintl-3.4.0-sol10-sparc-local.gz 
2. libiconv-1.13.1-sol10-sparc-local.gz 
3. libgcc-3.4.6-sol10-sparc-local.gz
4. cvs-1.12.13-sol10-sparc-local.gz

Here I have used SPARC binaries. If you are using x86/x64 hardware, you can download the specific binaries from the same source.

Installation 

bash-3.00# gunzip libgcc-3.4.6-sol10-sparc-local.gz
bash-3.00# gunzip libintl-3.4.0-sol10-sparc-local.gz libiconv-1.13.1-sol10-sparc-local.gz cvs-1.12.13-sol10-sparc-local.gz
bash-3.00# pkgadd -d libgcc-3.4.6-sol10-sparc-local
bash-3.00# pkgadd -d libintl-3.4.0-sol10-sparc-local
bash-3.00# pkgadd -d libiconv-1.13.1-sol10-sparc-local
bash-3.00# pkgadd -d cvs-1.12.13-sol10-sparc-local

Add /usr/local/bin to PATH

/etc/profile
PATH=/usr/local/bin:/usr/X11/bin:/usr/openwin/bin:/export/home/fenxi-2.1a/dist/s
export LOGNAME PATH

launch new terminal

Setting up the Filesystem

bash-3.00# newfs /dev/dsk/c0t1d0s7 
bash-3.00# mount /dev/dsk/c0t1d0s7 /mydisk

Avaliability feature is not available in this setup. If you are concerned of the Disk failures then follow this blog entry Enabling High Availability in Solaris 10 via SVM(Solaris Volume Manager)

Adding group and user

bash-3.00# groupadd cvs
bash-3.00# useradd -m -g cvs -s /bin/bash -d /users/cvs cvs
bash-3.00# passwd cvs

CVS Initialization

bash-3.00# chgrp cvs /mydisk/cvsroot/
bash-3.00# chmod g+srwx /mydisk/cvsroot/
bash-3.00# cvs -d /mydisk/cvsroot/ init
bash-3.00# chown -R cvs:cvs /mydisk/cvsroot/
bash-3.00# ls -la /mydisk/cvsroot/
total 6
drwxr-xr-x   3 cvs      cvs          512 May 26 00:21 .
drwxr-xr-x   4 root     root         512 May 26 00:19 ..
drwxrwxr-x   3 cvs      cvs         1024 May 26 00:21 CVSROOT

Adding Environment Variables

bash-3.00# su - cvs
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
-bash-3.00$ cd
-bash-3.00$ pwd
/users/cvs
-bash-3.00$ more .bash_profile
CVSROOT=/mydisk/cvsroot
export CVSROOT
CVSEDITOR=/bin/vi
export CVSEDITOR

Add User entries to passwd file for PSERVER protocol

-bash-3.00$ su - root

Perl script
-----------
#!/usr/bin/perl
$cvsroot="/mydisk/cvsroot";
$user = shift @ARGV || die "cvspasswd user\n";
print "Enter password for $user: ";
system "stty -echo";
chomp ($plain = <>);
system "stty echo";
print "\n";
@chars = ('A'..'Z', 'a'..'z', '0'..'9');
$salt = $chars[rand(@chars)] . $chars[rand(@chars)];
$passwd = crypt($plain, $salt);
open(PASSWD,">>$cvsroot/CVSROOT/passwd") || die("Cannot Open File");
print PASSWD "$user:$passwd:cvs\n";
close PASSWD;
#-End

bash-3.00# perl myperl.pl user1
Enter password for laptop:
bash-3.00# perl myperl.pl user2
Enter password for ofmac1:
bash-3.00# cat /mydisk/cvsroot/CVSROOT/passwd
user1:xxxxxxxxxxxxx:cvs
user2:xxxxxxxxxxxxx:cvs

For security reasons make sure only root has the permission to passwd file.

Add the following lines to /etc/services file

more /etc/services
cvspserver 2401/tcp # CVS Client/server operations
cvspserver 2401/udp # CVS Client/server operations

Moving Inetd entries to SMF services

using file cvs_inetd to hold the inetd entry
bash-3.00# more cvs_inetd
cvspserver stream tcp nowait cvs /usr/local/bin/cvs -f --allow-root=/mydisk/cvsroot pserver
bash-3.00# inetconv -f -i ./cvs_inetd
cvspserver -> /var/svc/manifest/network/cvspserver-tcp.xml
Importing cvspserver-tcp.xml ...Done

Changes /var/svc/profile/inetd_services.xml

Add the following lines to /var/svc/profile/inetd_services.xml

<service name='network/cvspserver-tcp' version='1' type='service'>
<instance name='default' enabled='true'/>
</service>

Restart Network Service

svcadm restart svc:/network/inetd:default

CVS is ready and waiting for client to connect at port 2401.

Command line CVS access
cvs -d :pserver:user1@machinename:2401/mydisk/cvsroot checkout project1

GUI based access


Enabling High Availability in Solaris 10 via SVM(Solaris Volume Manager)


Attach atleast two disks to the hardware running Solaris 10. Here I have taken two disks.

Inspecting the disk partition information.

c0t0d0 (root partition)
c0t1d0 (extra disk)

bash-3.00# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c0t0d0
          /pci@1d,700000/scsi@4/sd@0,0
       1. c0t1d0  deepak
          /pci@1d,700000/scsi@4/sd@1,0
Specify disk (enter its number): 0

Current partition table (original):
Total disk cylinders available: 14087 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm     421 -  6055       54.69GB    (5635/0/0)  114683520
  1       swap    wu       0 -   412        4.01GB    (413/0/0)     8405376
  2     backup    wm       0 - 14086      136.71GB    (14087/0/0) 286698624
  3 unassigned    wm       0                0         (0/0/0)             0
  4 unassigned    wm       0                0         (0/0/0)             0
  5 unassigned    wm       0                0         (0/0/0)             0
  6       root    wm    6056 -  6057       19.88MB    (2/0/0)         40704
  7       home    wm    6058 - 14086       77.92GB    (8029/0/0)  163406208

Copying VTOC info from disk c0t0d0 to c0t1d0

bash-3.00#prtvtoc /dev/rdsk/c0t0d0s0 | fmthard -s - /dev/rsk/c0t1d0s0

Modifying the partitions in disk c0t1d0.

bash-3.00# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c0t0d0
          /pci@1d,700000/scsi@4/sd@0,0
       1. c0t1d0  deepak
          /pci@1d,700000/scsi@4/sd@1,0
Specify disk (enter its number): 1

selecting c0t1d0: deepak
[disk formatted]

Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm       2 -  5636       54.69GB    (5635/0/0)  114683520
  1 unassigned    wu       0                0         (0/0/0)             0
  2     backup    wm       0 - 14086      136.71GB    (14087/0/0) 286698624
  3 unassigned    wu       0                0         (0/0/0)             0
  4 unassigned    wu       0                0         (0/0/0)             0
  5 unassigned    wu       0                0         (0/0/0)             0
  6       root    wm    6056 -  6057       19.88MB    (2/0/0)         40704
  7       home    wm    6058 - 14086       77.92GB    (8029/0/0)  163406208

partition> label
Ready to label disk, continue? y

partition>quit

Creating State Database Replicas

bash-3.00# metadb -a -f c0t0d0s6
bash-3.00# metadb
        flags           first blk       block count
     a        u         16              8192            /dev/dsk/c0t0d0s6

Adding one more copy

bash-3.00# metadb -a -f c0t1d0s6
bash-3.00# metadb
        flags           first blk       block count
     a        u         16              8192            /dev/dsk/c0t0d0s6
     a        u         16              8192            /dev/dsk/c0t1d0s6

Creating first RAID-0 volume/ Submirror (single stripe on single slice)

bash-3.00# metainit d21 1 1 c0t0d0s7
d21: Concat/Stripe is setup

Creating second RAID-0 volume/ Submirror (single stripe on single slice)

bash-3.00# metainit d22 1 1 c0t1d0s7
d22: Concat/Stripe is setup

Creating RAID-1 volumes/ Mirrors on first submirror

bash-3.00# metainit d0 -m d21
d0: Mirror is setup

Adding the second submirror to RAID-1 volume

bash-3.00# metattach d0 d22
d0: submirror d22 is attached

Creating a new UFS filesystem on metadevice d0

bash-3.00# newfs /dev/md/dsk/d0
newfs: construct a new file system /dev/md/rdsk/d0: (y/n)? y
Warning: 5760 sector(s) in last cylinder unallocated
/dev/md/rdsk/d0:        163406208 sectors in 26597 cylinders of 48 tracks, 128 sectors
        79788.2MB in 1663 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
Initializing cylinder groups:
.................................
super-block backups for last 10 cylinder groups at:
 162503328, 162601760, 162700192, 162798624, 162897056, 162995488, 163093920,
 163192352, 163290784, 163389216

Mounting the filesystem

bash-3.00# mount /dev/md/dsk/d0 /mydisk/

Testing Availability

bash-3.00# cd /mydisk/
bash-3.00# touch deepak.txt
bash-3.00# cat /mydisk/deepak.txt
This is a test message
bash-3.00# umount -f /mydisk/
bash-3.00# pwd
/mydisk
bash-3.00# ls
.: Not a directory
bash-3.00# cd /
Recovering data from disk c0t0d0
bash-3.00# mount /dev/dsk/c0t0d0s7 /mydisk/
bash-3.00# cat /mydisk/deepak.txt
This is a test message
bash-3.00# umount -f /mydisk/
bash-3.00# cd /
Recovering data from disk c0t1d0
bash-3.00# mount /dev/dsk/c0t1d0s7 /mydisk/
bash-3.00# cat /mydisk/deepak.txt
bash-3.00# umount -f /mydisk/
This is a test message
Reverting back to metadevice ie, RAID-1 volume.
bash-3.00# mount /dev/md/dsk/d0 /mydisk/



Wednesday, June 16, 2010

Glassfish v2 Cluster,HA, Load-balancing

I happen to come accross this link which explains Cluster/Load-balancing(Sun Java System Web server 7.0)/HA on Glassfish v2 in a single page. There is sample app called 'clusterjsp' which tests the cluster setup too.