oracle 11g手工建库步骤(初学者)

时间:2022-02-05 08:29:39

要建立的数据库ORACLE_SID=test1
sys和system的密码为oracle
1、建立相应的目录
mkdir /u01/app/oracle/oradata/test1
mkdir /u01/app/oracle/fast_recovery_area/test1
mkdir -p /u01/app/oracle/admin/test1/{a,dp}dump

2、指定oracle_sid
export ORACLE_SID=test1


3、确定当前用户的环境变量
echo $ORACLE_HOME
echo $ORACLE_SID
echo $PATH


4、选择数据库的认证方式,这里选择口令文件验证。
orapwd file=orapwtest password=oracle


5、为数据库添加一个参数文件。
cd $ORACLE_HOME/dbs
cp init.ora inittest.ora
vi inittest.ora (添加以下的内容)

db_name='test1'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/test1/adump'
audit_trail ='db'
db_block_size=8192
db_domain='oracle.com'
db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=test1XDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files =
('/u01/app/oracle/oradata/test1/contorl01.ctl','/u01/app/oracle/fast_recovery_area/test1/control02.ctl')
compatible ='11.2.0'


6、连接到实例
sqlplus / as sysdba


7、打开实例到nomount状态
startup nomount;


8、创建建库语句,执行建库语句
cd
vi createdbtest.sql (添加以下的语句,也可以直接在sqlplus里面执行)
CREATE DATABASE test1
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/test1/redo01a.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/test1/redo02a.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/test1/redo03a.log') SIZE 100M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/test1/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/test1/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/test1/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/test1/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/test1/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;


9、执行创建数据字典的脚本

sqlplus  / as sysdba

@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql
@?/rdbms/admin/utlrp.sql

conn system/oracle
@?/sqlplus/admin/pupbld.sql

 

 


10、到此数据库就创建好了。