Monday, March 25, 2013

Using Windows 7 to host PHP applications in 5 easy steps!

A few people have asked me recently whether it’s possible to setup Windows 7 as a PHP server (for development purposes).  The answer is absolutely yes, and it’s a breeze to setup.  Follow these five simple steps to get PHP up and running in minutes:

1.  In the Programs and Features control panel, click on the Turn Windows features on or off link:

image

 2.  In the list of Windows Features, expand Internet Information Services, World Wide Web Services, and the Application Deployment Features.  If it’s not already, select the CGI checkbox and click OK.  (The most reliable way of hosting PHP applications on Windows 7 is to use the built in FastCGI interface for IIS – checking this box installs it together with any pre-requisites.)

image

3.  Download the non-thread-safe (NTS) version of PHP from http://www.php.net/downloads.php.  The current version (as of time of writing is 5.2.9).  (The thread safe (TS) version will also work, but generally NTS is faster, and thread safety is not an issue under FastCGI).  Expand the zip to an installation directory of your choice – e.g. c:devphp
4.  Copy the php.ini-recommended file to php.ini in the PHP directory.  Edit the php.ini file and add correctly configure extension_dir, pointing to the PHP extensions directory (normally the .ext folder of the PHP installation – e.g c:devphpext).  You can also configure other php.ini options and modules here if required.
5.  Run Internet Information Services Manager by typing inetmgr in the Start menu.  You can either set the global settings of the server, or (recommended) add a new web site to run the PHP applications.  Once you’ve done this, double click on the Handler Mappings for the site and add a new module mapping with the following settings:

