ITPub博客

首页 > 数据库 > Oracle > 手动创建数据库过程

手动创建数据库过程

原创 Oracle 作者:skyin_1603 时间:2016-10-06 11:44:56 0 删除 编辑

1、设置环境变量:

[oracle@enmo ~]$ cat .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin


export PATH

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export ORACLE_SID=PROD

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

编辑后,使其生效:

. .bash_profile

2、创建密码文件(作用:允许远程用密码方式以sysdba身份登陆数据库,可有可无):

[oracle@enmo ~]$ cd $ORACLE_HOME/dbs

[oracle@enmo dbs]$ pwd

/u01/app/oracle/product/11.2.0/dbhome_1/dbs

[oracle@enmo dbs]$ ls

init.ora  init.ora.bck

3、生成密码文件:

[oracle@enmo dbs]$ orapwd file=orapwPROD password=oracle

[oracle@enmo dbs]$ ls

init.ora  init.ora.bck  orapwPROD

[oracle@enmo dbs]$

4、生成pfile文件:

[oracle@enmo dbs]$ cat init.ora |grep -v ^#|grep -v ^$ > initPROD.ora

[oracle@enmo dbs]$ ls

init.ora  init.ora.bck  initPROD.ora  orapwPROD

5、修改pfile文件:

[oracle@enmo dbs]$ vi initPROD.ora

db_name='PROD'

memory_target=800M

processes = 150

audit_file_dest='/u01/app/oracle/admin/prod/adump'

#audit_trail ='db'

db_block_size=8192

db_domain='oracle.com'

#db_recovery_file_dest='/flash_recovery_area'

#db_recovery_file_dest_size=2G

#diagnostic_dest=''

dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'

open_cursors=300

remote_login_passwordfile='EXCLUSIVE'

undo_tablespace='UNDOTBS1'

control_files = (/u01/app/oracle/oradata/PROD/ora_control1.ctl,/u01/app/oracle/oradata/PROD/ora_control2.ctl)

compatible ='11.2.0'

6、根据pfile创建目录adump目录和控制文件目录:

[oracle@enmo ~]$  mkdir -p $ORACLE_BASE/admin/prod/adump

[oracle@enmo ~]$  mkdir -p $ORACLE_BASE/oradata/PROD/

7、通过pfile创建spfile:

[oracle@enmo dbs]$ ls

init.ora  init.ora.bck  initPROD.ora  orapwPROD

[oracle@enmo dbs]$ echo $ORACLE_SID

PROD

[oracle@enmo dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 5 23:29:53 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> !ls

init.ora  init.ora.bck  initPROD.ora  orapwPROD  spfilePROD.ora


8、数据库启动到nomount(默认情况下,oracle会使用spfile启动数据库):

SQL> startup nomount;

ORACLE instance started.

Total System Global Area  835104768 bytes

Fixed Size                  2257840 bytes

Variable Size             541068368 bytes

Database Buffers          289406976 bytes

Redo Buffers                2371584 bytes

SQL> show parameter spfile

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      /u01/app/oracle/product/11.2.0

                                                 /dbhome_1/dbs/spfilePROD.ora


SQL> select status from v$instance;

STATUS

------------

STARTED

 

9、手工建库脚本:
create database prod
   user sys identified by oracle
   user system identified by oracle
   logfile group 1('/u01/app/oracle/oradata/PROD/redo01.log') size 10M blocksize 512,
           group 2('/u01/app/oracle/oradata/PROD/redo02.log') size 10M blocksize 512,
  group 3('/u01/app/oracle/oradata/PROD/redo03.log') size 10M 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/PROD/system01.dbf' size 325M reuse
   sysaux datafile '/u01/app/oracle/oradata/PROD/sysaux01.dbf' size 325M reuse
   default tablespace users
     datafile '/u01/app/oracle/oradata/PROD/users01.dbf'
     size 50M reuse AUTOEXTEND ON MAXSIZE UNLIMITED
   default temporary tablespace tempts1
     tempfile  '/u01/app/oracle/oradata/PROD/temp01.dbf' size 20M reuse
   UNDO TABLESPACE UNDOTBS1
     datafile '/u01/app/oracle/oradata/PROD/undotbs01.dbf'
     size 50M reuse AUTOEXTEND ON MAXSIZE UNLIMITED;
10、查看数据库实例状态:
SQL> select status from v$instance;

STATUS
------------
OPEN

11、查看相关参数:
SQL> show parameter control_files
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      /u01/app/oracle/oradata/PROD/o
                                                 ra_control1.ctl, /u01/app/orac
                                                 le/oradata/PROD/ora_control2.c
                                                 tl
SQL> show parameter undo  
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS1

SQL> show parameter spfile
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/spfilePROD.ora
SQL>


12、创建字典表及工具包:

--必执行脚本
SQL> conn / as sysdba
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
SQL> conn system/passwd
SQL> @?/sqlplus/admin/pupbld.sql
--可选脚本
SQL> conn / as sysdba
SQL> @?/rdbms/admin/catblock.sql
SQL> @?/rdbms/admin/catoctk.sql
SQL> @?/rdbms/admin/owminst.plb

执行完以上的脚本,手动建库就完成了。手动建库没有hr与scott示例两个用户。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31392094/viewspace-2125862/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2016-09-06

  • 博文量
    231
  • 访问量
    215133