torsdag 7. juni 2012

Mount a new hard drive in Solaris



Another part of these useful guides may be a guide about how to mount external drive to Solaris and use it as ORACLE partition.
Attach a new hard drive to Solaris system and check if it is visible by Solaris. You can do this by executing a command:
# ls /dev/rdsk/*s0


or using a format command:
# format

You should get output similar to the following:




You can see that there is a two drives listed. First drive is your root drive and the second one is extra drive that we have attached to the system. From the first command, remember the path of the second drive (/dev/rdsk/s0t2d0s0).

Important: if you can’t see the second drive, then issue the following command:

# devfsadm

It is possible that Solaris is not aware of that you just added a new drive so you need to tell to Solaris to check any new hardware. Then follow the steps described above.
After selecting the appropriate drive, in our case number 1, pressing Enter and getting the message that the disk is being formated, at format prompt, you need to enter partition command:

format> partition

In my specific case, I got a message like:

WARNING - This disk may be in use by an application that has modified the fdisk table. Ensure that this disk is not currently in use before proceeding to use fdisk.

Workaround for this issue is that you type command:

format> fdisk

and answer YES to the question you get.
At last, issue the partition command and at partition menu, write:

partition> modify

We will use all free space on disk partition for ORACLE. Select the option for "All Free Hog", which should be option 1, and press ENTER. Answer "yes" when asked if you want to continue creating a new partition table.It will ask you which slice you want to be the Free Hog partition. Type 0, and then press ENTER. It will then ask you for the size of the rest of the slices, starting with 1 and working to 7. Hit ENTER for each of these. It will automatically set each one to a size of 0, meaning that it is not given any space. Since we set slice 0 to be the "Free Hog" partition, this ensures that slice 0 takes up the entire space of the drive.

You are then shown the partition table as you have just created it. Note that slice 0 contains the full size of the drive, but so does slice 2. The reason for this is that slice 2 is representative of the entire drive. You should never change it -- it is for the computer's use only.

Answer "yes" when asked if it is ok to make this the current partition table.

It will then ask you for a table name. This is completely up to you. I like to just call it "u01" or something simple like that. Press ENTER. You will then be asked if you are ready to label the disk. Answer "yes" to this question.

At the "partition>" menu, type:

partition> quit

At the "format>" menu, type:

format> save

You will be asked to enter a file name. This is the name of the file where it will save the partition information you have just created. The system reads this information from a file called /etc/format.dat However, if you notice, the line reads:

Enter file name["./format.dat"]:

If you just hit ENTER, you will be saving the partition information to a file called format.dat IN THE CURRENT DIRECTORY! This means that if you are not currently in the “/etc” directory, you will be saving the partition information to the wrong file. VERY IMPORTANT: When it asks you to enter the filename, ALWAYS type the entire pathname:

/etc/format.dat

At the "format>" prompt, type:
 
format> quit

Write a new file system to the slice ("partition."). Now it’s time to involve thing you have remembered at the beginning of this text (controller/target number). We need to issue next command and the syntax is like:

newfs /dev/rdsk/{controller/target/disk number}

In keeping with the example we've been using, to write a new filesystem to the slice we just created, type the following:

# newfs /dev/rdsk/c0t2d0s0

After hitting ENTER, you will be asked if you want to construct a new file system on the device you just specified. Answer "yes" and press ENTER.

Now, finally, we need to create a mount point (aka "directory") where you will mount the slice. The mount point can be named anything you want but since we need it for ORACLE, it is useful if we give it the name “u01”. To create the mount point, type:

# mkdir /u01

One step more: mount the slice to that mount point. Once the mount point has been created, you can manually mount the slice to the mount point by typing:

# mount /dev/dsk/c0t2d0s0 /u01

This will mount slice 0 (s0) of the second disk (t2) on the mount point, or directory, known as /u01. Since we have put the entire drive space of the second disk onto slice 0 of the second disk, consequently, the entire second disk has now been mounted (and therefore is accessible) at /u01.
One important thing to note is that when you manually mount things with the mount command, as we did above, it is only 'temporarily' mounted. By this, I mean that the next time you reboot the machine, it will no longer be mounted. To fix this, you need to edit a file called /etc/vfstab. Add a new line like:

/dev/dsk/c0t2d0s0      /dev/rdsk/c0t2d0s0     /u01     ufs       2          yes       -

onsdag 6. juni 2012

Adding more SWAP space in Solaris 10



In addition to installing ORACLE 11g R2 on Solaris 10, this articles explain how you can add swap space on Solaris. In Oracle 11g R2 you need couple of Gbytes of SWAP space so if you need it to start ORACLE installation, the steps below can help you in adding additional swap space. Here is useful table for determine how much SWAP space you actually need (recomended by ORACLE):

