1. 安装Linux AS4.52. 安装Oracle database 11g software3. Create database manually 3.1 Set environment variables [oracle@localhost ~]$ vi .bash_profile # .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
HOSTNAME=$(uname -n)
PS1='(${?})${LOGNAME}@${HOSTNAME}:${ORACLE_SID:-"NO_SID"}:${PWD}
$ '
PS2='> '
# Set Global variables
set -o vi
set VISUAL=vi
set EDITOR=vi
set PAGER=more
# Set local variables
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1
export ORACLE_SID=orcl
export JAVA_HOME=/usr/java5
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$JAVA_HOME/bin:$PATH:$HOME/bin
unset USERNAME
3.2 Create user and group by root # groupadd oinstall # groupadd dba # useradd -g oinstall -G dba oracle 3.3 Create directories $./create_directory.ksh -----create_directory.ksh-----
#!/bin/ksh
mkdir -p /data/oradata/orcl
mkdir -p /indx/oradata/orcl
mkdir -p /redo01/oradata/orcl
mkdir -p /redo02/oradata/orcl
mkdir -p /bakup/flash_recovery_area
mkdir -p /bakup/rman/orcl
mkdir -p /u01/app/oracle/admin/orcl
cd /u01/app/oracle/admin/orcl
mkdir adump pfile script. create utl
chown -R oracle:oinstall /data /indx /redo01 /redo02 /bakup /u01/app/admin
3.4 Create pfile and password file 3.4.1 create pfile $ cd /u01/app/oracle/admin/orcl/pfile $ vi initorcl.ora ##############################################################################
# Example INIT.ORA file
#
# This file is provided by Oracle Corporation to help you start by providing
# a starting point to customize your RDBMS installation for your site.
#
# NOTE: The values that are used in this file are only intended to be used
# as a starting point. You may want to adjust/tune those values to your
# specific hardware and needs. You may also consider using Database
# Configuration Assistant tool (DBCA) to create INIT file and to size your
# initial set of tablespaces based on the user input.
###############################################################################
# Change '
' to point to the oracle base (the one you specify at
# install time)
db_name='ORCL'
memory_target=350M
processes = 150
audit_file_dest='/u01/app/oracle/admin/orcl/adump'
utl_file_dir='/u01/app/oracle/admin/orcl/utl'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/bakup/flash_recovery_area'
db_recovery_file_dest_size=4G
diagnostic_dest='/u01/app/oracle'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS'
control_files = ('/data/oradata/orcl/control01.ctl', '/indx/oradata/orcl/control02.ctl')
compatible ='11.1.0'
nls_language=AMERICAN
nls_territory=AMERICA
job_queue_processes=5
$ ln -s initorcl.ora $ORACLE_HOME/dbs/initorcl.ora
3.4.2 Create password file
$ cd $ORACLE_HOME/dbs
$ orapwd file=/u01/app/oracle/product/11.1.0/db_1/dbs/orapworcl password=oracle entries=20
4. Create database script
$sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Sat Jul 11 10:58:31 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @create_database.sql
Database created.
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
$cat create_database.sql
spool create_db.log
STARTUP NOMOUNT pfile=$ORACLE_HOME/dbs/initorcl.ora
CREATE DATABASE "orcl"
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/data/oradata/orcl/system01.dbf'
SIZE 500M AUTOEXTEND ON NEXT 10M MAXSIZE 2000M
SYSAUX
DATAFILE '/data/oradata/orcl/sysaux01.dbf'
SIZE 500M AUTOEXTEND ON NEXT 10M MAXSIZE 2000M
LOGFILE
GROUP 1 ('/redo01/oradata/orcl/redo101.log','/redo02/oradata/orcl/redo102.log') SIZE 10M,
GROUP 2 ('/redo01/oradata/orcl/redo201.log','/redo02/oradata/orcl/redo202.log') SIZE 10M,
GROUP 3 ('/redo01/oradata/orcl/redo301.log','/redo02/oradata/orcl/redo302.log') SIZE 10M
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/data/oradata/orcl/temp01.dbf'
SIZE 100M EXTENT MANAGEMENT LOCAL UNIFORM. SIZE 1M
DEFAULT TABLESPACE users
DATAFILE '/data/oradata/orcl/users01.dbf'
SIZE 10M AUTOEXTEND ON NEXT 5M MAXSIZE 100M
UNDO TABLESPACE undotbs
DATAFILE '/data/oradata/orcl/undotbs01.dbf'
SIZE 100M AUTOEXTEND ON MAXSIZE UNLIMITED
;
exit
spool off
5. Create spfile
SQL> create spfile from pfile;
(0)oracle@liang:orcl:/u01/app/oracle/product/11.1.0/db_1/dbs
$ ls
hc_orcl.dat initdw.ora init.ora initorcl.ora lkORCL orapworcl spfileorcl.ora
6. Enable archivelog and flashback features
SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /bakup/flash_recovery_area
db_recovery_file_dest_size big integer 4G
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence 3
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database flashback on;
SQL> alter database open;
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 3
Current log sequence 3
SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /bakup/flash_recovery_area
db_recovery_file_dest_size big integer 4G
SQL> show parameter db_flashback_retention_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flashback_retention_target integer 1440
7. Create additional tablespace
SQL> create tablespace app_tbs
datafile '/data/oradata/orcl/app_tbs01.dbf' SIZE 10M
AUTOEXTEND ON NEXT 5M MAXSIZE 100M
EXTENT MANAGEMENT LOCAL;
SQL> create tablespace indx_tbs
datafile '/indx/oradata/orcl/indx_tbs01.dbf' SIZE 10M
AUTOEXTEND ON NEXT 5M MAXSIZE 100M
EXTENT MANAGEMENT LOCAL;
8. Run Scripts to build dictionary views
RUN catalog.sql and catproc.sql by sys user
SQL> @$ORACLE_HOME/rdbms/admin/catalog.sql
SQL> @$ORACLE_HOME/rdbms/admin/catproc.sql
Run pupbld.sql by system user
SQL> @$ORACLE_HOME/sqlplus/admin/pupbld.sql
Done.
Snap1.jpg
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9466564/viewspace-608884/
,如需转载,请注明出处,否则将追究法律责任。