How to install and run Oracle on your Linux machine

Source: Internet
Author: User
Tags manual documentation port number oracle database sqlplus in python

Summary: Oracle announced the porting of Oracle 8 and Oracle Application Server at the end of last year
To Linux. This is a clear and unmistakable sign: the whole world should realize that Linux has
is a serious operating system, enough to take on enterprise-class applications. Uche Ogbuji is solved in the following
How to install, configure, and initially use Oracle 8 for Linux.


How to install and run Oracle on your Linux machine
A Practical Guide

After a lot of rumors and hints, Oracle released the Linux on October 7, 1998
Oracle 8 Database and Oracle Application Server. This is the most recent Linux history
A dazzling scene.

Whatever your personal opinion of Oracle, the company's massive data-application field
Reputation makes this product a clear and unmistakable sign: the world should realize that
Linux is already a serious operating system, enough to take on enterprise-class applications.

But for anyone who really cares about Linux, all kinds of publicity campaigns are just ephemeral, only code
is the key. (Only code matters.) In fact, Oracle 8i, or 8.1.5
For Linux has been developed, but there is a problem with the Jserver module,
So Oracle hasn't been released yet. )

Start the action.

It can be pretty easy to install Oracle on Redhat, but if you follow Oracle company completely
Documentation is not always easy to walk through. The quickest shortcut is Tom Bisset's homepage:
Http://jordan.fortwayne.com/oracle.

If you read Tom's homepage, you will notice that he missed the JDBC installation. If you are ready to use
JDBC (Convenient for cross-platform Oracle applications) requires you to select a group on the installation screen
Item (components), you can add this option. Of course, you should install the JDK first. I personally make
Use the Blackdown JDK 1.1.7. (Redhat includes JDK) and then needs to set Oracle
The best way for users to CLASSPATH environment variables is in the Oracle User directory. Bash_profile
Or. Profile, add a sentence:
Classpath=/usr/lib/jdk/lib/classes.zip; Export CLASSPATH
Then, if you only need to do web applets, in the installer "Choose JDBC components"
, select "JDK 1.1 JDBC Thin Driver" If you need to do a full Java application,
Select JDK 1.1 JDBC OCI Driver.


Also note that the installer allows you to enter each password and does not warn you if the password does not conform to the specification.
The first time I installed, the password added ".", which is allowed in Unix, Oracle is another code
Thing. It was not until the installation was over that the program told me there was a problem with the password. At that time for the sake of insurance, I
The installation was done from scratch.

Another problem with Setup is trying to dealings files in a directory that is not established. It is necessary to install
Ago
Mkdir-p/u01/app/oracle/product/8.0.5/doc/server.805/install. This one
All is fine after closing.

After the installation is successful, you must log in as root and run root.sh. I made the following changes to root.sh:
· The LBIN environment variable changed from/usr/lbin to/usr/local/bin.
· Increase the environment variable log=/tmp/oracle-root.sh.log so that the script's run results will record
Get down

Root.sh said, to the database as a server to run, must first set the Two_task variable;
But, in fact, if you run root.sh from a machine that installs Oracle, it's not necessary to set this variable.


Python and Oracle

I have configured Python (a powerful, fast object-oriented scripting language) to measure
Try Oracle's programming interface and network interface. To Oracle in Python, you need
The Dcoracle module of the Digital creation (author of the Zope Application server).
All you need to do is download the software and follow the instructions. If it is dcoracle 1.1.0, use
Setup-8.0.4 configuration, remove from Oracle_libs variable-lsocket,-LNSL,-lgen,
-lelf,-laio, and-lposix4, those are all Solaris-specific. Note Redhat 5.2 and
The Python setup in 6.0 is not complete, and the Config directory and include directory are omitted and cannot be compiled
Install a third party module. You must compile Python yourself or download a suitable rpm. Find
Python's rpm, the best place to be is Oliver Andrich's Python & Linux home page.
Just rpm-e--nodeps python, then rpm-i Python,python-dev and other rpm
Can.
After I loaded Python, I ran the following basic query to access Oracle.

