手工创建oracle 数据库实例
1.确认oracle实例名,如orcl
2.创建相关的目录,在$ORACLE_BASE/oradata
主要有 $ORACLE_BASE/oradata/orcl/admin/adump
$ORACLE_BASE/oradata/orcl/admin/bdump
$ORACLE_BASE/oradata/orcl/admin/cdump
$ORACLE_BASE/oradata/orcl/admin/pfile
$ORACLE_BASE/oradata/orcl/admin/udump
创建闪存目录
$ORACLE_BASE/oradata/flash_recovery_area
mkdir -p $ORACLE_BASE/oradata/orcl/admin/adump
3.创建初始化文件
在$ORACLE_HOME/dbs目录下
命名方法
init实例名.ora 本例中initorcl.ora
cp init.ora initorcl.ora 即可以生成
vi initorcl.ora 进行编辑
db_name='实例名' 本例中orcl,必须填写
给出各个文件位置
内容如下:
db_name='orcl' #必须给出的名字
memory_target=1G
processes = 150
audit_file_dest='/opt/oracle/oradata/admin/orcl/adump' #必须给出的名字
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/opt/oracle/oradata/flash_recovery_area' #必须给出的名字
db_recovery_file_dest_size=2G
diagnostic_dest='/opt/oracle' #必须给出的名字
dispatchers='(PROTOCOL=TCP) (SERVICE=orcl)'
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 = (orcl_control1, orcl_control2)
compatible ='11.2.0'
4 设置ORACLE_SID变量
修改.bash_profile
export ORACLE_SID=orcl
5. 建立创建数据库脚本 createdb.sql
create database orcl ==数据SID名称
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
DATAFILE
'/opt/oracle/oradata/orcl/system01.dbf' size 100m reuse autoextend on next 1m maxsize unlimited
sysaux datafile
'/opt/oracle/oradata/orcl/syaux01.dbf' size 100m reuse autoextend on next 1m maxsize unlimited
default temporary tablespace TEMP tempfile
'/opt/oracle/oradata/orcl/temp01.dbf' size 20m reuse autoextend on next 64k maxsize unlimited
undo tablespace UNDOTBS1 datafile
'/opt/oracle/oradata/orcl/undo01.dbf' size 20m reuse autoextend on next 5m maxsize unlimited
logfile
GROUP 1 ('/opt/oracle/oradata/orcl/redo01.dbf') size 10m,
GROUP 2 ('/opt/oracle/oradata/orcl/redo02.dbf') size 10m,
GROUP 3 ('/opt/oracle/oradata/orcl/redo03.dbf') size 10m
CHARACTER SET ZHS16GBK ==字符集
NATIONAL CHARACTER SET AL16UTF16
6 .sqlplus "/as sysdba"
startup nomount;
执行创建createdb.sql
@?$ORACLE_BASE/oradata/createdb.sql
7.创建数据字典
@?/rdbms/admin/catalog.sql;
@?/rdbms/admin/catproc.sql;
切换用户system/manager
执行 本人没有执行此脚本,
@?/sqlplus/admin/pupbld.sql;
8.安装全文检索
用sys以sysdba身份登录
创建全文检索表空间
create tablespace ctxsys logging datafile='/opt/oracle/oradata/orcl/ctxsys01.dbf' size 200m autoextend on maxsize unlimited;
执行脚本
@?/ctx/admin/catctx.sql ctxsys ctxsys temp nolock; --参数说明 密码,表空间 临时表空间 用户状态
connect ctxsys/ctxsys;
@?/ctx/admin/defaults/drdefus.sql
9.配置监听
$ORACLE_HOME/network/admin
vi listener.ora
SID_LIST_orcl=
(SID_DESC=
(SID_NAME=orcl)
(ORACLE_HOME=/opt/oracle/product/11.2.0/db_1)
)
)
orcl=
(DESCRIPTIONI_LIST=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)
(HOST=192.168.56.100)(PORT=1521)
)
)
10 配置tnsnames.ora
orcl=
(
DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.100)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME=orcl)
)
)
11 手工启停
启动监听:lsnrctl start
停止监听:lsnrctl stop
启动数据库
sqlplus "/as sysdba"
startup
关闭数据库
sqlplus "/as sysdba"
shutdown