The third little pig met a man with a load of bricks, and said, “Please, man, give me those bricks to build a house with;” so the man gave him the bricks, and he built his house with them. So the wolf came, as he did to the other little pigs, and said,—
“Little pig, little pig, let me come in.”
“No, no, by the hair of my chiny chin chin.”
“Then I’ll huff, and I’ll puff, and I’ll blow your house in.”
Well, he huffed, and he puffed, and he huffed, and he puffed, and he puffed, and he huffed; but he could not get the house down.
—The Nursery Rhymes of England by James Orchard Halliwell (1886)
You’re almost ready to create a database. Chapter 4 covered the planning process. This chapter first goes over a few prerequisites such as obtaining the software, installation guides, and reference manuals. I also discuss the installation of software that precedes the creation of a database. I then demonstrate the process of installing the Oracle software in your VM. I hope you take the opportunity to perform the software installation exercise yourself—the best way to learn is by doing. Besides, software installation is one of the most common tasks of a database administrator.
Once you’ve learned how to install the Oracle software, you’ll be ready to create a database. You create your first database in Chapter 6. To get maximum value out of this book, please repeat all the demonstrations yourself in your VM.
Note To make it possible to repeat the software installation procedure multiple times, make sure you have taken a snapshot of the VM before installing the Oracle software into it. You can then restore the snapshot at will to repeat the procedure if you desire.
One of the reasons Oracle dominates the database market is that it makes its software and its software manuals available for download without any artificial restrictions such as license keys and limited trials. Oracle’s motto is, “free to download, free to learn, unlimited evaluation.” All you need is an Oracle Technology Network (OTN) account, available free of charge.
In addition to software and software manuals, OTN offers forums, articles, sample code, and tutorials. Go to www.oracle.com/technology/index.html and create an account for yourself; there’s no reason not to do so.
Beginning with Oracle Database 8, Oracle discontinued the practice of providing free printed copies of reference manuals to customers who purchased database licenses. In the early days of the Internet, when broadband access was not common, Oracle put the manuals on a CD. Today, you can search and read the manuals online; they are available in both HTML and PDF formats. For convenience, you can also download selected manuals—or the entire set of manuals—to your laptop computer for offline reading. You can purchase printed copies of the manuals at http://store.oracle.com, but they are huge. Oracle Database 12c SQL Language Reference alone is almost 1,500 pages, twice the size of the Oracle Database 7 version.
The manuals for Oracle Database 12c are available at docs.oracle.com; the manuals for older database versions are also available, all the way back to Oracle Database 7. For this chapter, you need the installation guides for the Linux operating system—separate guides are available for client installations and server installations.
Note A very short version of the server installation guide, called a Quick Installation Guide, is also available in each case; it covers the most common scenarios.
You need to pay attention to the sections of the installation guides that discuss prerequisites and preinstallation requirements. If you have chosen a complex architecture such as Real Application Clusters (RAC) , these prerequisites are themselves fairly complex, but RAC is outside the scope of this book.
Of course, a common prerequisite for all operating systems is adequate space for database files, archived redo logs, and backups. In a Linux environment, you need to install and run Oracle using a dedicated account, and there are also numerous other prerequisites. There was a time when you had to perform all the prerequisites manually; but when using Oracle Enterprise Linux (OEL) , as is the case for your VM, they are bundled into an RPM package that is installed from the root account by the yum installer as follows:
yum install oracle-rdbms-server-12cR1-preinstall –y
Of course, you don’t need to perform the prerequisites on the VM, because it already contains a full Oracle installation and therefore all the necessary prerequisites have been completed.
A client installation refers to the software that needs to be installed on every machine from which a connection to the database is initiated. This could be a user’s laptop or an application server. This section shows you two types of client installations—Instant Client and SQL Developer—and demonstrates how to install them on a Windows desktop or laptop and connect to a database in your VM.
Prior to Oracle 10g, a typical client installation was a large collection of software including dozens of components. Installation was a time-consuming process that required the use of Oracle Universal Installer (OUI) .
Beginning with Oracle Database 10g, Oracle provides the most essential software in a bundle called Instant Client. OUI is not needed for installation; you can simply copy a few files to a directory of your choice. The entire process takes only a few minutes:
$ dir
Volume in drive C is System
Volume Serial Number is 1C02-18A4
Directory of C:UsersiggyDesktopIggyDownloadsinstantclient_12_1
08/03/2014 07:15 PM <DIR> .
08/03/2014 07:15 PM <DIR> ..
06/28/2013 04:04 AM 40,448 adrci.exe
06/28/2013 04:04 AM 19,672 adrci.sym
06/28/2013 04:04 AM 567 BASIC_README
06/28/2013 04:04 AM 84,992 genezi.exe
06/28/2013 04:04 AM 52,656 genezi.sym
01/13/2006 12:36 AM 342 glogin.sql
06/28/2013 04:02 AM 641,024 oci.dll
06/28/2013 04:02 AM 472,392 oci.sym
06/26/2013 04:38 AM 150,016 ocijdbc12.dll
06/26/2013 04:38 AM 29,912 ocijdbc12.sym
06/28/2013 03:39 AM 505,856 ociw32.dll
06/28/2013 03:39 AM 79,840 ociw32.sym
06/26/2013 04:38 AM 3,389,454 ojdbc6.jar
06/28/2013 03:33 AM 67,072 oramysql12.dll
06/28/2013 03:33 AM 32,472 oramysql12.sym
06/25/2013 12:30 PM 4,736,000 orannzsbb12.dll
06/25/2013 12:30 PM 859,960 orannzsbb12.sym
06/28/2013 03:13 AM 1,095,680 oraocci12.dll
06/28/2013 04:04 AM 842,704 oraocci12.sym
06/28/2013 03:26 AM 1,121,792 oraocci12d.dll
06/28/2013 04:04 AM 944,272 oraocci12d.sym
06/28/2013 04:03 AM 161,174,528 oraociei12.dll
06/28/2013 04:04 AM 10,604,136 oraociei12.sym
06/25/2013 08:25 AM 207,872 oraons.dll
06/28/2013 04:00 AM 310,272 orasql12.dll
06/28/2013 04:00 AM 53,712 orasql12.sym
06/25/2013 04:36 AM 1,559,040 Orasqlplusic12.dll
06/25/2013 04:36 AM 946,176 sqlplus.exe
06/28/2013 04:05 AM 150,856 sqlplus.sym
06/28/2013 04:05 AM 571 SQLPLUS_README
08/03/2014 07:32 PM 187 tnsnames.ora
06/28/2013 04:04 AM 40,448 uidrvci.exe
06/28/2013 04:04 AM 19,672 uidrvci.sym
08/03/2014 07:08 PM <DIR> vc10
08/03/2014 07:08 PM <DIR> vc11
06/28/2013 03:47 AM 71,231 xstreams.jar
34 File(s) 190,305,824 bytes
4 Dir(s) 28,239,732,736 bytes free
$ type tnsnames.ora
orcl12c =
(description =
(address = (protocol = tcp)(host = 192.168.56.101)(PORT = 1521))
(connect_data =
(server = dedicated)
(service:name = orcl)
)
)
[oracle@localhost ~]$ su -
Password:
[root@localhost ~]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Sun Aug 3 22:31:09 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Sun Aug 3 22:31:09 2014
[root@localhost ~]# sed -i ’/dport 22/a-A INPUT -p tcp -m state --state
NEW -m tcp --dport 1521 -j ACCEPT’ /etc/sysconfig/iptables
[root@localhost ~]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Sun Aug 3 22:31:09 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 1521 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Sun Aug 3 22:31:09 2014
[root@localhost ~]# /etc/init.d/iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
$ cd "C:UsersiggyDesktopIggyDownloadsinstantclient_12_1"
$ set TNS_ADMIN="C:UsersiggyDesktopIggyDownloadsinstantclient_12_1"
$ type tnsnames.ora
orcl12c =
(description =
(address = (protocol = tcp)(host = 192.168.56.101)(PORT = 1521))
(connect_data =
(server = dedicated)
(service:name = pdb1)
)
)
$ sqlplus hr/oracle@orcl12c
SQL*Plus: Release 12.1.0.1.0 Production on Sun Aug 3 21:44:34 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-28002: the password will expire within 7 days
Last Successful login time: Sun Aug 03 2014 21:16:51 -07:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select count(*) from employees;
COUNT(*)
----------
107
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Another form of client installation that you have already seen is SQL Developer—a Java-based GUI tool that is useful to application developers as well as database administrators. It is a client installation in its own right and does not depend on other client software such as Instant Client.
Installing SQL Developer is painless:
A GUI tool such as SQL Developer is much easier to use than a command-line tool such as SQL*Plus, but it cannot be used in conjunction with batch programs.
A server installation refers to the software that needs to be installed on the host computer of a database. If you’re not using an advanced Oracle architecture such as RAC or Automatic Storage Management (ASM), creating a server installation is a fairly simple task. Let’s demonstrate using your VM.
First you have to download the zip file containing the software from OTN and unzip it into a staging directory. You’ll use the Firefox browser because it is already installed in the VM. However, you get “Server not found” errors because the network interface has not been started on the VM; you have to fix this first. Switch to the root account using the su - command; the password is oracle. Start the network interface using the ifconfig eth0 up command followed by dhclient eth0. Confirm that interface has been started using the command ping -c 1 www.oracle.com:
[oracle@localhost ~]$ su -
Password:
[root@localhost ~]# ifconfig eth0 up
[root@localhost ~]# dhclient eth0
[root@localhost ~]# ping -c 1 www.oracle.com
PING e7075.x.akamaiedge.net (23.7.198.140) 56(84) bytes of data.
64 bytes from a23-7-198-140.deploy.static.akamaitechnologies.com
(23.7.198.140): icmp_seq=1 ttl=57 time=30.0 ms
--- e7075.x.akamaiedge.net ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 104ms
rtt min/avg/max/mdev = 30.093/30.093/30.093/0.000 ms
If you want the network interface to be started automatically when the VM is powered on, you have to change the value of ONBOOT from no to yes in the file /etc/sysconfig/network-scripts/ifcfg-eth0.
You’re now ready to download and install the Oracle software from the Oracle web site:
unzip linuxamd64_12c_database_1of2.zip
unzip linuxamd64_12c_database_2of2.zip
[oracle@localhost ~]$ su -
Password:
[root@localhost ~]# /u01/app/oracle/product/12.1.0/dbhome_2/root.sh
Performing root user operation for Oracle 12c
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/12.1.0/dbhome_2
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.
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 script.
Now product-specific root actions will be performed.
[root@localhost ~]# exit
logout
[oracle@localhost ~]$
Oracle provides examples and demos that you can install for learning purposes. The steps are as follows:
Here are some of the key points touched on in this chapter:
18.119.111.179