原文地址:http://blog.csdn.net/sunchenglu7/article/details/39676659
如果条件允许,可用图形化界面创建更方便快捷
以root用户登录,敲./dbca,如果跳不出图形化界面,就用下面的手动创建
一、以oracle用户登录
二、获取oracle安装路径
[oracle@linux] echo $ORACLE_HOME
[oracle@linux] cd $ORACLE_HOME
[oracle@linuxoracle/product/11g/db] cd dbs
三、创建新实例的参数文件
[[email protected] dbs]$ ls
hc_orcl2.dat initdw.ora initorcl.ora lkORCL2 orapworcl2 spfileorcl.ora
hc_orcl.dat init.ora lkORCL orapworcl spfileorcl2.ora
[[email protected] dbs]$ pwd
/oracle/inst1/product/10.2.0/db_1/dbs
[[email protected] dbs]$ cp initorcl.ora initorcl3.ora
注:这里我们通过拷贝原实例参数文件的方法进行创建,然后再进行修改。
修改新实例的参数文件
orcl.__db_cache_size=184549376
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__shared_pool_size=88080384
orcl.__streams_pool_size=0
*.audit_file_dest='/oracle/inst1/admin/orcl3/adump'
*.background_dump_dest='/oracle/inst1/admin/orcl3/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oracle/inst1/oradata/orcl3/control01.ctl','/oracle/inst1/oradata/orcl3/control02.ctl','/oracle/inst1/oradata/orcl3/control03.ctl'
*.core_dump_dest='/oracle/inst1/admin/orcl3/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl3'
*.db_recovery_file_dest='/oracle/inst1/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/oracle/inst1/arch/orcl3'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/inst1/admin/orcl3/udump'
创建新实例的相关目录:
[[email protected] ~]$ cd /oracle/inst1/admin/
[[email protected] admin]$ mkdir orcl3
[[email protected] admin]$ ls
orcl orcl2 orcl3
[[email protected] admin]$ cd orcl3
[[email protected] orcl3]$ mkdir adump bdump cdump udump
[[email protected] orcl3]$ cd /oracle/inst1/oradata/
[[email protected] oradata]$ mkdir orcl3
[[email protected] oradata]$ ls
orcl orcl2 orcl3
[[email protected] oradata]$ pwd
/oracle/inst1/oradata
[[email protected] oradata]$ ls
orcl orcl2 orcl3
[[email protected] oradata]$ cd ..
[[email protected] inst1]$ ls
admin arch database flash_recovery_area libXp-1.0.0-8.1.el5.i386.rpm oradata oraInventory product
[[email protected] inst1]$ cd arch
[[email protected] arch]$ ls
orcl orcl2
[[email protected] arch]$ mkdir orcl3
[[email protected] arch]$ ls
orcl orcl2 orcl3
启动实例测试
[[email protected] arch]$ export ORACLE_SID=orcl3
[[email protected] arch]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 5 17:46:40 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba;
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl3
创建密码文件:(该步骤一定要执行,否则SYS没有SYSDBA权限登录)
[email protected] arch]$ orapwd file=”/oracle/inst1/product/10.2.0/db_1/dbs/orapworcl3” password=oracle entries=10;
四、创建数据库
4.1、编写数据库创建脚本
下面为创建数据库的脚本:(注意:路径不要有空格)
CREATE DATABASE orcl5
USER SYS IDENTIFIED BY sys
USER SYSTEM IDENTIFIED BY manager
LOGFILE GROUP 1 ('/mnt/sda3/oracle/oradata/orcl5/redo01.log') SIZE 20M,
GROUP 2 ('/mnt/sda3/oracle/oradata/orcl5/redo02.log') SIZE 20M,
GROUP 3 ('/mnt/sda3/oracle/oradata/orcl5/redo03.log') SIZE 20M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET UTF8
DATAFILE '/mnt/sda3/oracle/oradata/orcl5/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/mnt/sda3/oracle/oradata/orcl5/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1 datafile '/mnt/sda3/oracle/oradata/orcl5/tbs_1.dbf' size 50m
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/mnt/sda3/oracle/oradata/orcl5/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/mnt/sda3/oracle/oradata/orcl5/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
4.3、验证是否创建成功
查询数据库状态
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL>
4.4、运行后续脚本,创建数据字典及相关视图
SQL>conn sys as sysdba
SQL>@?/rdbms/admin/catalog.sql;
此过程可能需要10分钟左右
SQL>@?/rdbms/admin/catproc.sql;
此过程可能需要15分钟左右
SQL>@?/rdbms/admin/catblock.sql;
SQL>@?/rdbms/admin/catoctk.sql;
SQL>@?/rdbms/admin/owminst.plb;
SQL>conn system/ manager
SQL>@?/sqlplus/admin/pupbld.sql;
SQL>@?/sqlplus/admin/help/hlpbld.sql helpus.sql
五、客户端连接
5.1、监听文件配置(listener.ora)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /oracle/inst1/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl5)
(ORACLE_HOME = /oracle/inst1/product/10.2.0/db_1)
(SID_NAME = orcl5)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl3)
(ORACLE_HOME = /oracle/inst1/product/10.2.0/db_1)
(SID_NAME = orcl3)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.14.54.199)(PORT = 1521))
)
)
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.14.54.199)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)