RAM                                     Swap Space
Between 1 GB and 2 GB      1.5 times the size of RAM
Between 2 GB and 16 GB    Equal to the size of RAM
More than 16 GB                  16 GB

Here is the procedure:

1.
Login as root and check how much swap space you have from the following command.
# swap –l

2. We guess that you have not enough of SWAP space so we will create swap file. As root, use mkfile to create a swap file:
# mkfile filesize /path/file
e.g.
# mkfile 3072m /export/home/oracle/swap1

3. Add the file create above in the swap area.
# swap -a /path/file
e.g.
# swap -a /export/home/oracle/swap1

4. Check the swap space again
# swap -l

Done. You have now enough of SWAP space so you can proceed with the ORACLE installation process.

Oracle Database 11g Release 2 (11.2.0.2) Installation On Solaris 10 (x86-64)



This is my experience of installing Oracle 11g R2 on Solaris 10 based on instructions from the oracle-base.com web page.

For this installation you need Solaris 10 (x86-64) and ORACLE Database 11g R2. Both things you can download from ORACLE’s web page. I assume that you have Solaris 10 installed already so let’s proceed with the ORACLE.
When I’ve tried for first time to install this combination, I got some errors like that ORACLE can’t access some of the installation files. It took me a lot of time to figure it out what happened. Well, as a root, I’ve unpacked ORACLE installation files but the whole installation process is conduct with an oracle user. Off course, that was a privileges issue. SO, my advice is: do not extract yet installation files before oracle user is created. OR, you can extract them as a root and play a little bit with the privileges. I took the first option.


SOLARIS SETUP

Log in
Log in as root user.

Check hosts-file
The "/etc/hosts" file must contain a fully qualified name for the server.
<IP-address>  <fully-qualified-machine-name>  <machine-name>
Usually, this is done already by Solaris installation so there is not much to worry about.
Here is mine:
::1     localhost
127.0.0.1       localhost
192.168.10.1    SolarisORA.testdomain.com      loghost

Set Kernel Parameters
This is something that should not bother you much for now but in order to ORACLE “glide” on your Solaris, you need to setup kernel of the operating system. First, check the release of the Solaris. You need Solaris 10 U6 at least, to run ORACLE 11g R2 database. You probably don’t need this if you download nowadays Solaris but still…
# cat /etc/release
                    Oracle Solaris 10 9/10 s10x_u9wos_14a X86
     Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
                            Assembled 11 August 2010
#
We need to add a new project entry to the /etc/project file, so, as root, issue the following command.
# projadd oracle
In some the the installation guides I saw that they recommend next move to edit /etc/user_attr file but in my case that didn’t work. I got a password inconsistency problem. As a workaround, I’ve delayed this step after creating oracle user.  SO, let’s create it:
# groupadd oinstall
# groupadd dba
# groupadd oper

# useradd -g oinstall -G dba -d /export/home/oracle oracle
# mkdir /export/home/oracle
# chown oracle:oinstall /export/home/oracle
# passwd -r files oracle
Here you’ll must enter a password for oracle user and pay attention on password requirements.
Create the directories in which the Oracle software will be installed.
# mkdir -p /u01/app/oracle/product/11.2.0.2/db_1
# chown -R oracle:oinstall /u01
In my case, installation is performed on separate hard disk which is mounted on “/u01” partition which is some kind of standard. How to mount hard disk on “/u01”, you can find also on my blog.
If you will just test the database and won’t use any extern hard disk, you can install the software in the "/export/home/oracle" directory as follows.
# mkdir -p /export/home/oracle/u01
# ln -s /export/home/oracle/u01 /u01
# mkdir -p /u01/app/oracle/product/11.2.0.2/db_1
# chown -h oracle:oinstall /u01
# chown -R oracle:oinstall /export/home/oracle/u01

Now, at last, you must edit and apend "/etc/user_attr" file:
oracle::::project=oracle

Next, we’ll play little bit with a memory. Open new terminal window and login as oracle user. In first terminal window when you still have a root session, issue the following command:

# prctl -n project.max-shm-memory -i project oracle

You’ll get the output something like:


project: 100: oracle
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
project.max-shm-memory
        privileged       510MB      -   deny                                 -
        system          16.0EB    max   deny                                 -
