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、手工建库脚本:
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31392094/viewspace-2125862/ ,如需转载,请注明出处,否则将追究法律责任。