奇数机 主机名:ocm1 ORACLE_SID=PROD IP:192.168.1.161 oracle用户:密码是oracle root用户:密码是123456 偶数机 主机名:ocm2 ORACLE_SID=EMREP和SBDB IP:192.168.1.162 oracle用户:密码oracle root用户:密码123456 操作系统版本:Enterprise-R5-U4-Ser
奇数机
主机名:ocm1 ORACLE_SID=PROD IP:192.168.1.161 oracle用户:密码是oracle root用户:密码是123456
偶数机 主机名:ocm2 ORACLE_SID=EMREP和SBDB IP:192.168.1.162 oracle用户:密码oracle root用户:密码123456
操作系统版本:Enterprise-R5-U4-Server-i386-dvd 数据库版本:10.2.0.2.0 gridcontrol版本:10.2.0.1.1
Section 0 :创建数据库(即手动建库) 1. Create a database the sid name is PROD 2. Don't run the Script catalog.sql and catproc.sql
参考联机文档: Reference ==> Basic Initialization Parameters http://docs.oracle.com/cd/B19306_01/server.102/b14237/initparams002.htm#CJAJHDED
Administrator's Guide ==> Step 7: Issue the CREATE DATABASE Statement http://docs.oracle.com/cd/B19306_01/server.102/b14231/create.htm#sthref242
[oracle@ocm1 ~]$ hostname ocm1 [oracle@ocm1 ~]$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.4 (Tikanga) [oracle@ocm1 ~]$ /sbin/ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:23:43:C3 inet addr:192.168.1.161 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe23:43c3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:315 errors:0 dropped:0 overruns:0 frame:0 TX packets:151 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:29390 (28.7 KiB) TX bytes:19900 (19.4 KiB) Memory:f0000000-f0020000
lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1504 errors:0 dropped:0 overruns:0 frame:0 TX packets:1504 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4332028 (4.1 MiB) TX bytes:4332028 (4.1 MiB)
[oracle@ocm1 ~]$
考试时可用sudo来继承root用户权限做管理员操作
准备工作:
1.查看oracle环境变量。
[oracle@ocm1 ~]$ cat .bash_profile # .bash_profile
# Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
# User specific environment and startup programs
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export PATH=$ORACLE_HOME/bin:$PATH PATH=$PATH:$HOME/bin
export PATH [oracle@ocm1 ~]$
2.设置一下sqlplus命令提示符。
[oracle@ocm1 ~]$ vi /u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/glogin.sql -- -- Copyright (c) 1988, 2004, Oracle Corporation. All Rights Reserved. -- -- NAME -- glogin.sql -- -- DESCRIPTION -- SQL*Plus global login "site profile" file -- -- Add any SQL*Plus commands here that are to be executed when a -- user starts SQL*Plus, or uses the SQL*Plus CONNECT command -- -- USAGE -- This script is automatically run --
-- Used by Trusted Oracle COLUMN ROWLABEL FORMAT A15
-- Used for the SHOW ERRORS command COLUMN LINE/COL FORMAT A8 COLUMN ERROR FORMAT A65 WORD_WRAPPED
-- Used for the SHOW SGA command COLUMN name_col_plus_show_sga FORMAT a24 COLUMN units_col_plus_show_sga FORMAT a15 -- Defaults for SHOW PARAMETERS COLUMN name_col_plus_show_param FORMAT a36 HEADING NAME COLUMN value_col_plus_show_param FORMAT a30 HEADING VALUE
-- Defaults for SHOW RECYCLEBIN COLUMN origname_plus_show_recyc FORMAT a16 HEADING 'ORIGINAL NAME' COLUMN objectname_plus_show_recyc FORMAT a30 HEADING 'RECYCLEBIN NAME' COLUMN objtype_plus_show_recyc FORMAT a12 HEADING 'OBJECT TYPE' COLUMN droptime_plus_show_recyc FORMAT a19 HEADING 'DROP TIME'
-- Defaults for SET AUTOTRACE EXPLAIN report -- These column definitions are only used when SQL*Plus -- is connected to Oracle 9.2 or earlier. COLUMN id_plus_exp FORMAT 990 HEADING i COLUMN parent_id_plus_exp FORMAT 990 HEADING p COLUMN plan_plus_exp FORMAT a60 COLUMN object_node_plus_exp FORMAT a8 COLUMN other_tag_plus_exp FORMAT a29 COLUMN other_plus_exp FORMAT a44
-- Default for XQUERY COLUMN result_plus_xquery HEADING 'Result Sequence'
set sqlprompt"_user'@'_connect_identifier>" "/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/glogin.sql" 49L, 1569C written
3.查看是否有user和连接的标识符。
[oracle@ocm1 ~]$ export ORACLE_SID=PROD [oracle@ocm1 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.2.0 - Production on Mon Apr 14 08:23:03 2014
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
@>conn /as sysdba Connected to an idle instance. SYS@PROD>
#################################################################################################################### ORA-12162: TNS:net service name is incorrectly specified -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[oracle@ocm1 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.2.0 - Production on Mon Apr 14 08:21:30 2014
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
@>conn /as sysdba ERROR: ORA-12162: TNS:net service name is incorrectly specified
指定ORACLE_SID=PROD即可 ####################################################################################################################
手动建库步骤:
1.创建密码文件
[oracle@ocm1 ~]$ cd /u01/app/oracle/product/10.2.0/db_1/dbs/ [oracle@ocm1 dbs]$ ll total 28 -rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora -rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora [oracle@ocm1 dbs]$
orapwd file=orapwPROD password=oracle entries=30 [oracle@ocm1 dbs]$ ll total 36 -rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora -rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora -rw-r----- 1 oracle oinstall 5120 Apr 14 08:26 orapwPROD [oracle@ocm1 dbs]$
2.创建相关目录
[oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/admin/PROD/adump [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/admin/PROD/bdump [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/admin/PROD/cdump [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/admin/PROD/udump [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/oradata/PROD/Disk1 [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/oradata/PROD/Disk2/arch [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/oradata/PROD/Disk3 [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/oradata/PROD/Disk4 [oracle@ocm1 dbs]$ mkdir -p $ORACLE_BASE/oradata/PROD/Disk5 [oracle@ocm1 dbs]$
3.创建pfile参数文件
[oracle@ocm1 dbs]$ pwd /u01/app/oracle/product/10.2.0/db_1/dbs [oracle@ocm1 dbs]$
vi initPROD.ora
CONTROL_FILES=('/u01/app/oracle/oradata/PROD/Disk1/control01.ctl','/u01/app/oracle/oradata/PROD/Disk2/control02.ctl','/u01/app/oracle/oradata/PROD/Disk3/control03.ctl') DB_BLOCK_SIZE=8192 DB_CREATE_FILE_DEST=/u01/app/oracle/oradata/PROD/Disk1 DB_CREATE_ONLINE_LOG_DEST_1=/u01/app/oracle/oradata/PROD/Disk1 DB_NAME=PROD JOB_QUEUE_PROCESSES=10 LOG_ARCHIVE_DEST_1='location=/u01/app/oracle/oradata/PROD/Disk2/arch' PROCESSES=200 SGA_TARGET=500M BACKGROUND_DUMP_DEST=/u01/app/oracle/admin/PROD/bdump CORE_DUMP_DEST=/u01/app/oracle/admin/PROD/cdump USER_DUMP_DEST=/u01/app/oracle/admin/PROD/udump UNDO_MANAGEMENT=auto UNDO_TABLESPACE=undotbs1 UNDO_RETENTION=5400 ~ ~ ~ ~ ~ ~ ~ ~ "initPROD.ora" [New] 16L, 659C written [oracle@ocm1 dbs]$
4.使用pfile生成spfile。
[oracle@ocm1 dbs]$ export ORACLE_SID=PROD [oracle@ocm1 dbs]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.2.0 - Production on Mon Apr 14 08:33:48 2014
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
@>conn /as sysdba Connected to an idle instance. SYS@PROD>create spfile from pfile;
File created.
SYS@PROD
5.然后启动到nomount,再查看是否以spfile启动的。
SYS@PROD>startup nomount ORACLE instance started.
Total System Global Area 524288000 bytes Fixed Size 1261788 bytes Variable Size 146804516 bytes Database Buffers 373293056 bytes Redo Buffers 2928640 bytes
SYS@PROD>show parameter spfile
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ spfile string /u01/app/oracle/product/10.2.0 /db_1/dbs/spfilePROD.ora
SYS@PROD>show parameter dest
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ audit_file_dest string /u01/app/oracle/admin/PROD/adump background_dump_dest string /u01/app/oracle/admin/PROD/bdump core_dump_dest string /u01/app/oracle/admin/PROD/cdump db_create_file_dest string /u01/app/oracle/oradata/PROD/Disk1 db_create_online_log_dest_1 string /u01/app/oracle/oradata/PROD/Disk1 ... user_dump_dest string /u01/app/oracle/admin/PROD/udump
6,创建数据库脚本。
[oracle@ocm1 ~]$ pwd /home/oracle [oracle@ocm1 ~]$ vi create_database.sql
CREATE DATABASE PROD USER SYS IDENTIFIED BY oracle USER SYSTEM IDENTIFIED BY oracle LOGFILE GROUP 1 ('/u01/app/oracle/oradata/PROD/Disk1/redo01.log') SIZE 100M, GROUP 2 ('/u01/app/oracle/oradata/PROD/Disk1/redo02.log') SIZE 100M, GROUP 3 ('/u01/app/oracle/oradata/PROD/Disk1/redo03.log') SIZE 100M MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 MAXDATAFILES 100 MAXINSTANCES 1 CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf' SIZE 325M REUSE DEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE '/u01/app/oracle/oradata/PROD/Disk1/temp01.dbf' SIZE 20M REUSE UNDO TABLESPACE undotbs1 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
[oracle@ocm1 ~]$ ll total 4 -rw-r--r-- 1 oracle oinstall 885 Apr 14 08:44 create_database.sql
7.在nomount阶段运行脚本,创建数据库。
SYS@PROD>@/home/oracle/create_database
Database created.
8.创建数据库时,可以查看相关的告警日志。
[oracle@ocm1 bdump]$ tail -f alert_PROD.log
Mon Apr 14 20:43:36 2014 CREATE DATABASE PROD USER SYS IDENTIFIED BY *USER SYSTEM IDENTIFIED BY *LOGFILE GROUP 1 ('/u01/app/oracle/oradata/PROD/Disk1/redo01.log') SIZE 100M, GROUP 2 ('/u01/app/oracle/oradata/PROD/Disk1/redo02.log') SIZE 100M, GROUP 3 ('/u01/app/oracle/oradata/PROD/Disk1/redo03.log') SIZE 100M MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 MAXDATAFILES 100 MAXINSTANCES 1 CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf' SIZE 325M REUSE DEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE '/u01/app/oracle/oradata/PROD/Disk1/temp01.dbf' SIZE 20M REUSE UNDO TABLESPACE undotbs1 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED Mon Apr 14 20:43:38 2014 Database mounted in Exclusive Mode Mon Apr 14 20:45:36 2014 Successful mount of redo thread 1, with mount id 256759032 Assigning activation ID 256759032 (0xf4dd4f8) Thread 1 opened at log sequence 1 Current log# 1 seq# 1 mem# 0: /u01/app/oracle/oradata/PROD/Disk1/redo01.log Successful open of redo thread 1 Mon Apr 14 20:45:37 2014 MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set Mon Apr 14 20:45:37 2014 SMON: enabling cache recovery Mon Apr 14 20:45:37 2014 create tablespace SYSTEM datafile '/u01/app/oracle/oradata/PROD/Disk1/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL online Mon Apr 14 20:45:47 2014 Completed: create tablespace SYSTEM datafile '/u01/app/oracle/oradata/PROD/Disk1/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL online Mon Apr 14 20:45:47 2014 create rollback segment SYSTEM tablespace SYSTEM storage (initial 50K next 50K) Completed: create rollback segment SYSTEM tablespace SYSTEM storage (initial 50K next 50K) Mon Apr 14 20:46:02 2014 CREATE UNDO TABLESPACE UNDOTBS1 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED Mon Apr 14 20:46:07 2014 Successfully onlined Undo Tablespace 1. Completed: CREATE UNDO TABLESPACE UNDOTBS1 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED Mon Apr 14 20:46:07 2014 create tablespace SYSAUX datafile '/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online Mon Apr 14 20:46:20 2014 Completed: create tablespace SYSAUX datafile '/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO online Mon Apr 14 20:46:21 2014 CREATE TEMPORARY TABLESPACE TEMPTS1 TEMPFILE '/u01/app/oracle/oradata/PROD/Disk1/temp01.dbf' SIZE 20M REUSE
Completed: CREATE TEMPORARY TABLESPACE TEMPTS1 TEMPFILE '/u01/app/oracle/oradata/PROD/Disk1/temp01.dbf' SIZE 20M REUSE Mon Apr 14 20:46:21 2014 ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPTS1 Completed: ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMPTS1 Mon Apr 14 20:46:21 2014 ALTER DATABASE DEFAULT TABLESPACE SYSTEM Completed: ALTER DATABASE DEFAULT TABLESPACE SYSTEM Mon Apr 14 20:46:26 2014 SMON: enabling tx recovery Mon Apr 14 20:46:31 2014 Threshold validation cannot be done before catproc is loaded. replication_dependency_tracking turned off (no async multimaster replication found) Starting background process QMNC QMNC started with pid=14, OS id=2495 Mon Apr 14 20:46:32 2014 Completed: CREATE DATABASE PROD USER SYS IDENTIFIED BY *USER SYSTEM IDENTIFIED BY *LOGFILE GROUP 1 ('/u01/app/oracle/oradata/PROD/Disk1/redo01.log') SIZE 100M, GROUP 2 ('/u01/app/oracle/oradata/PROD/Disk1/redo02.log') SIZE 100M, GROUP 3 ('/u01/app/oracle/oradata/PROD/Disk1/redo03.log') SIZE 100M MAXLOGFILES 5 MAXLOGMEMBERS 5 MAXLOGHISTORY 1 MAXDATAFILES 100 MAXINSTANCES 1 CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/system01.dbf' SIZE 325M REUSE EXTENT MANAGEMENT LOCAL SYSAUX DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/sysaux01.dbf' SIZE 325M REUSE DEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE '/u01/app/oracle/oradata/PROD/Disk1/temp01.dbf' SIZE 20M REUSE UNDO TABLESPACE undotbs1 DATAFILE '/u01/app/oracle/oradata/PROD/Disk1/undotbs01.dbf' SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED