当前位置:   article > 正文

oracle创建新实例_oracle 创建实例

oracle 创建实例

使用oracle用户登录,或su到oracle用户

1、首先设置要创建的ORACLE的SID
export ORACLE_SID=test

2、 创建相应目录

#$ORACLE_BASE=/home/oracle/app

mkdir /data/orcltest/test
mkdir -p $ORACLE_BASE/admin/test
mkdir -p $ORACLE_BASE/admin/test/{a,b,c,u}dump
mkdir -p $ORACLE_BASE/admin/test/pfile
mkdir -p $ORACLE_BASE/oradata/test

3、在$ORACLE_HOME/dbs目录下创建初始化文件

命名方法:init实例名.ora 本例中inittest.ora 
cp init.ora inittest.ora 即可以生成 
vi inittest.ora 进行编辑,将里面的内容对应修改一下,我的修改完如下:

db_name='test'
memory_target=1G
processes = 150
audit_file_dest='/home/oracle/app/admin/test/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/home/oracle/app/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/home/oracle/app'
dispatchers='(PROTOCOL=TCP) (SERVICE=testXDB)'
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 = (ora_control9, ora_control10)
compatible ='11.2.0'
注意不要用原来的<ORACLE_BASE>作为路径,修改为对应的绝对路径,否则会报错

而且注意control_files应该是新的文件,否则会报文件已存在的错误

4、创建密码文件

orapwd file=$ORACLE_HOME/dbs/orapwtest password=test2017 entries=5 force=y 
这里设置的是sys用户,密码是test2017

5、创建oracle的建库脚本

脚本文件createdb.sql,内容如下,可以放在$ORACLE_BASE/oradata/test下面
vi $ORACLE_BASE/oradata/test/createdb.sql

create database test
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
DATAFILE
'/data/orcltest/test/system01.dbf' size 200m reuse autoextend on next 5m maxsize unlimited extent management local
sysaux datafile
'/data/orcltest/test/sysaux01.dbf' size 200m reuse autoextend on next 5m maxsize unlimited
default temporary tablespace TEMP tempfile
'/data/orcltest/test/temp01.dbf' size 30m reuse autoextend on next 640k maxsize unlimited undo tablespace UNDOTBS1 datafile
'/data/orcltest/test/undo01.dbf' size 30m reuse autoextend on next 5M maxsize unlimited
logfile
GROUP 1 ('/data/orcltest/test/redo1.dbf') size 20m,
GROUP 2 ('/data/orcltest/test/redo2.dbf') size 20m,
GROUP 3 ('/data/orcltest/test/redo3.dbf') size 20m
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16

6、执行建库和数据字典脚本

以sysdba进入:

sqlplus / as sysdba

执行下面命令:

startup nomout;
@$ORACLE_BASE/oradata/test/createdb.sql
@?/rdbms/admin/catalog.sql;
@?/rdbms/admin/catproc.sql;
@?/rdbms/admin/catexp.sql;


7、修改监听配置文件listener.ora

到$ORACLE_HOME/network/admin目录下:vi listener.ora

test =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 114.55.30.70)(PORT = 1522))
      )
    )
  )
SID_LIST_test =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test)
      (ORACLE_HOME = /data/install/oracle/product/11.2.0/db_1)
      (SID_NAME = test)
    )
  )


8、启停监听和数据库实例

启停监听

lsnrctl start test
lsnrctl stop test

启停实例

  export ORACLE_SID=test
  sqlplus / as sysdba
  >startup
  >shutdown

9、创建表空间和用户

create tablespace test datafile '/data/orcltest/test/test.dbf' size 1024m autoextend on next 1024m maxsize 32767m extent management local;
create user test identified by test2017 default tablespace  test;
grant dba,connect,resource,create session to test;

10、扩展用户表空间

alter tablespace USERS add datafile '/data/orcltest/test/user2.dbf' size 1024m autoextend on next 1024m maxsize 32767m;

欢迎关注交流:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/956725
推荐阅读
相关标签
  

闽ICP备14008679号