[Uche@malatesta uche]$ python
Python 1.5.1 (#1, Sep 3 1998, 22:51:17) [GCC 2.7.2.3] on linux-i386
Copyright 1991-1995 stichting Mathematisch Centrum, Amsterdam
>>> Import Dcoracle
>>> #connect to DB. Scott/tiger are the test database Username/password
>>> dbc=dcoracle.connect ("Scott/tiger@sforza") #sforza is the local Oracle
Server
>>> C = dbc.cursor ()
>>> C.execute ("SELECT * from emp WHERE Emp.deptno = 10")
>>> rows = C.fetchall ()
>>> Print Rows
[7782, ' CLARK ', ' MANAGER ', 7839, Dbidate (' 1981-06-09 00:00:00 '), 2450.0,
None, 10),
(7839, ' KING ', ' PRESIDENT ', None, Dbidate (' 1981-11-17 00:00:00 '), 5000.0,
None, 10),
(7934, ' MILLER ', ' clerk ', 7782, Dbidate (' 1982-01-23 00:00:00 '), 1300.0,
None, 10)]


Development workstation Configuration

I compiled Python and other programming interfaces on a single machine outside the database server. First
It seems that I have to install all Oracle pro*c/c++ packages. But to install the Oracle
It was troublesome enough to get to that step, so I didn't want to do that. So I figured out what I needed to write the program.
Minimum limited header files (include), object files (objects), and library files (libraries) you want:
$ORACLE _home/lib/*
$ORACLE _home/rdbms/demo/*
$ORACLE _home/rdbms/lib/*
I set oracle_home on my machine for/usr/local/oracle.
Note that these files also do not allow you to embed SQL statements directly in the C program, only the full installation
Pro*c/c++ after the trip. If you want to use Java, you have to increase $oracle_home/jdbc/lib/*;
Note that this directory is added to the CLASSPATH variable.

JDBC Connection


To test the JDBC connection, I made a small program to display the inside of the test library in a ListBox
has an employee name. The following program 1 is called JDBC
Java applet, program 2 is the HTML hypertext that invokes the Java program. If your JDBC has been Ann
Loaded successfully, the program 1 copy as Jdbctest.java, the program 2 copy as Jdbctest.html,
And then:

Javac Jdbctest.java
Appletviewer jdbctest.html

You can see for yourself how the result is:

Program 1:

/*
Applet that reads in several rows from a remote Oracle database
and presents them in a listbox.
*/
Import java.sql.*;
Import java.awt.*;
Import java.applet.*;
Import java.lang.*;
public class Jdbctest extends Applet
{
File://Single-select ListBox
Private list employee_list = new List (5, false)
public void Init ()
{
SetLayout (New BorderLayout ());
try {
File://Set up the Oracle JDBC driver
Drivermanager.registerdriver (New Oracle.jdbc.driver.OracleDriver ());
File://Connect to a Oracle database on machine Sforza, using username
file://"Scott" and password "Tiger"
Connection Db_conn = drivermanager.getconnection
("Jdbc:oracle:thin: @sforza: 1521:orcl", "Scott", "Tiger");
File://Connection Db_conn = drivermanager.getconnection
("JDBC:ORACLE:THIN:SCOTT/TIGER@SFORZA:1521:ORCL");
File://Create a JDBC Statement object
Statement statement_obj = Db_conn.createstatement ();
File://Execute a query to get the employee names from the test DB
ResultSet results = statement_obj.executequery ("Select ename from
EMP ");
File://Populate the "list box with" All the employee names
while (Results.next ()) {
Employee_list.add (results.getstring (1));
}
catch (SQLException e) {
throw new RuntimeException ("SQL Exception" + e.getmessage ());
}
Add (employee_list);
}
}


Program 2:




Oracle JDBC Driver Test


Your
Browser doesn ' t support Java.

-->

-->


Last Modified:sat Mar 6 22:19:26 MST 1999

-->





Most of the program 1 is a specific database-independent JDBC call, dots you can also
Access to PostgreSQL, primarily and Oracle phase
The closing part is:

Connection Db_conn = drivermanager.getconnection
("Jdbc:oracle:thin: @sforza: 1521:orcl", "Scott", "Tiger");


Note The format of the URI in Oracle thin JDBC driver:
jdbc:oracle:thin:@ : :
If you want to include the username and password in the URI:
jdbc:oracle:thin:username/password@ : :

The same URI also has a longer format:
"Jdbc:oracle:thin:@ (description= (address=) (host= _ip>) (protocol
=TCP) (port= ) (Connect_data= (sid= )))"
Note that the ORCL is the default SID (System Identifier, systems Identifier) for system installation.
If you use a different SID when you install it,
The SID is also used in the URI. $ORACLE _home/network/admin/tnsnames.ora Bag
Encloses the port and SID settings for the Oracle server.
This is the configuration file for the TNS Listener,oracle Network connection process. If you cannot pass
Network connection database, you should first check
Port number and SID are correct, TNS Listner is normal (Lsnrctl status,
or tnsping). JDBC is not a development
The only means of SQL database application, ANSI standard SQLJ allows direct embedding in Java programs
SQL statement. Oracle for Linux 8.0.5
There is no bundled SQLJ, but can be obtained as another standalone product. SQLJ is 100%.
JAVA, should run on Linux no problem,
In fact, SQLJ is using JDBC at the bottom, so it can be interconnected with any SQL database,
is not limited to Oracle.

