old-www/HOWTO/Oracle-7-HOWTO-3.html

271 lines
7.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>Oracle Database HOWTO: Creating a Database</TITLE>
<LINK HREF="Oracle-7-HOWTO-4.html" REL=next>
<LINK HREF="Oracle-7-HOWTO-2.html" REL=previous>
<LINK HREF="Oracle-7-HOWTO.html#toc3" REL=contents>
</HEAD>
<BODY>
<A HREF="Oracle-7-HOWTO-4.html">Next</A>
<A HREF="Oracle-7-HOWTO-2.html">Previous</A>
<A HREF="Oracle-7-HOWTO.html#toc3">Contents</A>
<HR>
<H2><A NAME="s3">3. Creating a Database</A></H2>
<P>Now the Oracle server is installed we need to create a database to test the installation.
<P><CODE>If you are using Oracle 7.2.x or earlier, please read the troubleshooting section below.</CODE>
<H2><A NAME="ss3.1">3.1 Create the Initialisation File</A>
</H2>
<P>Copy the <CODE>$ORACLE_HOME/dbs/init.ora</CODE> to <CODE>$ORACLE_HOME/dbs/initorcl.ora</CODE>:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
$ cd $ORACLE_HOME/dbs
$ cp init.ora initorcl.ora
</PRE>
<HR>
</CODE></BLOCKQUOTE>
Modify it by adding the following lines:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
db_name = orcl
COMPATIBLE=7.3.3.0.0
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>
<P>
<H2><A NAME="ss3.2">3.2 Creating the Database Install Script</A>
</H2>
<P>Create a script file called makedb.sql in the <CODE>$ORACLE_HOME/dbs</CODE> directory:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
connect internal
startup nomount
set echo on
spool makedb.log
create database orcl
maxinstances 1
maxlogfiles 8
datafile '$ORACLE_HOME/dbs/orcl_syst_01.dbf' size 40M reuse
logfile
'$ORACLE_HOME/dbs/orcl_redo_01.dbf' size 1M reuse,
'$ORACLE_HOME/dbs/orcl_redo_02.dbf' size 1M reuse,
'$ORACLE_HOME/dbs/orcl_redo_03.dbf' size 1M reuse;
@$ORACLE_HOME/rdbms/admin/catalog.sql
create tablespace rollback
datafile '$ORACLE_HOME/dbs/orcl_roll_01.dbf' size 8.5M reuse;
create tablespace temp
datafile '$ORACLE_HOME/dbs/orcl_temp_01.dbf' size 5M reuse
temporary;
create tablespace users
datafile '$ORACLE_HOME/dbs/orcl_user_01.dbf' size 10M reuse;
create rollback segment r1 tablespace rollback
storage ( optimal 5M );
alter rollback segment r1 online;
connect system/manager
@$ORACLE_HOME/rdbms/admin/catdbsyn.sql
connect internal
@$ORACLE_HOME/rdbms/admin/catproc.sql
connect system/manager
@$ORACLE_HOME/sqlplus/admin/pupbld.sql
spool off
exit
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="ss3.3">3.3 Running the Database Installation Script</A>
</H2>
<P>Start <CODE>svrmgrl</CODE> and run the script:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
$ cd $ORACLE_HOME/dbs
$ svrmgrl
Oracle Server Manager Release 2.3.3.0.0 - Production
Copyright (c) Oracle Corporation 1994, 1995. All rights reserved.
Oracle7 Server Release 7.3.3.0.0 - Production Release
PL/SQL Release 2.3.3.0.0 - Production
SVRMGR> connect internal
Connected.
SVRMGR> startup nomount
ORACLE instance started.
Total System Global Area 4313312 bytes
Fixed Size 41876 bytes
Variable Size 4140364 bytes
Database Buffers 122880 bytes
Redo Buffers 8192 bytes
SVRMGR> @makedb
&lt;loads of messages>
SVRMGR> exit
Server Manager complete.
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<H2><A NAME="ss3.4">3.4 Starting the Database</A>
</H2>
<P>Firstly, we need to bring up the database by hand (we will automate this later on). To startup an Oracle database we need to issue the <CODE>startup</CODE> command when connected internally:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
$ svrmgrl
Oracle Server Manager Release 2.3.3.0.0 - Production
Copyright (c) Oracle Corporation 1994, 1995. All rights reserved.
Oracle7 Server Release 7.3.3.0.0 - Production Release
PL/SQL Release 2.3.3.0.0 - Production
SVRMGR> connect internal
Connected.
SVRMGR> startup
ORACLE instance started.
Total System Global Area 4313316 bytes
Fixed Size 41876 bytes
Variable Size 4140368 bytes
Database Buffers 122880 bytes
Redo Buffers 8192 bytes
Database mounted.
Database opened.
SVRMGR> exit
Server Manager complete.
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<H2><A NAME="ss3.5">3.5 Stopping the Database</A>
</H2>
<P>It is worth mentioning here that restarting a Linux server without shutting down the Oracle database first there is a high risk of corrupting the database.
<P>So, before we issue the Linux <CODE>shutdown</CODE> command it is wise to bring down the database:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
$ svrmgrl
Oracle Server Manager Release 2.3.3.0.0 - Production
Copyright (c) Oracle Corporation 1994, 1995. All rights reserved.
Oracle7 Server Release 7.3.3.0.0 - Production Release
PL/SQL Release 2.3.3.0.0 - Production
SVRMGR> connect internal
Connected.
SVRMGR> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SVRMGR> exit
Server Manager complete.
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<H2><A NAME="ss3.6">3.6 Create a Default User</A>
</H2>
<P>The database, as created, has a two special users which are automatically created. These are:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
Username Password
SYSTEM MANAGER
SYS change_on_install
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>
<P>These users are typically used to hold the standard data dictionary information for the database. It is a good idea to change the passwords from the defaults as soon as possible.
<P>This can be achieved by:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
sqlplus system/manager
SQL*Plus: Release 3.3.3.0.0 - Production on Sat Feb 21 12:43:33 1998
Copyright (c) Oracle Corporation 1979, 1996. All rights reserved.
Connected to:
Oracle7 Server Release 7.3.3.0.0 - Production Release
SQL> alter user system identified by &lt;newpassword>;
User altered.
SQL> alter user sys identified by &lt;newpassword>;
User altered.
SQL> exit;
Disconnected from Oracle7 Server Release 7.3.3.0.0 - Production Release
PL/SQL Release 2.3.3.0.0 - Production
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>
<P>Since the user <CODE>system/manager</CODE> is similar to using <CODE>root</CODE> on a UNIX machine, we need to create a user with less ability to cause damage. (remember to bring up the database before attempting to create a user)
<P>Connect to SQL*Plus and create a user:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
$ sqlplus system/manager
SQL*Plus: Release 3.3.3.0.0 - Production on Sat Feb 21 12:43:33 1998
Copyright (c) Oracle Corporation 1979, 1996. All rights reserved.
Connected to:
Oracle7 Server Release 7.3.3.0.0 - Production Release
PL/SQL Release 2.3.3.0.0 - Production
SQL> create user &lt;user> identified by &lt;psw>
2 default tablespace users
3 temporary tablespace temp;
User created.
SQL> grant connect, resource to &lt;user>
Grant succeeded.
SQL> exit
Disconnected from Oracle7 Server Release 7.3.3.0.0 - Production Release
PL/SQL Release 2.3.3.0.0 - Production
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>Now that you have a new user on the system you can play with the new system. To login to the Oracle database:
<BLOCKQUOTE><CODE>
<HR>
<PRE>
$ sqlplus &lt;user>/&lt;password>
</PRE>
<HR>
</CODE></BLOCKQUOTE>
<P>If this completes with no error messages then you have a working Oracle database. If you never want to connect to this database from anywhere but this server then the job is complete, enjoy!
<P>If, however, like most people you want to configure the networking software so that you can connect from other machines, keep on reading.
<HR>
<A HREF="Oracle-7-HOWTO-4.html">Next</A>
<A HREF="Oracle-7-HOWTO-2.html">Previous</A>
<A HREF="Oracle-7-HOWTO.html#toc3">Contents</A>
</BODY>
</HTML>