工作环境:linux6.5 ;oracle11g软件
1.编辑环境变量
[oracle@PROD1 ~]$ vi .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=PROD1
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_TATH=$ORACLE_HOME/lib:/lib:/usr/lib
~
2.创建口令文件
[oracle@PROD1 dbs]$ orapwd file=orapwPROD1 password=oracle
3.创建参数文件
[oracle@PROD1 dbs]$ ls
init.ora orapwPROD1
[oracle@PROD1 dbs]$ cat init.ora|grep -v ^#>initPROD1.ora
[oracle@PROD1 dbs]$ vi initPROD1.ora
db_name='PROD1'
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/PROD1/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=PROD1XDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files = (/u01/app/oracle/oradata/PROD1/control01.ctl, /u01/app/oracle/flash_recovery_area/control02.ctl)
compatible ='11.2.0'
:%s@ora_@/u01/app/oracle/oradata/PROD1/@gi
4.创建目录
[oracle@PROD1 ~]$ mkdir -p /u01/app/oracle/admin/PROD1/adump
[oracle@PROD1 ~]$ mkdir -p /u01/app/oracle/flash_recovery_area
[oracle@PROD1 ~]$ mkdir -p /u01/app/oracle/oradata/PROD1
5.创建数据库脚本
[oracle@PROD1 dbs]$ cd
[oracle@PROD1 ~]$ vi create_database.sql
CREATE DATABASE PROD1
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/PROD1/redo01a.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/PROD1/redo02a.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/PROD1/redo03a.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/PROD1/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD1/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/PROD1/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/PROD1/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/PROD1/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
~
6.开始创建数据库
[oracle@PROD1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sun Dec 13 00:29:09 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2260088 bytes
Variable Size 671089544 bytes
Database Buffers 390070272 bytes
Redo Buffers 5517312 bytes
SQL> @create_database.sql
Database created.
7.更新数据字典,存储过程及用户登录受限设置
[oracle@PROD1 ~]$ ls
create_database.sql
[oracle@PROD1 ~]$ vi row
sqlplus / as sysdba << EOF
@?/rdbms/admin/catalog.sql;
@?/rdbms/admin/catproc.sql;
@?/sqlplus/admin/pupbld.sql;
quit
EOF
[oracle@PROD1 ~]$ ls
create_database.sql row
[oracle@PROD1 ~]$ ./row
-bash: ./row: Permission denied
[oracle@PROD1 ~]$ ll
total 8
-rw-r--r--. 1 oracle oinstall 1081 Dec 13 00:17 create_database.sql
-rw-r--r--. 1 oracle oinstall 121 Dec 13 00:38 row
[oracle@PROD1 ~]$ chmod 744 row
[oracle@PROD1 ~]$ ll
total 8
-rw-r--r--. 1 oracle oinstall 1081 Dec 13 00:17 create_database.sql
-rwxr--r--. 1 oracle oinstall 121 Dec 13 00:38 row
[oracle@PROD1 ~]$ ./row
SQL>
SQL> -- End of pupbld.sql
SQL> SELECT dbms_registry_sys.time_stamp('CATPROC') AS timestamp FROM DUAL;
TIMESTAMP
--------------------------------------------------------------------------------
COMP_TIMESTAMP CATPROC 2015-12-13 01:06:21
SQL> select status from v$instance;
STATUS
------------
OPEN
完成
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30606744/viewspace-1871191/
,如需转载,请注明出处,否则将追究法律责任。