Hopefully, these examples will help you with your programming. Unfortunately Oracle for Linux
The programming documentation is fairly small, or it's hidden
Very deep:) Maybe you'll have to chew one or two books before you can get your database programming in handy.

Pl/sql

The procedural language extension (pl/sql) of SQL is probably the most famous feature of Oracle. This
A powerful professional database management language allows you to
Declarative SQL plus logic control. In general, Pl/sql stored procedures (stored procedure)
Sqlplus with the command line, graphical
developer/2000 (not currently available on Linux) or other tool development allows you to
Oracle's numerous query interfaces (Oracle Application Server, Python, Perl,
JDBC or C) access.

Program 3:

Create or replace package stored_sample as
function Get_annual_salary (emp_number in number) return number;
End Stored_sample;
/
Create or replace package body stored_sample as
function Get_annual_salary (emp_number in number) return number
Is
Annual_salary number;
Monthly_salary number;
Begin
Select Sal into Monthly_salary from emp where empno = Emp_number;
Annual_salary: = monthly_salary * 24;
return (annual_salary);
End Get_annual_salary;
End Stored_sample;
/


The above program 3 is a small demonstration of the storage process, which accepts an employee number and returns the member
The annual salary of the workers. Related functions
The get_annual_salary is encapsulated in the Pl/sql package sample_package.

If you copy the program 3 to the file Sample.sql, you can run it through Sqlplus, as follows
As shown:

[Oracle@sforza demo]$ Sqlplus

Sql*plus:release 8.0.5.0.0-production on Sun Mar 7 13:36:32
1999

(c) Copyright 1998 Oracle Corporation. All rights reserved.

Enter User-name:scott
Enter Password:

Connected to:
Oracle8 Release 8.0.5.0.0-production
Pl/sql Release 8.0.5.0.0-production

Sql> @sample
Package created.

Package body created.

Sql> set Serveroutput on
Sql> exec
Dbms_output.put_line (Stored_sample.get_annual_salary (7782))
58800

Pl/sql procedure successfully completed.

Sql>

This Pl/sql package can also be used with other programming interfaces. In Python/dcoracle,
See procedures member of Connection object
In JDBC, see java.sql.CallableStatement.

Oracle has a number of built-in functions. In fact, most of what you've previously done with external code
Functions can be done efficiently through pl/sql. If you need anything more than the usual features,
Refer to the Pl/sql manual to see if the function you need has been implemented. If you are ready to do
A large number of Oracle programming, often read the Pl/sql manual to familiarize yourself with the various functions are
Benefits.

Managing Oracle for Linux

If you are accustomed to running a database that is relatively less complex, then complete it in Oracle
Some day-to-day operations, such as creating a new database or tuning the performance, can be quite complex. Yes
Some key configuration files need to be maintained, such as Init.ora, Config.ora, and
Tnsnames.ora.
There are generally several ways to specify key parameters, such as the current SID. Can be in the above
file, or it can be declared in an environment variable, or through the Oracle tool
Row arguments. This flexibility is commendable, but sometimes it is clear that a setting takes precedence over
Very nerve-racking.

Like Linux, Oracle provides security mechanisms that, if not properly managed, are not in the same box.
Take the time to familiarize yourself with the various access rules and settings, and the corners of various special Oracle user accounts
Color, it's still worth it.

Oracle's performance tuning is a very large and very specialized topic. Tuned properly, can
Improve performance to a large extent. The relationship between Oracle running and CPU, memory, and external storage is quite
Complex, these factors must be considered. In addition, pl/sql packages, stored procedures, temporary table empty
, the table structure itself, all of these will become increasingly complex as they are used to ensure that the database
Structural optimization, no garbage, is definitely more complicated than regular vacuum running from cron.

