Linux+Oracle11gR2手动创建数据库及数据库启动过程(一)startup nomount
1.设置环境变量
export ORACLE_BASE=/oracle/app/oracle
exportORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
2.安装完oracle11gR2软件后,ORACLE_BASE下已经创建了3000多个目录
[oracle@rac11g ~]$ du /oracle/app |wc
3184 6368 277051
有3个主目录:
[oracle@rac11g ~]$ ls -l $ORACLE_BASE
total 12
drwxr-xr-x. 2 oracle oinstall 4096 Jul 22 16:52 checkpoints
drwxrwxr-x. 11 oracle oinstall 4096 Jul 2216:50 diag
drwxr-xr-x. 3 oracle oinstall 4096 Jul 22 16:44 product
在$ORACLE_HOME/dbs下面已经有一个默认的init.ora文件,包含一些默认参数。
[oracle@rac11g dbs]$ more init.ora |grep -v"#"
db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='
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 = (ora_control1,ora_control2)
compatible ='11.2.0'
此时共享内存是空的
[oracle@rac11g app]$ ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
------ Semaphore Arrays --------
key semid owner perms nsems
------ Message Queues --------
key msqid owner perms used-bytes messages
3.重写pfile文件并启动数据库
[oracle@rac11g dbs]$ rm init.ora
--pfile文件中只填入一个dbname就可以启动到nomount状态了
[oracle@rac11g dbs]$ echo dbname='DB11G'>initDB11G.ora
[oracle@rac11g dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production onThu Jul 23 09:14:13 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 238034944 bytes
Fixed Size 2227136 bytes
Variable Size 180356160 bytes
Database Buffers 50331648 bytes
Redo Buffers 5120000 bytes
此时已读入参数文件,共有300多个参数,包括db_unique_name、instance_name、service_names等已经复制了db_name的值
SQL> show parameter name
db_file_name_convert string
db_name string DB11G
db_unique_name string DB11G
global_names boolean FALSE
instance_name string DB11G
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string DB11G
实例也已启动,看进程
[oracle@rac11g app]$ ps -ef|grep DB11G|grep -v grep
oracle 4884 1 0 09:14 ? 00:00:00 ora_pmon_DB11G
oracle 4886 1 0 09:14 ? 00:00:00 ora_psp0_DB11G
oracle 4888 1 1 09:14 ? 00:00:10 ora_vktm_DB11G
oracle 4892 1 0 09:14 ? 00:00:00 ora_gen0_DB11G
oracle 4894 1 0 09:14 ? 00:00:00 ora_diag_DB11G
oracle 4896 1 0 09:14 ? 00:00:00 ora_dbrm_DB11G
oracle 4898 1 0 09:14 ? 00:00:00 ora_dia0_DB11G
oracle 4900 1 0 09:14 ? 00:00:00 ora_mman_DB11G
oracle 4902 1 0 09:14 ? 00:00:00 ora_dbw0_DB11G
oracle 4904 1 0 09:14 ? 00:00:00 ora_lgwr_DB11G
oracle 4906 1 0 09:14 ? 00:00:00 ora_ckpt_DB11G
oracle 4908 1 0 09:14 ? 00:00:00 ora_smon_DB11G
oracle 4910 1 0 09:14 ? 00:00:00 ora_reco_DB11G
oracle 4912 1 0 09:14 ? 00:00:00 ora_mmon_DB11G
oracle 4914 1 0 09:14 ? 00:00:00 ora_mmnl_DB11G
[oracle@rac11g app]$ ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 163844 oracle 640 8388608 16
0x00000000 196613 oracle 640 230686720 16
0xebe20b18 229382 oracle 640 2097152 16
------ Semaphore Arrays --------
key semid owner perms nsems
0x26d4945c 163842 oracle 640 124
------ Message Queues --------
key msqid owner perms used-bytes messages
再用du对比未启动实例之前的目录,发现diag目录下创建了一些以实例名命名的目录
/oracle/app/oracle/diag/rdbms/db11g/DB11G/lck
/oracle/app/oracle/diag/rdbms/db11g/DB11G/metadata_pv
/oracle/app/oracle/diag/rdbms/db11g/DB11G/sweep
/oracle/app/oracle/diag/rdbms/db11g/DB11G/hm
/oracle/app/oracle/diag/rdbms/db11g/DB11G/metadata_dgif
/oracle/app/oracle/diag/rdbms/db11g/DB11G/cdump
/oracle/app/oracle/diag/rdbms/db11g/DB11G/alert
/oracle/app/oracle/diag/rdbms/db11g/DB11G/stage
/oracle/app/oracle/diag/rdbms/db11g/DB11G/trace
/oracle/app/oracle/diag/rdbms/db11g/DB11G/incident
/oracle/app/oracle/diag/rdbms/db11g/DB11G/metadata
/oracle/app/oracle/diag/rdbms/db11g/DB11G/ir
/oracle/app/oracle/diag/rdbms/db11g/DB11G/incpkg
/oracle/app/oracle/diag/rdbms/db11g/DB11G
/oracle/app/oracle/diag/rdbms/db11g
/oracle/app/oracle/product/11.2.0/dbhome_1/log/diag
Shutdown之后,共享内存清空,文件目录保留
4.此时,如果如果修改db_name值,重新启动实例
SQL> startup nomount
ORACLE instance started.
Total System Global Area 238034944 bytes
Fixed Size 2227136 bytes
Variable Size 180356160 bytes
Database Buffers 50331648 bytes
Redo Buffers 5120000 bytes
SQL> show parameter name
NAME TYPE VALUE
---------------------------------------------------------- ------------------------------
db_file_name_convert string
db_name string ORA11G
db_unique_name string ORA11G
global_names boolean FALSE
instance_name string ORA11G
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string ORA11G
再用du对比未启动实例之前的目录,发现又多了一套ORA11G的目录
[oracle@rac11g dbs]$ du/oracle/app/oracle/diag/rdbms
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/lck
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/metadata_pv
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/sweep
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/hm
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/metadata_dgif
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/cdump
20 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/alert
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/stage
32 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/trace
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/incident
3260 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/metadata
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/ir
4 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G/incpkg
3356 /oracle/app/oracle/diag/rdbms/ora11g/ORA11G
3360 /oracle/app/oracle/diag/rdbms/ora11g
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/lck
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/metadata_pv
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/sweep
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/hm
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/metadata_dgif
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/cdump
44 /oracle/app/oracle/diag/rdbms/db11g/DB11G/alert
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/stage
76 /oracle/app/oracle/diag/rdbms/db11g/DB11G/trace
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/incident
3260 /oracle/app/oracle/diag/rdbms/db11g/DB11G/metadata
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/ir
4 /oracle/app/oracle/diag/rdbms/db11g/DB11G/incpkg
3424 /oracle/app/oracle/diag/rdbms/db11g/DB11G
3428 /oracle/app/oracle/diag/rdbms/db11g
6792 /oracle/app/oracle/diag/rdbms
--进程
[oracle@rac11g dbs]$ ps -ef|grep ora |grep-v grep
oracle 5154 1 0 10:01 ? 00:00:00 ora_pmon_ORA11G
oracle 5156 1 0 10:01 ? 00:00:00 ora_psp0_ORA11G
oracle 5158 1 1 10:01 ? 00:00:11 ora_vktm_ORA11G
oracle 5162 1 0 10:01 ? 00:00:00 ora_gen0_ORA11G
oracle 5164 1 0 10:01 ? 00:00:00 ora_diag_ORA11G
oracle 5166 1 0 10:01 ? 00:00:00 ora_dbrm_ORA11G
oracle 5168 1 0 10:01 ? 00:00:00 ora_dia0_ORA11G
oracle 5170 1 0 10:01 ? 00:00:00 ora_mman_ORA11G
oracle 5172 1 0 10:01 ? 00:00:00 ora_dbw0_ORA11G
oracle 5174 1 0 10:01 ? 00:00:00 ora_lgwr_ORA11G
oracle 5176 1 0 10:01 ? 00:00:00 ora_ckpt_ORA11G
oracle 5178 1 0 10:01 ? 00:00:00 ora_smon_ORA11G
oracle 5180 1 0 10:01 ? 00:00:00 ora_reco_ORA11G
oracle 5182 1 0 10:01 ? 00:00:00 ora_mmon_ORA11G
oracle 5184 1 0 10:01 ? 00:00:00 ora_mmnl_ORA11G
5.此时若想把数据库启动到mount,则直接报错,因为控制文件没指定
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying controlfile, check alert log for more info