Step 1: Specify an Instance Identifier (SID) [指定SID]
假如这里 我们名字为 hello
linux 下 执行命令 :
cd $ORACLE_HOME/dbs
touch setenv.sh
vi命令 输入以下内容
ORACLE_SID=hello
ORACLE_BASE=/u01
ORACLE_HOME=$ORACLE_BASE/oracle
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH PATH
执行 . ./setenv.sh
Step 2: Ensure That the Required Environment Variables Are Set
查看sid是否修改为hello
[oracle@localhost dbs]$ env | grep ORACLE
ORACLE_SID=hello
ORACLE_BASE=/u01
ORACLE_HOME=/u01/database
ORACLE_SID=hello
ORACLE_BASE=/u01
ORACLE_HOME=/u01/database
Step 3: Choose a Database Administrator Authentication Method
我们这里使用 系统验证 但仍需要创建一个 password文件
通过命令 orapwd file=orapwhello password=liaomin entries=10; 在dbs目录下 创建 orapwd[SID]密码文件
Step 4: Create the Initialization Parameter File
这里我们拷贝一个通过dbca创建的spfile文件 我这里通过命令
create pfile='inithello.ora' from spfile='spfileorcl.ora'
内容基本如下
[oracle@localhost dbs]$ vi inithello.ora
orcl.__db_cache_size=318767104
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/u01'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=318767104
orcl.__sga_target=473956352
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=138412032
orcl.__streams_pool_size=0
*.audit_file_dest=' /u01/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files=' /u01/oradata/orcl/control01.ctl','/ u01/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest=' /u01/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=792723456
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
orcl.__db_cache_size=318767104
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/u01'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=318767104
orcl.__sga_target=473956352
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=138412032
orcl.__streams_pool_size=0
*.audit_file_dest=' /u01/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files=' /u01/oradata/orcl/control01.ctl','/ u01/flash_recovery_area/orcl/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest=' /u01/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=792723456
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
标红的目录我们都必须要手工去创建 并且替换我们对应的库的目录 不然覆盖orcl就不好了
我们修改后
hello.__db_cache_size=318767104
hello.__java_pool_size=4194304
hello.__large_pool_size=4194304
hello.__oracle_base='/u01'#ORACLE_BASE set from environment
hello.__pga_aggregate_target=318767104
hello.__sga_target=473956352
hello.__shared_io_pool_size=0
hello.__shared_pool_size=138412032
hello.__streams_pool_size=0
*.audit_file_dest='/u01/admin/hello/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/oradata/hello/control01.ctl','/u01/flash_recovery_area1/hello/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='hello'
*.db_recovery_file_dest='/u01/flash_recovery_area1'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=792723456
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
hello.__java_pool_size=4194304
hello.__large_pool_size=4194304
hello.__oracle_base='/u01'#ORACLE_BASE set from environment
hello.__pga_aggregate_target=318767104
hello.__sga_target=473956352
hello.__shared_io_pool_size=0
hello.__shared_pool_size=138412032
hello.__streams_pool_size=0
*.audit_file_dest='/u01/admin/hello/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/oradata/hello/control01.ctl','/u01/flash_recovery_area1/hello/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='hello'
*.db_recovery_file_dest='/u01/flash_recovery_area1'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=792723456
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
开始执行命令创建目录
cd
/u01/admin/
cp -r orcl hello
依次 通过 rm -r * 清除类似udum bdump文件夹下的文件
执行 cd /u01/oradata | mkdir hello;
执行 cd /u01 | mkdir
flash_recovery_area1;
执行 cd
/
u01/flash_recovery_area1 | mkdir hello
将上面修改后的参数内容 写入 $ORACLE/dbs/inithello.ora
执行create spfile='spfileorcl.ora' from pfile='inithello.ora'
Step 5: (Windows Only) Create an Instance
省略 centosStep 6: Connect to the Instance
首先执行 cd $ORALCE_HOME/dbs
. ./setenv.sh
env | grep ORA 查看 sid是否修改为hello
$ sqlplus /nolog SQL> CONNECT / AS SYSDBA
Step 7: Create a Server Parameter File
第4部已完成
Step 8: Start the Instance
STARTUP NOMOUNT
Step 9: Issue the CREATE DATABASE Statement
执行 create database命令CREATE DATABASE hello
USER SYS IDENTIFIED BY liaomin
USER SYSTEM IDENTIFIED BY liaomin
LOGFILE GROUP 1 ('/u01/oradata/hello/redo01a.log','/u01/oradata/hello/redo01b.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/oradata/hello/redo02a.log','/u01/oradata/hello/redo02b.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/oradata/hello/redo03a.log','/u01/oradata/hello/redo03b.log') SIZE 100M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/oradata/hello/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/oradata/hello/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/oradata/hello/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/oradata/hello/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE UNDOTBS1
DATAFILE '/u01/oradata/hello/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
这里在dbs目录下创建 create.sql 内容为
spool /u01/create.log
上面的create database 语句
spool off
如果这里
UNDO TABLESPACE UNDOTBS1 和 spfile的*.undo_tablespace='UNDOTBS1' 名称不一致 将报错
再次确认env中 sid为hello sqlplus 连接
连接到nomount状态后
执行 @?/dbs/create.sql 执行等待
如果执行失败 需要删除 创建那些目录下的文件 改正错误后 重新 执行 create。sql文件
执行 完成 提示 create success
执行命令
alter database mount;
alter database open;
SQL> select * from dual;
D
-
X
1 row selected.
D
-
X
1 row selected.
Step 10: Create Additional Tablespaces
open状态下 执行
CREATE TABLESPACE hello_tbs LOGGING DATAFILE '/u01/oradata/hello/apps01.dbf' SIZE 500M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;
Step 11: Run Scripts to Build Data Dictionary Views
open状态下 执行 下面sql语句 In SQL*Plus, connect to your Oracle Database instance with the SYSDBA
administrative privilege:
@?/rdbms/admin/catalog.sql @?/rdbms/admin/catproc.sql
In SQL*Plus, connect to your Oracle Database instance as SYSTEM
user:
@?/sqlplus/admin/pupbld.sql测试数据库是否启动
SQL> 1 row selected.
SQL> create table test(id number,text varchar2(20));
Table created.
SQL> insert into test values(1,'aaa');
1 row created.
SQL> select * from test;
ID TEXT
---------- --------------------
1 aaa
1 row selected.
成功
SQL> create table test(id number,text varchar2(20));
Table created.
SQL> insert into test values(1,'aaa');
1 row created.
SQL> select * from test;
ID TEXT
---------- --------------------
1 aaa
1 row selected.
如果想从新创建的数据库hello 切换回 以前的数据库 orcl
执行命了
shutdown immediate
su - oracle --这里默认执行oracle目录下的.bash_profile 会自动设置环境变量到 orcl
此时从新 启动后
SQL> show parameter db_name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string orcl
SQL> select * from test;
select * from test
*
ERROR at line 1:
ORA-00942: table or view does not exist
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string orcl
SQL> select * from test;
select * from test
*
ERROR at line 1:
ORA-00942: table or view does not exist
没有test说明不是hello库