Oracle DBA (DB adminstrator, database administrator) is a computer professional.
Member of a famous subculture. That's not surprising. Oracle's powerful capabilities and flexibility,
It also means a lot of crazy little secrets, little tricks, little traps,
The characteristics of it is no less than anyone-including Linux. You might be able to conquer Linux
It has been found that O ' Reilly's Zoo (All O ' Reilly and associate
Books published are made of animal cover) is a good place to be. If you need to be in Oracle
Finish a lot of work, looking for the yellow cover of the O ' Reilly Oracle album. There, you will
Find a much better source of information than Oracle Byzantine maze documents.

Oracle for Linux vs. Oracle for NT

Oracle on NT is selling more than SQL SERVER on NT, NT
The first large database provides a graphical interface for many management functions, similar to the functionality in Unix
The/linux can only be accessed through Sqlplus. Such a graphical interface, designed with NT control
The other parts of the panel are quite similar. Linux DBAs must be familiar with Sqlplus. The problem with NT is that
Many administrative tasks require the user to complete the console (before the machine screen), and if you want to remotely manage
It requires expensive Third-party software (or Oracle Enterprise Manager?).
Oracle Management on UNIX can be done from any authorized distance, with the same effect on the machine
Main console.

Oracle on NT uses multiple processes within a process, while Oracle on Unix/linux
Using multiple independent, separate memory spaces (multi-wire on Unix)
Part of the process: multithreaded Server,mts, equivalent to the listener mentioned above
Multi-threaded version of. The implementation on NT avoids interprocess communication and has a small performance
Advantage, but the implementation on UNIX provides much higher reliability and data integrity because
It is not possible for an Oracle process to contaminate the address space of another Oracle process. Nasa
On NT and VMS, creating a new process is much more expensive than creating a new thread, and
NT is slow to switch between processes, so Microsoft advises programmers to use multithreading whenever possible.
On UNIX, it is more efficient to build new processes. And on Linux, new processes and new
Kernel thread, kernel thread uses the same basic system call, which is very efficient. )

On a 32-bit hardware system, the Linux ext2 file system is limited to a maximum file of 2G,
NT is 4G. This does not affect Oracle users very much, because tablespace tablespace can extend
To a number of documents, but there is still a small efficiency problem. Of course, the 64-bit Linux
(Alpha,ultra-sparc, Pa-risc) eliminates these limitations, with 64-bit Solaris
(Solaris 7) is the same. There are actually some problems here, until I find out again
You reader explain).


Some good tools/concluding remarks

Oracle also publishes the Linux version of Oracle Application Server (OAS).
An in-depth discussion of OAS is outside the scope of this article, but it does connect back-end Oracle data
Library, a powerful tool for building an Internet or intranet application. OAS offers
Java development capabilities that enable HTTP and iiop to be strung together with OCI network interfaces, with
Friendly interface to design Web Forms and reports, as well as other handy tools.

Oracle is so popular, there is a corresponding batch of open source software (open source)
Tools. One of the oWS killer is a javaservlet based alternative to OAS
Web interface tools, with Apache Web server, Apache Jserv JAVA Servelet
module integration, providing access to Oracle databases. (OWS, Oracle Web
Server is the name of an earlier version of Oracle Application server.
You can find more tools at Matt's house to manage Oracle's stored procedures,
Provides quick report functionality.

Mastering Oracle is not a matter of little effort, but there is no need to be deterred. Do
There are many more manageable databases in the world, but if you need advanced SQL, or
Pl/sql functions, or trigger, or various extensions, or advanced trading tubes
, or you have to coexist with the Oracle system, you will find that Linux is an excellent
Oracle platform. You have explored this far in the Linux world and must also
To pay Oracle's challenge.


Resource Links:

Official release of Oracle for Linux:
Http://www.oracle.com/cgi-bin/press/printpr.cgi?
file=199810090500.17129.html&mode=corp&td=01&product=00&
tm=10&fd=01&fm=08&status=search&ty=1998&limit=100&fy=1998

Detailed instructions for installing Oracle 8.0.5 and OAS 3 on Redhat:
(Step-by-Step install notes for Oracle 8.0.5 and application
Server on Red Hat):
Http://jordan.fortwayne.com/oracle

Download Oracle 8 and Oracle Application Server:
Http://technet.oracle.com/tech/linux/section.htm

Oliver Andrich ' s Python & Linux Page:
Http://andrich.net/python

Oracle on Linux-Forum on Oracle TechNet
Http://f2.dejanews.com/oracletechnet/nonmembers/index.cgi?
Do=listmsgs&conf=early.linux

blackdown.org--Linux JDK:
http://www.blackdown.org/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.