Create and start an Oracle database

Source: Internet
Author: User
  1. Start Database
    In.
    Use Oracle to install the user to log on to the host and start database and service listening. The operations are as follows:
    [Ora @ localhost ora] $ sqlplus "/As sysdba" </P> <p> SQL * Plus: release 9.2.0.4.0-production on Sun Mar 22 23:55:56 2009 </P> <p> copyright (c) 1982,200 2, Oracle Corporation. all rights reserved. </P> <p> connected to an idle instance. </P> <p> SQL> startup <br/> Oracle instance started. </P> <p> total system global area 236000356 bytes <br/> fixed size 451684 bytes <br/> variable size 201326592 bytes <br/> database buffers 33554432 bytes <br/> redo buffers 667648 bytes <br/> database mounted. <br/> database opened. <br/> SQL> quit <br/> disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0-production <br/> with the partitioning, OLAP and Oracle Data Mining options <br/> jserver release 9.2.0.4.0-production <br/> [ora @ localhost ora] $ LSNRCTL start </P> <p> LSNRCTL for Linux: version 9.2.0.4.0-production on 22-Mar-2009 23:57:21 </P> <p> copyright (c) 1991,200 2, Oracle Corporation. all rights reserved. </P> <p> starting/home/ora/ora9/Oracle/bin/tnslsnr: Please wait... </P> <p> tnslsnr for Linux: Version 9.2.0.4.0-production <br/> system parameter file is/home/ora/ora9/Oracle/Network/admin/listener. ora <br/> log messages written to/home/ora/ora9/Oracle/Network/log/listener. log <br/> listening on: (description = (address = (Protocol = IPC) (Key = EXTPROC) <br/> listening on: (description = (address = (Protocol = TCP) (host = localhost. linux) (Port = 1521) </P> <p> connecting to (description = (address = (Protocol = IPC) (Key = EXTPROC ))) <br/> Status of the listener <br/> ---------------------- <br/> alias listener <br/> Version tnslsnr for Linux: version 9.2.0.4.0-production <br/> Start Date 22-Mar-2009 23:57:21 <br/> uptime 0 days 0 HR. 0 min. 0 sec <br/> Trace Level off <br/> Security off <br/> SNMP off <br/> listener parameter file/home/ora/ora9/Oracle/Network/admin /listener. ora <br/> listener log file/home/ora/ora9/Oracle/Network/log/listener. log <br/> listening endpoints summary... <br/> (description = (address = (Protocol = IPC) (Key = EXTPROC) <br/> (description = (address = (Protocol = TCP) (host = localhost. linux) (Port = 1521) <br/> services summary... <br/> service "plsextproc" has 1 instance (s ). <br/> instance "plsextproc", status unknown, has 1 handler (s) for this service... <br/> service "linuxdb" has 1 instance (s ). <br/> instance "linuxdb", status unknown, has 1 handler (s) for this service... <br/> service "wldev" has 1 instance (s ). <br/> instance "wldev", status unknown, has 1 handler (s) for this service... <br/> the command completed successfully
    According to the above prompt, the database and service listening have been successfully started.
    However, I didn't specify the database to be started. If I have created multiple databases, how can I start each database and the corresponding listening service?
    The above command only starts the default database linuxdb installed in Oracle and the corresponding listening service.

    Since the database is started, let's add the startup status. Oracle has three startup statuses:
    Nomount(Not Installed) Oracle only reads the configuration information in the INI file and initializes the SGA
    Mount(Installation) in addition to reading the INI file, Oracle also needs to read the control file and obtain information about the physical structure of the database.
    Open(Open) The database should check that all files are at the same time point, recover the error, roll back the unfinished transactions, and finally allow the user to access.
    The corresponding command is:
    SQL> startup nomount;
    SQL> alter database Mount;
    SQL> alter database open;
    The above three commands enable the database to enter three states: nomount, mount, and open. The direct execution of startup is equal to the sequential execution of these three states.

    Corresponding to the above three-stage startup command, the startup process is also divided into three phases:
    1)Start an instance
    Read the initialization parameter file. Pay attention to the reading order.
    Allocate system global Zone
    Start background processes
    Open the alertsid. Log File and tracking File
    2)Load Database
    Associate a database with an opened instance
    Open Control File
    Obtains the name and status of the data file and redo log file.
    3)Open Database
    Open a data file
    Open the online redo log file.

    Initialize the parameter file:
    Before Oracle9i, the database started to use the text init <Sid>. ora Initialization Files, after Oracle9i, all use spfile <Sid>. ora binary file, if you are in the $ ORACLE_HOME/DBS directory init. ora, initwd. ora is a sample file and can be deleted. In fact, these two files should be moved to the sample directory to avoid misleading users.
    I use oracle9.2i to directly Delete these two files. The database can also be started and used normally. To reduce the garbage, delete or remove these files.

  2. Create a database
    It is easy to find the Oracle database creation script on the Internet.
    However, for beginners, we recommend that you use dbca provided by Oracle. It provides a wizard to create a database that you need.
    I successfully created a database wldev using dbca.
    Under $ ORACLE_HOME/DBS, spfilewldev. ora is the initial file for database startup.
    In the listener. ora file under $ ORACLE_HOME/Network/admin, you have added a listener for the wldev service. The content is as follows:
    Listener = <br/> (description_list = <br/> (description = <br/> (address_list = <br/> (address = (Protocol = IPC) (Key = EXTPROC) <br/> (address_list = <br/> (address = (Protocol = TCP) (host = localhost. linux) (Port = 1521) <br/>) </P> <p> sid_list_listener = <br/> (sid_list = <br/> (sid_desc = <br/> (sid_name = plsextproc) <br/> (ORACLE_HOME =/home/ora/ora9/Oracle) <br/> (program = EXTPROC) <br/>) <br/> (sid_desc = <br/> (global_dbname = linuxdb) <br/> (ORACLE_HOME =/home/ora/ora9/Oracle) <br/> (sid_name = linuxdb) <br/> (sid_desc = <br/> (global_dbname = wldev) <br/> (ORACLE_HOME =/home/ora/ora9/Oracle) <br/> (sid_name = wldev) <br/>)
    Linuxdb is the database service installed by default, and wldev is added when the database is created.
    Listener. ora some introduction can see the article http://blog.csdn.net/chenxiaohua/archive/2009/03/19/4004128.aspx
    On the DB database, create the user DEV/123. Use the alias below to log on to the two databases respectively for testing.
    Log on to linuxdb and run the following command:
    Sqlplus DEV/123 @ local_dev
    Login successful.
    Log on to wldev and run the following command:
    Sqlplus DEV/123 @ wl_dev
    Logon Failed. The error message is as follows:
    Error: <br/> ORA-01034: Oracle not available <br/> ORA-27101: Shared Memory realm does not exist <br/> Linux error: 2: no such file or directory
    According to the error message, the Service Listening is normal and the database wldev is not started.

    Why is wldev not started? How does one specify the database to be started?

  3. Start a specified database
    Here is only one method.
    In sqlplus command mode, When you log on with sysdba, the system logs on to the database specified by the oracle_sid environment variable by default. In the current environment, linuxdb is started by default because Oracle Login User oracle_sid = linuxdb. The solution is to set oracle_sid = wldev before executing sqlplus "/As sysdba", then use sqlplus "/As sysdba", run startup to start wldev, and run the following command:
    [Ora @ localhost admin] $ export oracle_sid = wldev <br/> [ora @ localhost admin] $ sqlplus "/As sysdba" </P> <p> SQL * Plus: release 9.2.0.4.0-production on Mon Mar 23 00:29:58 2009 </P> <p> copyright (c) 1982,200 2, Oracle Corporation. all rights reserved. </P> <p> connected to an idle instance. </P> <p> SQL> startup <br/> Oracle instance started. </P> <p> total system global area 236000356 bytes <br/> fixed size 451684 bytes <br/> variable size 201326592 bytes <br/> database buffers 33554432 bytes <br/> redo buffers 667648 bytes <br/> database mounted. <br/> database opened. <br/> SQL>
    The system prompts that the database has been started successfully.

    In this case, we can use the sysdba role of wldev to create resources that we need.
    Create a tablespace:
    Create tablespace devbase
    Datafile '/home/ora/tbspace/wldevbase_2009032301.dbf' size 512 m;
    Create a user:
    Create user Dev
    Identified by 123.
    Default tablespace devbase
    Temporary tablespace temp;
    Grant the create session, connect, and resource permissions to the dev user.
    Grant resource, connect to Dev;
    Grant create session to Dev;
    Grant create table to Dev;
    Grant create tablespace to Dev;
    Grant create view to Dev;

    Now you can log on to wldev again and run the following command:
    Sqlplus DEV/123 @ local_dev
    Login successful.

    Note:
    Error 1The error message is as follows:
    ORA-01078: Failure in Processing System Parameters
    LRM-00109: cocould not open parameter file '/home/ora/ora9/Oracle/dbs/init <Sid>. ora
    So it must be that the environment variable oracle_sid is not correctly set. You can set the environment variable correctly.

  4. Modify listening port
    From the above listener. ora file, we can see that both linuxdb and wldev listen on the same port. If the traffic volume is large, it may cause a bottleneck.
    Back up the listener. ora file and run the command CP listener. ora 20090323_listener.ora.
    Edit the listener. ora file with the following content:
    Listener_wldev = <br/> (description_list = <br/> (description = <br/> (address_list = <br/> (address = (Protocol = TCP) (host = 192.168.1.111) (Port = 1621) <br/>) </P> <p> sid_list_listener_wldev = <br/> (sid_list = <br/> (sid_desc = <br/> (ORACLE_HOME =/home/ora/ora9/Oracle) <br/> (sid_name = wldev) <br/>) </P> <p> listener_linuxdb = <br/> (description_list = <br/> (description = <br/> (address_list = <br/> (address = (Protocol = TCP) (host = 192.168.1.111) (Port = 1521) <br/>) </P> <p> sid_list_listener_linuxdb = <br/> (sid_list = <br/> (sid_desc = <br/> (global_dbname = linuxdb) <br/> (ORACLE_HOME =/home/ora/ora9/Oracle) <br/> (sid_name = linuxdb) <br/>)
    Currently, you cannot simply use LSNRCTL start to start the listener, because the linrctl start command only starts the default listener. Currently, listener. ora does not have a listener.
    Now there are two listeners, listener_linuxdb and listener_wldev.
    Start two listeners respectively. The command is as follows:
    LSNRCTL start listener_linuxdb
    LSNRCTL start listener_wldev
    Modify the wl_dev alias in tnsname. ora of the client. Because the port number in the listener has changed to 1621, the modified content is as follows:
    Wl_dev = <br/> (description = <br/> (address = (Protocol = TCP) (host = 192.168.1.111) (Port = 1621 )) <br/> (CONNECT_DATA = <br/> (Server = dedicated) <br/> (SERVICE_NAME = wldev) <br/>)
    Use the following command to log on to the linuxdb and wldev databases again:
    Sqlplus DEV/123 @ wl_dev
    Successful.
    Sqlplus DEV/123 @ local_dev
    Successful.

    Through the above operations, we have a deeper understanding of the operations such as creating databases, creating service monitoring, starting databases, and starting service monitoring.

  5. Close Database
    Disable the use of database commands.
    The database to be closed is the database specified by oracle_sid in the environment variable, as described above.
    There is only one shutdown command for shutting down the database. Two commonly used data shutdown = shutdown normal means that the database is shut down normally. It needs to wait until all sessions end, but generally does not need to wait until all sessions end; shutdown immediate means to immediately shut down the database without waiting for all sessions to end.
    Shutdown command format:
    Shutdown Parameters
    Shutdown [Normal | transactional | immediate | abort];
    You can query the relevant documents for detailed descriptions of these parameters. The length is limited and cannot be described in detail.

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.