1.确定实例名
$export ORACLE_SID=orcl
2.设置环境变量
$[oracle@memory ~]$ vim /home/oracle/.bash_profile
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_home1
export TEMP=/tmp
export TEPDIR=/tmp
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
3.创建密码文件
$cd $ORACLE_HOME/dbs
$orapwd file=oraorcl password=oracle
4.创建参数文件
$vi initorcl.ora
db_name=orcl
memory_target=512000000
processes = 1500
audit_file_dest='/u01/app/oracle/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle'
open_cursors=500
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
undo_management=auto
control_files = '/u01/app/oracle/oradata/orcl/control01.ctl'
compatible ='11.2.0.4.0'
⚠️不存在的路径需要手动创建出来
5.启动数据库到nomount状态
$sqlplus / as sysdba
>create spfile from pfile;
>startup nomount;
6.创建建库脚本
$ cat createdb.sql --执行建库脚本
CREATE DATABASE orcl
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/orcl/redo01.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/orcl/redo02.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/orcl/redo03.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/app/oracle/oradata/orcl/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/orcl/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/orcl/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
--SEGMENT SPACE MANAGEMENT auto
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/orcl/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/orcl/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
7.登录已经是nomount的实例调用脚本
$sqlplus / as sysdba
>@createdb.sql
8.执行所需要的脚本
SYS>@?/rdbms/admin/catalog.sql --创建数据字典(数据字典视图、动态性能视图、公有同义词等)
SYS>@?/rdbms/admin/catproc.sql --创建需要存储过程、函数、触发器,授权信息等SYSTEM>@?/sqlplus/admin/pupbld.sql --sqlplus所需要的一些设置,不执行用户无法切换
@?/rdbms/admin/utlsampl.sql --创建scott模式