image
Request path should be set to *.php.  Module should be FastCgiModule.  Executable should be {php_install_dir}php-cgi.exe.  Name can be anything – I use “PHP via Fast CGI”.
That’s it! Simply start/restart IIS and you are ready to go.  The easiest way to test that everything is working is to create a simple info.php file with a single line:
<?php phpinfo(); ?>
When you access this page from a browser (e.g. http://localhost:8081/info.php), you should see the PHP info screen:

image

Validate that the server API is using CGI/FastCGI and that the loaded configuration file is the one in your installation directory.

Host PHP Website on Microsoft IIS

PHP is one of the most well known and used scripting languages for web applications in the Open Source and Linux world. However, it might be useful to know that you can not only run PHP on Windows servers using Internet Information Services, but also connect to SQL Server for data. Now why would you want to do that, one may ask given that Windows (and hence IIS) as well as SQL Server are proprietary products. There are a few reasons for this. First off, on Windows Server 2008 using IIS7, PHP applications get access to a number of features that are not available to them on other platforms easily. For instance, you can enable features like caching, HTTP redirection, membership and role management and many more IIS features and have them work with PHP natively – without changing the PHP code at all. A detailed look at the IIS7 Integrated Pipeline describing this was published in the December 2007 issue of PCQuest.

SQL Server is also a good target for PHP applications as it too offers a number of features that RDBMSs like PostGreSQL and MySQL do not. This includes a higher level of scalability, enterprise class features and query optimizers. You can even get a lot of these benefits with the free SQL Server Express editions as well. So in case you have mission critical applications or wish to make your PHP application target multiple databases, this is something that you can do quite easily.

Coming back to how you can setup PHP on IIS7 and for SQL Server, you need to get the latest version of PHP from either www.php.net or get the installable off the DVD included with this issue. Make sure IIS7 with CGI support is installed on the Windows Server 2008 machine. Open Server Manager | Roles | Web Server | Add Role Services and check the CGI option and install if not already done so. Now go ahead and install the MSI for the PHP install. Select the IIS with FastCGI support when prompted and install any extensions you wish. Next, open IIS Manager and select the server. On the right pane, open Handler Mappings. In the rightmost action pane, select Add Module Mapping. In the dialog that comes up, enter “*.php” for type, “FastCGI” for module, “C:\Program Files\PHP\php-cgi-exe” for executable and “PHP with FastCGI” as name.


While installing PHP, make sure you select the IIS FastCGI option.
Once complete, get the SQL Server Driver for PHP from Microsoft's site or off the DVD included. Run the file and extract the files to a temporary folder. Copy the php_sqlsrv_st.dll to c:\Program Files\PHP\ext. Open the PHP.ini file and add the line extension=php_sqlsrv_st.dll in the “Extensions” section. Save this and restart the Web server.

You are now ready to check out your PHP install as well as start writing PHP code that works with SQL Server. First off, create a simple text file in Notepad with the following code and save it as test.php as your Web server's web root folder. For instance in c:\inetpub\wwwroot\ php\test.php.


The “phpinfo()” page should show the “sqlsrv” section if the extension is installed correctly.
phpinfo();
?&gt;

Open Internet Explorer and point to http://localhost/ php/test.php. You should now see the PHP status information page. Check out whether the extension named sqlsrv is loaded. Now comes the time to actually connect to the database. For this, there is one more optional step that you may need to perform.


A page that connects to SQL Server 2008 and retrieves some data using the SQL Server driver for PHP.
In case you are running SQL Server 2005 on the same machine as where the PHP code is running, you need not do anything, but write your code. However, in case you are running SQL Server 2005 on a remote machine or SQL Server 2008 on the same or a remote machine, you will need to install the SQL Server 2005 Native Client on the Web server. This is because although the MS driver for PHP is optimized to work with SQL Server it works only with the SQL Server 2005 native client. You can download this from the Microsoft site or get it off the DVD. After this, you can start writing code to connect to SQL Server. Take a look at the code below for a small sample.

"AdventureWorks2008", "UID"=&gt;"sa", "PWD"=&gt;"password");$conn = sqlsrv_connect("(local)", $connectionInfo);if( $conn === false ){ echo "Could not connect.
"; die( print_r( sqlsrv_errors(), true));}$tsql = "SELECT ProductID, UnitPrice, StockedQty FROM Purchasing.PurchaseOrderDetail WHERE StockedQty &lt; 3 AND DueDate='2002-01-29'";$stmt = sqlsrv_query( $conn, $tsql);if ( $stmt ) echo "Statement executed.

";else { echo "Error in statement execution.
"; die( print_r( sqlsrv_errors(), true));}while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC)){ echo "ProdID: ".$row[0]."
"; echo "UnitPrice: ".$row[1]."
"; echo "StockedQty: ".$row[2]."
";}sqlsrv_free_stmt( $stmt);sqlsrv_close( $conn);?&gt;

Save this file as say get.php in the same location and browse over to http://localhost/php/get.php. You should see a few records from the AdventureWorks database being shown. The SQL Server driver for PHP is a great way of connecting to SQL Server databases from PHP. Written by Microsoft themselves, this offers much better performance and stability than stock or 3rd party drivers. As mentioned, if you have the option of using PHP on IIS7 and SQL Server for a large and scalable application, it makes a good choice to do so and these drivers let you work very nicely with the database. Do note that these drivers are open source and Microsoft has supplied the source at CodePlex where you can download, view and change them if you wish.

Oracle Interview Questions for Freshers

Hello Friends 
I am posting here the most common question which are asked in interviews  to thcandidates who are having experience of 0 to 6 Months.

1. What is Oracle table?
     A table is the basic unit of data storage in an Oracle database. The tables of a database hold all of the
     user accessible data. Table data is stored in rows and columns.

2. What are Clusters?
    Clusters are groups of one or more tables physically stores together to share common columns and are often used together.         

3. What is an Index
     An Index is an optional structure associated with a table to have direct access to rows, which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.

4. What are the advantages of views?
  • Provide an additional level of table security, by restricting access to a predetermined set of rows and columns of a table.
  • Hide data complexity.
  • Simplify commands for the user.
  • Present the data in a different perspective from that of the base table
  • Store complex queries.

5.  What are the various types of queries?
     
     The types of queries are :
  • Normal Queries
  • Sub Queries
  • Co-related queries
  • Nested queries
  • Compound queries

 6. What is the difference between clustered and a non-clustered index?
       A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.

     A Nonclustered index is a special type of index in which the logical order of the index does  not match the physical stored order of the rows on disk.
    

7. What is a Tablespace?
     A database is divided into Logical Storage Unit called tablespace. A tablespace is used to grouped related logical structures together. 

8. Why use materialized view instead of a table?
     Materialized views are basically used to increase query performance since it contains results   of a query. They should be used for reporting instead of a table for a faster execution.

9. What does ROLLBACK do?
     ROLLBACK retracts any of the changes resulting from the SQL statements in the transaction.

10. Compare and contrast TRUNCATE and DELETE for a table?
       Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves  the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete. 

11. What is the usage of SAVEPOINTS?
      SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.

12. What is cluster key?
        The related columns of the tables are called the cluster key. The cluster key is indexed using a cluster  index and its value is stored only once for multiple tables in the cluster.

13.What is DECODE function used for?

      DECODE is used to decode a CHAR or VARCHAR2 or NUMBER into any of several different character strings or numbers based on value. That is DECODE does a value-by-value substitution.

14. What is the difference between Explicit and Implicit Cursors?

An Implicit cursor is one created "automatically" for you by Oracle when you execute a query. It is simpler to code  
An Explicit cursor is one you create yourself. It takes more code, but gives more control - for example, you can just open-fetch-close if you only want the first record and don't care if there are others DBA_DATA_FILES.

15. What are the different index configurations a table can have?
  • A table can have one of the following index configurations
  • No indexes
  • A clustered index
  • A clustered index and many nonclustered indexes
  • A nonclustered index
  • Many nonclustered indexes.
16.What is BCP? When does it used? 

BulkCopy is a tool used to copy huge amount of data from tables and views. BCP does not copy the structures same as source to destination.

17.How to know which index a table is using?

SELECT table_name,index_name FROM user_constraints.

18.  How many LONG columns are allowed in a table? Is it possible to use LONG columns in WHERE clause or ORDER BY?

Only one LONG column is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

19. What is the maximum number of triggers, can apply to a single table?
     
 12 triggers

20. What are the differences between stored procedures and triggers?
A stored procedures are compiled collection of programs or SQL statements that live in the database. A stored procedure can access and modify data present in many tables. Also a stored procedure is not associated with any particular database object. But triggers are event-driven special procedures which are attached to a specific database object.

21. Explain the difference between a data block, an extent and a segment?

A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object.

22. What are ORACLE PRECOMPILERS?

  A precompiler is a tool that allows programmers to embed SQL statements in high-level source programs like C, C++, COBOL, etc.The precompiler accepts the source program as input, translates the embedded SQL statements into standard Oracle runtime library calls, and generates a modified source program that one can compile, link, and execute in the usual way.

23.What are the dictionary tables used to monitor a database spaces ? 
  • DBA_FREE_SPACE
  • DBA_SEGMENTS
  • DBA_DATA_FILES


Wednesday, March 20, 2013

The 40 Most Common Oracle Errors


Using tools Google have made available, I have put together a list of the ORA messages we collectively searched for the most in the first month of 2012. These messages  are a mix of those generic errors that can mean pretty much anything, the error messages we see most rarely, and those common error numbers that we never seem able to memorise.

ORA-12154: TNS:could not resolve the connect identifier specified (#1)

Coming in at number 1, and googled more than twice as often as any other error message, this error is, almost appropriately, often the very first one you get on trying to establish a connection to your database. Simply put, it means that you have named the database you wish to be connected to and Oracle doesn’t know who the heck you’re talking about.
This error is often caused by typos, maybe in your connection string, but possibly in your tnsnames.ora file. It is also possible that the tnsnames.ora file is not accessible or does not even exist. If it does, ensure that it contains the service name you are using; also go over it with a fine toothcomb to make sure it doesn’t have any unpaired parentheses or such.

ORA-00600: internal error code, arguments: [%s], [%s],[%s], [%s], [%s] (#2)

Coming in at number 2 is a generic error; it means something serious has gone wrong and you are going to need to roll up your sleeves, dig in, and find out what. But you are not without clues. Your alert.log file will contain the path to your trace file. You will want to look in it, as a record is written to the trace file every time an ORA-00600 error occurs. Take the information you get from your trace file and the first argument in the square brackets (the internal message number), and head over to My Oracle Support (Metalink). There you will find a handy ORA-0600 lookup tool (Note 153788.1) that will direct you to additional information that will help you solve your problem.

ORA-1722: Invalid Number (#3)

You get this error when your SQL tries to convert a non-numeric string into a number. This conversion might be explicit – to_number(‘I am looking for trouble’) – or implicit.
This error often arises when you have a table with a varchar2 column in which you store nothing but numbers. You know that this is bad practice, but you know you will get away with it as long as you strictly store nothing but numbers in the column and all your procedures treat the contents of the column as numeric. But then, one day, you hire a new developer and, seeing that the column is varchar2, he inserts a ‘two’ – instead of 2 – into it. And suddenly all the procedures and functions that reference this column clutch their chests and die.

ORA-03113: end-of-file on communication channel (#5)

This error pretty much means that your connection has clutched its chest and died. For some reason, your client machine and the database server are acting like an old married couple and have stopped talking to each other. That reason could be one of a rather long list: has your server crashed? has someone pulled out your network cable? was your process killed at the O/S level? is your Windows log full? or maybe there is an Oracle internal error?
My advice is this: do not overlook the obvious. This error is sometimes caused by the simplest of things. If, however, it is caused by an Oracle internal error, look to your alert log for further information.

ORA-01000: maximum open cursors exceeded (#23)

You get this error when a user of a host program attempts to open more cursors than they are allowed. The number of cursors allowed is dictated by the OPEN_CURSORS initialization parameter, and this quota can be eaten up by both implicit and explicit cursors. If you run into this error, there is a possibility that there is a bug in your application. Perhaps you’ve got an open cursor statement within a loop and you do not have a matching close cursor, and as a result your code is bleeding cursors all over the place.
However, it is possible that the OPEN_CURSORS number is just too low for the needs of your application and has to be upped. The default value is 50; however, the only factor limiting how high this number can go – 300, 1000, 2000 even – is what the operating system can take. However, it may be unwise to choose to change the OPEN_CURSORS parameter too steeply, rather than examine your code for leaks. That’ll be like thinking you can save yourself from drowning by drinking the sea.

Conclusion

I am not going to be able to analyse all of the Top 40 error messages given the constraints of space. Please inspect the list below (it’s interesting to see what we all search for the most anyway) and if you see an error that you feel you can provide succinct advice for, please add it to the comments section.
 

Top 40 Most Searched For Oracle Errors

Position Error Global Monthly Searches*
1 ORA-12154 101,500
2 ORA-00600 40,500
3 ORA-01722 27,100
4 ORA-12560 22,200
5 ORA-03113 18,100
6 ORA-00604 14,800
7 ORA-00936 12,100
8 ORA-01017 12,100
9 ORA-01555 12,100
10 ORA-04031 12,100
11 ORA-00257 12,100
12 ORA-27101 12,100
13 ORA-00911 12,100
14 ORA-00933 9,900
15 ORA-01403 9,900
16 ORA-01422 9,900
17 ORA-04030 9,900
18 ORA-00932 9,900
19 ORA-01031 8,100
20 ORA-20000 8,100
21 ORA-12560 8,100
22 ORA-06508 8,100
23 ORA-01000 6,600
24 ORA-12505 6,600
25 ORA-20001 6,600
26 ORA-12519 6,600
27 ORA-01008 6,600
28 ORA-00054 6,600
29 ORA-01830 6,600
30 ORA-00907 6,600
31 ORA-00984 6,600
32 ORA-01461 5,400
33 ORA-01110 5,400
34 ORA-00001 5,400
35 ORA-02010 5,400
36 ORA-12537 5,400
37 ORA-03135 5,400
38 ORA-01034 5,400
39 ORA-00918 5,400
40 ORA-04063 5,400

*Figures based on Google Adwords Keyword tool global monthly search average.

Tuesday, March 19, 2013

Silent Installation of Oracle 11g on RHEL 6.0

In this blog post, we are going to silently install Oracle 11.2.0.3 64-bit on RedHat 6.0 using VMWare Workstation 8.

This install demonstration is going to use the silent install mode for all components. At least within the guest VM, at no point will we use a GUI for the install. We will need to use the VMWare GUI to create the VM, install the OS and add disks.
With the increasing use of VMWare, many organizations are looking to automate the deployment of Oracle database environments for development, test or validation. And increasingly DBAs are being tasked with automating the provisioning process.

Note that even though Oracle provides “silent” install options for all of the installer programs, many of them still need a functioning graphic display. The installer programs are not able to disable the sub-routines that would typically render the GUI, and so they will fail if the Linux environment does not include a display. If need to install in an environment where there is no display, you can set the environment DISPLAY variable to another X-host or VNC server.
Whereas this demonstration is not completely automated, it might form the basis of a fully scripted database deployment model for non-production use.
Note: This blog post recycles a good deal of material from the Installing Oracle 11.2.0.3 on CentOS 6.3 on VMWare Workstation 8 post, but shows how to do the install silently. The target OS in this sample was RedHat 6.0.
Time Required: 70 minutes
Class Materials:
  • An x86 64-bit computer with 2GB RAM and 10GB of hard disk space.
  • A minimum of a 1024×768 display with 256 colors.
  • VMWare Workstation 8 or better.
  • Whatever OS VMWare Workstation needs to run on. In my case I run it on Windows 7 Professional.
  • Oracle Grid and Database software version 11.2.0.3.
You can download the software you need from the following links.
Note that for Oracle, we need the 11.2.0.3 version of the software, not the 11.2.0.1 that is available from download.oracle.com. Oracle 11.2.0.1 is not supported on RedHat 6. As far as I know you will need to get this from My Oracle Support, and you are looking for patch number 10404530 which will give you access to seven zip files. You only need the first three zip files.
Software Download Summary:
Software Product Download Link
VMWare Workstation VMWare Workstation download
RedHat 6.0 64-bit RedHat Linux 6.0 download
Oracle 11.2.0.3 Database Oracle 11gR2 11.2.0.3 Grid for x86 64-bit Download
Oracle 11.2.0.3 Grid Oracle 11gR2 11.2.0.3 Database for x86 64-bit Download


Part I – Create the RedHat VM.

Time Required: 10 mins.
First we need to create a RedHat VM. I created a new VM using the VMWare Workstation wizard. VMWare Workstation 8 recognizes the RedHat 6.0 install ISO image as RedHat 64-bit and allows Easy Installer to do most of the work.
I created my VM with 2GB RAM and a single 60GB SCSI disks.


Part II – Add Required RPMs.

Time Required: 10 mins.
Oracle 11.2.0.3 requires extra RPMs from the install media.
The following command should load all needed RPMs for 11.2.0.3 Grid and Database.
rpm -ivh compat-libstdc++-33-3.2.3-69.el6.*.rpm \
 elfutils-devel-0.148-1.el6.x86_64.rpm \
 elfutils-libelf-devel-0.148-1.el6.x86_64.rpm \
 gcc-c++-4.4.4-13.el6.x86_64.rpm \
 glibc-2.12-1.7.el6.i686.rpm \
 glibc-devel-2.12-1.7.el6.i686.rpm \
 libaio-devel-0.3.107-10.el6.x86_64.rpm \
 libaio-0.3.107-10.el6.i686.rpm \
 libgcc-4.4.4-13.el6.i686.rpm \
 libstdc++-devel-4.4.4-13.el6.x86_64.rpm \
 libtool-ltdl-2.2.6-15.5.el6.i686.rpm \
 nss-softokn-freebl-3.12.7-1.1.el6.i686.rpm \
 readline-6.0-3.el6.i686.rpm \
 ncurses-libs-5.7-3.20090208.el6.i686.rpm \
 libcap-2.16-5.2.el6.i686.rpm \
 libattr-2.4.44-4.el6.i686.rpm \
 compat-libcap1-1.10-1.*.rpm

Please note that not all the above RPMs are listed by the Oracle Installer as required. However testing has shown that they are needed to complete the install.
With our install DVD ISO mounted to the VM, log in as root, shift to the package install directory and execute the command:
[root@localhost ~]# cd "/media/RHEL_6.0 x86_64 Disc 1/Packages"

RedHat should respond with:
warning: compat-libstdc++-33-3.2.3-69.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:libstdc++-devel        ########################################### [  5%]
   2:elfutils-libelf-devel  ########################################### [ 11%]
   3:libgcc                 ########################################### [ 16%]
   4:elfutils-devel         ########################################### [ 21%]
   5:nss-softokn-freebl     ########################################### [ 26%]
   6:glibc                  ########################################### [ 32%]
   7:compat-libstdc++-33    ########################################### [ 37%]
   8:gcc-c++                ########################################### [ 42%]
   9:compat-libcap1         ########################################### [ 47%]
  10:libaio                 ########################################### [ 53%]
  11:ncurses-libs           ########################################### [ 58%]
  12:libattr                ########################################### [ 63%]
  13:libcap                 ########################################### [ 68%]
  14:readline               ########################################### [ 74%]
  15:compat-libstdc++-33    ########################################### [ 79%]
  16:libtool-ltdl           ########################################### [ 84%]
  17:compat-libcap1         ########################################### [ 89%]
  18:libaio-devel           ########################################### [ 95%]
  19:glibc-devel            ########################################### [100%]

If you want the pdksh RPM then you will have to download it from the web. I downloaded it from ftp.pbone.net. RedHat 6.0 has all the required supporting packages for it.
[root@localhost ~]# rpm -ivh pdksh-5.2.14-30.x86_64.rpm
warning: pdksh-5.2.14-30.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 73307de6: NOKEY
Preparing...                ########################################### [100%]
   1:pdksh                  ########################################### [100%]


Part III – Configure the Kernel.

Time Required: 10 mins.
Next we need to configure the RedHat 6.0 Linux kernel to support Oracle 11gR2 11.2.0.3.
Before we can install Oracle 11.2.0.3 on our new VM, we need configure the Linux kernel. The following steps modify key settings to allow Oracle to execute. We will also disable the NTP time synchronization configuration file which will confuse the Oracle installer.
Edit the /etc/sysctl.conf and add following lines:
# added for Oracle 11.2.0.3
kernel.shmall = 2097152
kernel.shmmax = 1050470400
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

Now execute sysctl -p command to apply the new settings:
Edit the /etc/pam.d/login file and add following line:
# added for Oracle 11.2.0.3
session    required     pam_limits.so

Edit the /etc/security/limits.conf file and add following lines:
# added for Oracle 11.2.0.3
oracle    soft  nproc   2047
oracle    hard  nproc   16384
oracle    soft  nofile  1024
oracle    hard  nofile  65536

Check current status of SELinux:
[root@localhost ~]# /usr/sbin/getenforce
Enforcing

If output is Enforcing then change mode to Permissive as follows:
[root@localhost ~]# /usr/sbin/setenforce 0

To make the change permanent, modify the /etc/sysconfig/selinux change value of SELINUX variable to disabled:
[root@localhost ~]# cat /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

Disable the NTP configuration file
[root@localhost ~]# cd /etc
[root@localhost etc]# mv ntp.conf ntp.conf.bak

Now we have the RedHat 6.0 Linux kernel ready for Oracle 11.2.0.3.


Part IV – Add the Oracle User.

Time Required: 10 mins.
Next we need to create the Oracle user account, OS groups and mount point.
The Oracle software will be installed and owned by the oracle user account. In additional several OS groups are created that allow other non oracle OS users privileged access to the database and grid resources.
Login as root and create the user oracle account and the OS groups:
[root@localhost ~]# groupadd dba
[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd asmdba
[root@localhost ~]# groupadd asmadmin
[root@localhost ~]# useradd -g oinstall -G dba,asmdba,asmadmin oracle

Now set the password for the oracle user. Since this is development, I suggest we stick with “oracle”.
[root@localhost ~]# passwd oracle
Changing password for user oracle.
New UNIX password: 
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password: 
passwd: all authentication tokens updated successfully.

Now we create a directory into which the oracle software will be installed. We need to set this new directory to be owned by oracle:
[root@localhost ~]# mkdir /u01
[root@localhost ~]# mkdir /u01/app
[root@localhost ~]# chown oracle:dba /u01/app

Now we can log into our new oracle account and configure the bash profile:
[root@localhost ~]#  su - oracle
[oracle@localhost ~]$  vi ~/.bash_profile

Add the following lines to the profile script:
LD_BIND_NOW=1; export LD_BIND_NOW
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=`hostname`; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
    ulimit -p 16384
    ulimit -n 65536
  else
    ulimit -u 16384 -n 65536
  fi
fi


Part V – Add Disk for ASM.

Time Required: 20 mins.
At this point we are going to shut down our VM and add a second SCSI disk. Using the VMWare Workstation menu, select Create a new virtual disk and then select SCSI. Do not check Independent. Disk size should be 5GB or larger. It doesn’t matter if the disk is fully allocated immediately or if the disk is split into multiple parts.
Once the disk is added, navigate to the directory where the VM files are stored and edit the VMX file. Add the following directive:
disk.EnableUUID = "TRUE"

This directive is needed to allow VMWare Workstation to provide unique SCSI identifiers to Linux.
Now you can restart the VM.
When the VM is restarted, log in as root and use fdisk to partition the new disk. In this example we have added /dev/sdb
Set the partition offset to 2048 sectors.
[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-10485759, default 63): 2048
Last sector or +size or +sizeM or +sizeK (2048-10485759, default 10485759): 
Using default value 10485759

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

With the new disk added, we can use scsi_id to determine the SCSI identifier of the new device:
[root@localhost ~]# scsi_id -g -u -d /dev/sdb
36000c29721f0ef917cf4b6179923ed12

So the SCSI identifier of the new disk is 36000c29721f0ef917cf4b6179923ed12. We can now use this with UDEV rules to set the permission of the new device as well as an alias.
We are going to create (or edit) a file in the /etc/udev/rules.d directory. In this case we are calling our file 50-udev.rules.
[root@localhost ~]# vi /etc/udev/rules.d/50-udev.rules

And we add the following line – this should all be one line:
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", 
RESULT=="36000c29721f0ef917cf4b6179923ed12", NAME="oracleasm/asm-disk1", 
OWNER="oracle", GROUP="dba", MODE="0660"

In the above example we have instructed RedHat to create an alias called /dev/oracleasm/asm-disk1 when it finds the SCSI ID 36000c29721f0ef917cf4b6179923ed12. The alias will be owned by the oracle user and have permissions of 660.
I chose this alias as it matches those used by the old ASMLib.
Once the file is created, we restart udev as follows:
[root@localhost ~]# /sbin/start_udev
Starting udev:                                             [  OK  ]

We can now check that the alias exists:
[root@localhost ~]# ls -al /dev/oracleasm/*
total 0
drwxr-xr-x  2 root   root    60 Nov  6 12:27 .
drwxr-xr-x 19 root   root  3900 Nov  6 12:27 ..
brw-rw----  1 oracle dba  8, 17 Nov  6 12:27 asm-disk1


Part VI – Install Grid.

Time Required: 5 mins.
Next we will install the Grid Infrastructure home to provide support for ASM.
For Oracle 11.2.0.3 this means unzipping file p10404530_112030_platform_3of7.zip.
This will create a grid directory. Since we are going to install the Grid in silent mode, we need a response file. The response file will provide instructions to the installer program on how we want Oracle 11.2.0.3 Grid configured.
Change into the grid directory and launch the runInstaller script as follows:
[oracle@localhost grid]$ ./runInstaller -silent -force -responseFile $HOME/grid.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 50568 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4031 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-01-10_08-16-23AM. Please wait ...[oracle@localhost grid]$ You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2013-01-10_08-16-23AM.log
The installation of Oracle Grid Infrastructure was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2013-01-10_08-16-23AM.log' for more details.

As a root user, execute the following script(s):
 1. /u01/app/oraInventory/orainstRoot.sh
 2. /u01/app/11.2.0/grid/root.sh


Successfully Setup Software.

[oracle@localhost grid]$

At the conclusion of the install, we will need to log in as root as execute the two scripts shown.
Note that in my response file I have selected to install only the software, and not create a Grid infrastructure by setting the following option:
oracle.install.option=CRS_SWONLY

Other important directives in the response file include:
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/11.2.0/grid

The interested DBA should examine the grid response file in detail before selecting this method of install, and be comfortable with all the directives being used.
My complete grid.rsp file can be found here: grid.rsp. WordPress does not allow straight text files to be uploaded, so the extension is DOC, although it is a raw ASCII text file.


Part VII – Install Database.

Time Required: 5 mins.
Next we will install the Database home.
For Oracle 11.2.0.3 this means unzipping files p10404530_112030_platform_1of7.zip and p10404530_112030_platform_2of7.zip. Note these should be unzipped into the same directory, and not separate directories as was the case in older releases.
This will create a database directory. Since we are going to install the Database in silent mode, we need a response file. The response file will provide instructions to the installer program on how we want Oracle 11.2.0.3 Database software configured.
Change into the database directory and launch the runInstaller script as follows:
[oracle@localhost database]$ ./runInstaller -silent -force -responseFile $HOME/db.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 47617 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4023 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-01-10_11-26-40AM. Please wait ...
You can find the log of this install session at:
 /u01/app/oraInventory/logs/installActions2013-01-10_11-26-40AM.log

The installation of Oracle Database 11g was successful.
Please check '/u01/app/oraInventory/logs/silentInstall2013-01-10_11-26-40AM.log' for more details.

As a root user, execute the following script(s):
 1. /u01/app/oracle/product/11.2.0/dbhome_1/root.sh


Successfully Setup Software.

[oracle@localhost database]$

At the conclusion of the install we need to log in as root and execute the /u01/app/oracle/product/11.2.0/dbhome_1/root.sh script.
My complete db.rsp file can be found here: db.rsp. WordPress does not allow straight text files to be uploaded, so the extension is DOC, although it is a raw ASCII text file.


Part VIII – Configure Standalone ASM/GI.

Time Required: 2 mins.
We have now configured RedHat 6.0 for Oracle 11.2.0.3 and installed both Grid and Database in software-only mode. Now would be a good time to make a full backup of your VM. It is very simple to change the VM’s hostname and IP address since we not configured the Grid components or Listener yet. You can clone and deploy the template as often as you like setting new hostnames and IP addresses each time. This is also a good method if the storage at the time of deployment is not known. It might be VMFS based virtual LUNs, or it might be RDM LUNs from an array. Indeed you might even choose NFS for some less performance demanding tasks.
The Grid infrastructure must be configured from the root account, and with the ORACLE_HOME variable set to the location of the Grid software:
[root@localhost ~]# $ORACLE_HOME/perl/bin/perl -I \
  $ORACLE_HOME/perl/lib -I \
  $ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/roothas.pl
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
LOCAL ADD MODE 
Creating OCR keys for user 'oracle', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE 
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node localhost successfully pinned.
Adding Clusterware entries to upstart

localhost     2013/01/10 15:06:48     /u01/app/11.2.0/grid/cdata/localhost/backup_20130110_150648.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server


Part IX – Configure Listener.

Time Required: 1 min.
At this point it is good idea to create a listener under the Grid Infrastructure home. We can do this as follows:
[oracle@localhost grid]$ netca -silent -responsefile $ORACLE_HOME/assistants/netca/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /u01/app/11.2.0/grid/assistants/netca/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0


Part X – Create ASM Instance and Diskgroup.

Time Required: 2 mins.
In the next step, we will create an ASM instance under the Grid Infratsructure home, as well as create an initial DATA diskgroup. Make sure the ORACLE_HOME variable is set to the location of the Grid install.
In the following example we use the /dev/oracleasm/asm-disk1 disk presented by UDEV. We set the compatibility to 11.2.0.0.0 for the ASM diskgroup we are creating.
It is important we specify the diskString parameter and point it at the /dev/oracleasm/* directory.
[oracle@localhost grid]$ asmca -silent -configureASM \
  -sysAsmPassword mypassword \
  -asmsnmpPassword mypassword \
  -diskGroupName DATA \
  -diskList '/dev/oracleasm/asm-disk1' \
  -redundancy EXTERNAL \
  -au_size 1 \
  -compatible.asm '11.2.0.0.0' \
  -compatible.rdbms '11.2.0.0.0' \
  -diskString '/dev/oracleasm/*'

ASM created and started successfully.

Disk Group DATA created successfully.

The ASM instance is now running.


Part XI – Create a Database.

Time Required: 5 mins.
In the last section we create a database from the DBCA template General Purpose. In this example we set the SYSTEM and SYSDBA passwords to mypassword, use ASM diskgroup DATA for our data files and name the dataabse gctdev.
Sample schemas are also loaded into our new database, which will register with the local listener LISTENER.
dbca -silent \
  -createDatabase \
  -asmsnmpPassword mypassword \
  -characterSet WE8ISO8859P15 \
  -continueOnNonFatalErrors false \
  -disableSecurityConfiguration ALL \
  -diskGroupName DATA \
  -emConfiguration NONE \
  -gdbName gctdev.local \
  -listeners LISTENER \
  -memoryPercentage 40 \
  -recoveryAreaDestination DATA \
  -sid gctdev \
  -SysPassword mypassword \
  -SystemPassword mypassword \
  -storageType ASM \
  -sampleSchema true \
  -templateName General_Purpose.dbc

Copying database files
1% complete
3% complete
10% complete
17% complete
24% complete
35% complete
Creating and starting Oracle instance
37% complete
42% complete
47% complete
52% complete
53% complete
56% complete
58% complete
Registering database with Oracle Restart
64% complete
Completing Database Creation
68% complete
71% complete
75% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/gctdev/gctdev.log" for further details.

And that is it – the database install is now complete! And we hardly touched a GUI at all :)
Install the Oracle Grid Infrastructure software.

The Grid Infrastructure will provide the Cluster software that allows the RAC nodes to communicate, as well as the ASM software to manage the shared disks.
To begin, download the zip file from the Oracle software download website and unzip on Orpheus. Make sure you are logged into Orpheus as the oracle user so that oracle owns the unzipped files.

There is one zip file for 11gR2 Linux 64-bit called linux.x64_11gR2_grid.zip
Having unzipped it, we should have a directory called grid. It is important to be logged into Orpheus through the VM desktop and not through a non graphical interface such as Putty or SecureCRT. You may also use a tool such as VNC.
Change into the grid/sshsetup directory and we will find a script called sshUserSetup.sh
We will launch this script as follows:
[oracle@orpheus sshsetup]$ ./sshUserSetup.sh \
-user oracle -hosts "orpheus eurydice" \
-noPromptPassphrase -confirm -advanced
The output of this script is also logged into /tmp/sshUserSetup_2012-10-29-20-19-55.log
Hosts are orpheus eurydice
user is oracle
Platform:- Linux 
Checking if the remote hosts are reachable

You will be prompted for the oracle password twice during the script.
The noPromptPassphrase flag means that the script will not prompt for a pass phrase.
The confirm flag means that the script will automatically overwrite existing settings and permissions to set up the keys.
The advanced flag causes the script to set up unchallenged connections between all listed hosts, not just from the current host to the targets.
If everything is successful you should see the script complete with the following:
------------------------------------------------------------------------
--orpheus:--
Running /usr/bin/ssh -x -l oracle orpheus date to verify SSH connectivity has been setup from local host to orpheus.
IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL. Please note that being prompted for a passphrase may be OK but being prompted for a password is ERROR.
Mon Oct 29 20:21:21 PDT 2012
------------------------------------------------------------------------
--eurydice:--
Running /usr/bin/ssh -x -l oracle eurydice date to verify SSH connectivity has been setup from local host to eurydice.
IF YOU SEE ANY OTHER OUTPUT BESIDES THE OUTPUT OF THE DATE COMMAND OR IF YOU ARE PROMPTED FOR A PASSWORD HERE, IT MEANS SSH SETUP HAS NOT BEEN SUCCESSFUL. Please note that being prompted for a passphrase may be OK but being prompted for a password is ERROR.
Mon Oct 29 20:21:21 PDT 2012
------------------------------------------------------------------------
SSH verification complete.
[oracle@orpheus sshsetup]$

Now change into the grid directory and we will find a file called runcluvfy.sh
We use this script to check that our cluster is ready for the Grid install. Invoke it as follows:
[oracle@orpheus grid]$ ./runcluvfy.sh stage -pre crsinst -n orpheus,eurydice

Performing pre-checks for cluster services setup 

Checking node reachability...
Node reachability check passed from node "orpheus"

Checking user equivalence...
User equivalence check passed for user "oracle"

Checking node connectivity...

Checking hosts config file...

Verification of the hosts config file successful

<output removed to aid clarity>

Clock time offset check from NTP Time Server started...
Clock time offset check passed

Clock synchronization check using Network Time Protocol(NTP) passed

Pre-check for cluster services setup was successful. 
[oracle@orpheus grid]$

If we have followed all the steps carefully, the script should report success and we are ready to start the Grid install:
We will now launch the Grid installer as follows:
[oracle@orpheus grid]$ ./runInstaller &

This will start the graphical installer and present the following menu:

We are going to select the first option; Install and Configure Grid Infrastructure for a Cluster

On the next screen we select Advanced Installation

On the next screen we select the languages to install. I am happy with just English.

On the next screen we unselect Configure GNS and then define our cluster name and SCAN port number. I am going to call my cluster underworld with a SCAN name of underworld-scan. This matches the SCAN definition we added to our DNS server back in Part VII.
I am defining the port for the SCAN listener as 1561, and not the suggested 1521.

On the next screen we define our cluster nodes. Orpheus is added automatically but we need to add Eurydice manually by selecting Add and then defining the addresses eurydice and eurydice-vip. Again these should match the addresses we added to the DNS server back in Part VII.

On the next screen we define the ethernet networks to use for our cluster traffic. Remember eth0 is the public port we use to access the outside world, and since this is a laptop that address changes. We set eth0 to Do Not Use
The eth1 network is the public network we set up on VMnet2 so we set that to Public.
The eth2 network is the private network we set up on VMnet3 so we set that to Private.

On the next screen we choose Automatic Storage Management (ASM)

On the next screen we should see the DATA ASM diskgroup listed. Set redundancy to External and check the ORCL:DATA option for the DATA disk group. Since this is a demonstration only we are going to place all of our files, including cluster and voting files, into a single disk group.

On the next screen check Use same passwords for these accounts. Since this is a demo I usually set these to something very simple like oracle. But make a note of this password as you will need it in Part X.

The installer warns us that our password choice is not very secure. That’s okay, I don’t forsee anyone really trying to hack into this RAC cluster.

On the next screen select Do not use Intelligent Platform Management Interface (IPMI).

On the next screen we should see OS groups for ASM management listed. These should be set as follows:
ASM Database Administrator (OSDBA) Group asmdba
ASM Database Administrator Operator (OSOPER) Group oinstall
ASM Instance Administrator (OSASM) Group asmadmin

On the next screen we choose where to install the Oracle Base and the Grid software. Note that the Grid software cannot be installed as a sub-directory of the Oracle Base.

On the next screen we select a location for the Oracle Inventory.

On the next screen we can verify that we have defined everything correctly. If everything looks good then press Finish

The install process can take a while to complete. On my VM RAC it will take at least ten minutes to complete. Don’t be alarmed if things hang at 65% for a while. This is normal. However you can check the second node to ensure that disk free space is gradually decreasing. If the 65% progress remains static for over 30 minutes you might have forgotten to disable the firewall.

Once the software install finishes we are presented with a dialog to run some scripts as the root user.
STOP! This is the part of the process where most people make mistakes!
It is extremely important that we run the scripts listed in the order listed, and that we wait for scripts to complete on Orpheus before we run them on Eurydice.
First we will run the orainstRoot.sh script on Orpheus:
[root@orpheus grid]# ./orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.

Next we can run the same script on Eurydice.
Now we run the root.sh script on Orpheus. This will take a while to complete and MUST be allowed to run to completion before we start the execution on Eurydice.
Given the critical nature of this step, I have elected to show you the full output of the script on both my VM nodes. First Orpheus:
[root@orpheus grid]# ./root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/11.2.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
2012-10-29 20:50:56: Parsing the host name
2012-10-29 20:50:56: Checking for super user privileges
2012-10-29 20:50:56: User has super user privileges
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
LOCAL ADD MODE 
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
  root wallet
  root wallet cert
  root cert export
  peer wallet
  profile reader wallet
  pa wallet
  peer wallet keys
  pa wallet keys
  peer cert request
  pa cert request
  peer cert
  pa cert
  peer root cert TP
  profile reader root cert TP
  pa root cert TP
  peer pa cert TP
  pa peer cert TP
  profile reader pa cert TP
  profile reader peer cert TP
  peer user cert
  pa user cert
Adding daemon to inittab
CRS-4123: Oracle High Availability Services has been started.
ohasd is starting
CRS-2672: Attempting to start 'ora.gipcd' on 'orpheus'
CRS-2672: Attempting to start 'ora.mdnsd' on 'orpheus'
CRS-2676: Start of 'ora.mdnsd' on 'orpheus' succeeded
CRS-2676: Start of 'ora.gipcd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'orpheus'
CRS-2676: Start of 'ora.gpnpd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'orpheus'
CRS-2676: Start of 'ora.cssdmonitor' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'orpheus'
CRS-2672: Attempting to start 'ora.diskmon' on 'orpheus'
CRS-2676: Start of 'ora.diskmon' on 'orpheus' succeeded
CRS-2676: Start of 'ora.cssd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'orpheus'
CRS-2676: Start of 'ora.ctssd' on 'orpheus' succeeded

ASM created and started successfully.

DiskGroup DATA created successfully.

clscfg: -install mode specified
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-2672: Attempting to start 'ora.crsd' on 'orpheus'
CRS-2676: Start of 'ora.crsd' on 'orpheus' succeeded
CRS-4256: Updating the profile
Successful addition of voting disk 2e7657066f434fb3bf49ddfec8560948.
Successfully replaced voting disk group with +DATA.
CRS-4256: Updating the profile
CRS-4266: Voting file(s) successfully replaced
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   2e7657066f434fb3bf49ddfec8560948 (ORCL:DATA) [DATA]
Located 1 voting disk(s).
CRS-2673: Attempting to stop 'ora.crsd' on 'orpheus'
CRS-2677: Stop of 'ora.crsd' on 'orpheus' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'orpheus'
CRS-2677: Stop of 'ora.asm' on 'orpheus' succeeded
CRS-2673: Attempting to stop 'ora.ctssd' on 'orpheus'
CRS-2677: Stop of 'ora.ctssd' on 'orpheus' succeeded
CRS-2673: Attempting to stop 'ora.cssdmonitor' on 'orpheus'
CRS-2677: Stop of 'ora.cssdmonitor' on 'orpheus' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'orpheus'
CRS-2677: Stop of 'ora.cssd' on 'orpheus' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'orpheus'
CRS-2677: Stop of 'ora.gpnpd' on 'orpheus' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'orpheus'
CRS-2677: Stop of 'ora.gipcd' on 'orpheus' succeeded
CRS-2673: Attempting to stop 'ora.mdnsd' on 'orpheus'
CRS-2677: Stop of 'ora.mdnsd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.mdnsd' on 'orpheus'
CRS-2676: Start of 'ora.mdnsd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on 'orpheus'
CRS-2676: Start of 'ora.gipcd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'orpheus'
CRS-2676: Start of 'ora.gpnpd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'orpheus'
CRS-2676: Start of 'ora.cssdmonitor' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'orpheus'
CRS-2672: Attempting to start 'ora.diskmon' on 'orpheus'
CRS-2676: Start of 'ora.diskmon' on 'orpheus' succeeded
CRS-2676: Start of 'ora.cssd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'orpheus'
CRS-2676: Start of 'ora.ctssd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'orpheus'
CRS-2676: Start of 'ora.asm' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.crsd' on 'orpheus'
CRS-2676: Start of 'ora.crsd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.evmd' on 'orpheus'
CRS-2676: Start of 'ora.evmd' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'orpheus'
CRS-2676: Start of 'ora.asm' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.DATA.dg' on 'orpheus'
CRS-2676: Start of 'ora.DATA.dg' on 'orpheus' succeeded
CRS-2672: Attempting to start 'ora.registry.acfs' on 'orpheus'
CRS-2676: Start of 'ora.registry.acfs' on 'orpheus' succeeded

orpheus     2012/10/29 20:56:44     /u01/app/11.2.0/grid/cdata/orpheus/backup_20121029_205644.olr
Preparing packages for installation...
cvuqdisk-1.0.7-1
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Updating inventory properties for clusterware
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4008 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'UpdateNodeList' was successful.

Now we can execute the root.sh script on Eurydice:
[root@eurydice grid]# ./root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/11.2.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]: 
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...


Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
2012-10-29 20:57:56: Parsing the host name
2012-10-29 20:57:56: Checking for super user privileges
2012-10-29 20:57:56: User has super user privileges
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
LOCAL ADD MODE 
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Adding daemon to inittab
CRS-4123: Oracle High Availability Services has been started.
ohasd is starting
CRS-4402: The CSS daemon was started in exclusive mode but found an active CSS daemon on node orpheus, number 1, and is terminating
CRS-2673: Attempting to stop 'ora.cssdmonitor' on 'eurydice'
CRS-2677: Stop of 'ora.cssdmonitor' on 'eurydice' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'eurydice'
CRS-2677: Stop of 'ora.gpnpd' on 'eurydice' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'eurydice'
CRS-2677: Stop of 'ora.gipcd' on 'eurydice' succeeded
CRS-2673: Attempting to stop 'ora.mdnsd' on 'eurydice'
CRS-2677: Stop of 'ora.mdnsd' on 'eurydice' succeeded
An active cluster was found during exclusive startup, restarting to join the cluster
CRS-2672: Attempting to start 'ora.mdnsd' on 'eurydice'
CRS-2676: Start of 'ora.mdnsd' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on 'eurydice'
CRS-2676: Start of 'ora.gipcd' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'eurydice'
CRS-2676: Start of 'ora.gpnpd' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'eurydice'
CRS-2676: Start of 'ora.cssdmonitor' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'eurydice'
CRS-2672: Attempting to start 'ora.diskmon' on 'eurydice'
CRS-2676: Start of 'ora.diskmon' on 'eurydice' succeeded
CRS-2676: Start of 'ora.cssd' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'eurydice'
CRS-2676: Start of 'ora.ctssd' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.drivers.acfs' on 'eurydice'
CRS-2676: Start of 'ora.drivers.acfs' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'eurydice'
CRS-2676: Start of 'ora.asm' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.crsd' on 'eurydice'
CRS-2676: Start of 'ora.crsd' on 'eurydice' succeeded
CRS-2672: Attempting to start 'ora.evmd' on 'eurydice'
CRS-2676: Start of 'ora.evmd' on 'eurydice' succeeded

eurydice     2012/10/29 21:01:14     /u01/app/11.2.0/grid/cdata/eurydice/backup_20121029_210114.olr
Preparing packages for installation...
cvuqdisk-1.0.7-1
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Updating inventory properties for clusterware
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 4008 MB    Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'UpdateNodeList' was successful.

The critical part of the Eurydice install process is the line:
An active cluster was found during exclusive startup, restarting to join the cluster
If everything looks okay, click the OK button:

The Grid install is now complete.

If you want to check that both nodes are connected, launch the asmca tool and check that ASM instances are shown on both Orpheus and Eurydice.

Add some shared disk to our new freshly minted VMs

VMWare Workstation makes the allocation of shared disk to VMs very simple. Shared disk has been the biggest obstacle to create Oracle RAC clusters at home, but now VMWare gives us a reliable and portable solution that does not require fire-wire hacks, your own NFS server or a SCSI disk array.
Best of all this whole solution can exist on a single laptop, so you can take your RAC on the road.

Make sure both VMs are shut down. If you want to make a clone of your progress then now is your last chance to do so without the complication of shared external disk.
We will add a new disk to Orpheus first, and then add the same disk into Eurydice.
Using the VMWare Workstation menu, right click on Orpheus and select Settings.
Virtual Machine Settings
This will bring up the Virtual Machine Settings menu. Click on the Add button.
Add Hardwre Wizard
At the Add Hardware Wizard menu, select Hard Disk and click Next.
Select a Disk
Select Create a new virtual disk and click Next.
Select a Disk Type
When the Select a Disk Type menu appears, select SCSI (Recommended) and for mode check Indepenent and the radio button Persistent.
Specify Disk Capacity
When the Specify Disk Capacity menu appear, set the new disk size at 5GB. This should be just enough to support our demo RAC database. If you have an abundance of disk space then by all means set the disk size much larger.
Check the All all disk space now. button and Store virtual disk as a single file
NOTE: These last two options are very important for our RAC. Trying to create a shared disk with VMWare Workstation using thin-provisioning will result in disk corruption.
Next VMWare Workstation will ask where you want to store your new disk and what you want to call it. By default it will want to place the virtual disk in the same directory as the rest of the Orpheus VM. However this new disk is to be shared, so I prefer to place it in a separate directory.
VMWare Workstation stores its VMs by default in the user’s Documents directory under a sub-directory called Virtual Machines. In this directory you will find sub-directories for both our VMs Orpheus and Eurydice. I suggest creating a new sub-directory here called Shared Disk and storing our new virtual disk in the Shared Disk directory with the name asm disk 1.vmdk.
Browse for Virtual Disk File
VMWare will ask you confirm your selection. Press Finish to confirm.
Specify Disk File
Now we need to move our new disk to a different virtual SCSI device within the VM. In order to avoid all manner of cluster disk issues, we need to place the shared disks on a different SCSI controller to the local disks.
Highlight the Orpheus VM in the VMWare Workstation menu and select Settings. When the Virtual Machine Settings menu appears, highlight Hard Disk 2 and select the Advanced button on the right hand side.
Virtual Machine Settings
The Hard Disk Advanced Settings menu allows to modify the Virtual device node. By default this will be set to SCSI 0:1, but we need to change this to SCSI 1:0. This will move our new disk to SCSI controller 1, device 0.
Hard Disk Advanced Settings
Next we will have to resort to a little hacking to make our shared disk really sharable. We are now leveraging VM functionality that is not really supported in VMWare Workstation 8, but does appear to work, at least for demo purposes.
Navigate to the directory where the Orpheus VM files are stored, in most cases this will be Documents/Virtual Machines/Orpheus. In there you will find a file called Orpehus.vmx
VMWare VMX files
The VMX file contains the hardware profile of the VMs we have created. Before we do anything else, make a copy of it so we have something to go back to if we make a mess.
Open the VMX file with an ASCII editor. Make sure you have an editor able to open and save in ASCII format. Word Processors are a poor choice here as they are more likely to add symbols that will corrupt the file.
The VMX file is a unsorted mess. Why VMWare doesn’t perform a simple sort on the file before saving it to disk is a mystery. Still at least it isn’t some gigantic XML monstrosity. I recommend that if your editor allows it, you perform a sort on the entire file and save it back to disk before making any changes.
This is where the magic happens, and I have to acknowledge it was Dan Norris who figured this out, not me. In order to make our new disk fully clusterable, we are going to add the following directives to the VMX file:
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0" 
diskLib.dataCacheMinReadAheadSize = "0" 
diskLib.dataCachePageSize = "4096" 
diskLib.maxUnsyncedWrites = "0" 
scsi1.sharedBus = "virtual"

These changes force the VMs to not try to buffer reads and writes to the disk, which would result in block corruption to the shared database. The new directives can be added anywhere in the VMX file, although I tend to add them immediately above the SCSI settings.
The following is a sub-section taken from the VMX file of my Orpheus VM. I have not dumped the entire file for the sake of clarity.
replay.supported = "FALSE"
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0" 
diskLib.dataCacheMinReadAheadSize = "0" 
diskLib.dataCachePageSize = "4096" 
diskLib.maxUnsyncedWrites = "0" 
scsi1.sharedBus = "virtual"
scsi0.pciSlotNumber = "16"
scsi0.present = "TRUE"
scsi0.virtualDev = "lsilogic"
scsi0:0.fileName = "local disk 1-cl2.vmdk"
scsi0:0.present = "TRUE"
scsi0:0.redo = ""
scsi0:1.present = "FALSE"
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1:0.fileName = "C:\Users\thorng1.CORP\Documents\Virtual Machines\Shared Disk\asm disk 1.vmdk"
scsi1:0.mode = "independent-persistent"
scsi1:0.present = "TRUE"
serial0.fileType = "thinprint"
serial0.present = "TRUE"
sound.autodetect = "TRUE"

Now navigate to the VMX file for Eurydice and add the same directives for diskLib and scsi1. You do NOT need to use the VMWare interface to make these changes. Editing the VMX file directly is the better option.
The following is taken from the VMX file of my Eurydice VM. Again I have not dumped the entire file for the sake of clarity. As you can see it should match Orpheus exactly.
replay.supported = "FALSE"
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0" 
diskLib.dataCacheMinReadAheadSize = "0" 
diskLib.dataCachePageSize = "4096" 
diskLib.maxUnsyncedWrites = "0" 
scsi1.sharedBus = "virtual"
scsi0.pciSlotNumber = "16"
scsi0.present = "TRUE"
scsi0.virtualDev = "lsilogic"
scsi0:0.fileName = "local disk 1-cl2.vmdk"
scsi0:0.present = "TRUE"
scsi0:0.redo = ""
scsi1.present = "TRUE"
scsi1.virtualDev = "lsilogic"
scsi1:0.fileName = "C:\Users\thorng1.CORP\Documents\Virtual Machines\Shared Disk\asm disk 1.vmdk"
scsi1:0.mode = "independent-persistent"
scsi1:0.present = "TRUE"
serial0.fileType = "thinprint"
serial0.present = "TRUE"
sound.autodetect = "TRUE"

Now you can start up both Orpheus and Eurydice. As you do so, you might notice a small warning in the bottom right hand corner of the VMWare window that states:
Clustering is not supported for WMware Workstation – this setting will be ignored
Don’t worry about this. This is expected behavior.
When Orpheus is full booted up, we should be able to create a partition table on the new shared disk, which will be presented to Linux as /dev/sdb.
In the following example we create a partition at the 1MB offset.
[root@orpheus ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-10485759, default 63): 2048
Last sector or +size or +sizeM or +sizeK (2048-10485759, default 10485759): 
Using default value 10485759

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Okay cool. We have created a partition on the new shared disk. Now we can stamp it for use by ASM by using the ASMLib we installed back in Part V.
[root@orpheus ~]# oracleasm createdisk DATA /dev/sdb1
Writing disk header: done
Instantiating disk: done
To verify the operation worked as expected, we can list the ASM disks as follows:
[root@orpheus ~]# oracleasm listdisks
DATA

Now we need to see if the changes we just did are visible to Eurydice. Log into Eurydice as root and start the fdisk command. Now if we list the partition table we should see that one already exists, as we just created it on Orpheus.
[root@eurydice ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 1448.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes
181 heads, 40 sectors/track, 1448 cylinders
Units = cylinders of 7240 * 512 = 3706880 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1449     5241856   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Note: It is important to re-write the partition header table from fdisk so that Eurydice can see the partitioned device /dev/sdb1.
Now we can use ASMLib on Eurydice to scan the devices for any ASM stamped disks:
[root@eurydice ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
Finally if we check to see what was found, we should see that the ASM disk for DATA has been discovered!
[root@eurydice ~]# oracleasm listdisks
DATA

The shared disk is visible to both Orpheus and Eurydice. We are now ready to install our RAC database!