#
We need to change max-shm-memory parameter value so issue the following commands as root but keep terminal window with oracle user logged in active
# prctl -n project.max-shm-memory -v 4gb -r -i project oracle
# projmod -s -K "project.max-shm-memory=(priv,4gb,deny)" oracle
The first dynamically resets the value, while the second makes changes to the "/etc/project" file so the value is persistent between reboots. You can check what those commands did to the /etc/project file:
# cat /etc/project
system:0::::
user.root:1::::
noproject:2::::
default:3::::
group.staff:10::::
oracle:100::::project.max-shm-memory=(priv,4294967296,deny)
#
Next, add the following lines to the “/etc/inittab” file, before the entry for “startd”.
Tm::sysinit:/usr/sbin/ndd –set /dev/tcp tcp_smallest_anon_port 9000 > /dev/console
tm::sysinit:/usr/sbin/ndd –set /dev/tcp tcp_largest_anon_port 65500 > /dev/console
tm::sysinit:/usr/sbin/ndd –set /dev/udp udp_smallest_anon_port 9000 > /dev/console
tm::sysinit:/usr/sbin/ndd –set /dev/udp udp_largest_anon_port 65500 > /dev/console
Append the following line to the “/etc/system” file.
set maxusers=16384
That’s it, now we need few more steps to complete the system preparation.
Reboot the Solaris.

We need to check for those necessary packages in Solaris. Check to see which of the required 13 packages are already installed.
# pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibC SUNWlibm SUNWlibms SUNWsprot \
  SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt SUNWcsl

system      SUNWarc   Lint Libraries (usr)
system      SUNWbtool CCS tools bundled with SunOS
system      SUNWcsl   Core Solaris, (Shared Libs)
system      SUNWhea   SunOS Header Files
system      SUNWi1of  ISO-8859-1 (Latin-1) Optional Fonts
system      SUNWlibC  Sun Workshop Compilers Bundled libC
system      SUNWlibm  Math & Microtasking Library Headers & Lint Files (Usr)
system      SUNWlibms Math & Microtasking Libraries (Usr)
system      SUNWsprot Solaris Bundled tools
system      SUNWtoo   Programming Tools
system      SUNWxwfnt X Window System platform required fonts
ERROR: information for "SUNWi1cs" was not found
ERROR: information for "SUNWi15cs" was not found
#
Add the "SUNWi1cs" and "SUNWi15cs" packages using the "pkgadd" command.
# pkgadd -d /cdrom/sol_10_811_x86/Solaris_10/Product SUNWi1cs SUNWi15cs

Processing package instance <SUNWi1cs> from
< /cdrom/sol_10_811_x86/Solaris_10/Product>

X11 ISO8859-1 Codeset Support(i386) 2.0,REV=2004.10.17.15.04
Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.

This appears to be an attempt to install the same architecture and
version of a package which is already installed.  This installation
will attempt to overwrite this package.

Using </> as the package base directory.
## Processing package information.
## Processing system information.
   16 package pathnames are already properly installed.
## Verifying package dependencies.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

This package contains scripts which will be executed with super-user
permission during the process of installing this package.

Do you want to continue with the installation of <SUNWi1cs> [y,n,?] y

Installing X11 ISO8859-1 Codeset Support as <SUNWi1cs>

## Installing part 1 of 1.

Installation of <SUNWi1cs> was successful.

Processing package instance <SUNWi15cs> from </cdrom/sol_10_106_x86/Solaris_10/Product>

X11 ISO8859-15 Codeset Support(i386) 2.0,REV=2004.10.17.15.04
Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.

This appears to be an attempt to install the same architecture and
version of a package which is already installed.  This installation
will attempt to overwrite this package.

Using </> as the package base directory.
## Processing package information.
## Processing system information.
   21 package pathnames are already properly installed.
## Verifying package dependencies.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

This package contains scripts which will be executed with super-user
permission during the process of installing this package.

Do you want to continue with the installation of <SUNWi15cs> [y,n,?] y

Installing X11 ISO8859-15 Codeset Support as <SUNWi15cs>

## Installing part 1 of 1.

Installation of <SUNWi15cs> was successful.
#
Now, say goodbye for now to the root user and create a new session with an oracle user. Edit or create a “/export/home/oracle/.profile“ file and add the following lines:
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

# Select the appropriate ORACLE_BASE
ORACLE_HOSTNAME=SolarisORA.testdomain.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=ORASOL; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.2/db_1; export ORACLE_HOME
ORACLE_SID=ORASOL; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH

Just in case you are using X emulation then set the DISPLAY environmental variable.
# DISPLAY=<machine-name>:0.0; export DISPLAY

Finally, unzip the files “solaris.x64_11gR2_database_1of2.zip” and “solaris.x64_11gR2_database_2of2.zip”  in the “/u01” directory.
You should now have a single directory called "database" containing installation files in “/u01” partition.

Finally!
Go to “/u01/database directory” and start the Oracle Universal Installer (OUI) by issuing the following command in the database directory.
./runInstaller
Important is that you choose right OSDBA group (oinstall), set database name, set administrative password and choose database edition.
 
Also, you must set the Inventory location and inventory group name (oinstall):
 
After the installation…
Edit the "/var/opt/oracle/oratab" file setting the restart flag for each instance to 'Y'.
ORCLMAN:/u01/app/oracle/product/11.2.0.2/db_1:Y