分享一下今天在linux环境手工创建实例以及遇到的问题
环境:linux + Oracle 11g R1
注意:这篇文章是来描述手动建实例,而非安装oracle
网上教程太多,大多数都是一个命令来,一个命令去,这里我分享一段linux环境下实例脚本。
以及一些注释,按照这个来,你就清楚的了解了创建实例的流程,以及一些常见问题。
vi create_instance.sh
#!/bin/bash
#
# author:wangsitu
# Date : 2014-09-19
##########################################
## create_database.sh ##
##########################################
LOGFILE=/home/oracle/create_database.log
read -p "Please Enter OracleSID:" SID
# 设置环境变量 指定好相关目录 sh执行后,会让你输入一个实例名(SID)
export ORACLE_SID=$SID
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1
# 创建必要的目录 注意:我这边的oradata目录没有在oracle_home下面,就手动改了一下,后面的也一样
mkdir -p /oradata/$ORACLE_SID
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/{adump,dpdump,pfile}
# 创建相关初始化参数 #注意,memory_target=512M此处先保持512M,我开始设置的300M报错了说小了,大家根据环境来看吧<span style="font-family: Arial, Helvetica, sans-serif;"> </span>
touch $ORACLE_HOME/dbs/init$ORACLE_SID.ora
INITPAR=$ORACLE_HOME/dbs/init$ORACLE_SID.ora
echo "audit_file_dest='$ORACLE_BASE/admin/$ORACLE_SID/adump'" >> $INITPAR
echo "audit_trail='db'" >> $INITPAR
echo "compatible='11.2.0.0.0'" >> $INITPAR
echo "control_files='/oradata/$ORACLE_SID/control01.ctl'" >> $INITPAR
echo "db_block_size=8192" >> $INITPAR
echo "db_name='$ORACLE_SID'" >> $INITPAR
echo "diagnostic_dest='$ORACLE_BASE'" >> $INITPAR
echo "dispatchers='(PROTOCOL=TCP) (SERVICE=zftXDB)'" >> $INITPAR
echo "job_queue_processes=1000" >> $INITPAR
echo "memory_target=512M" >> $INITPAR
echo "open_cursors=300" >> $INITPAR
echo "processes=300" >> $INITPAR
echo "remote_login_passwordfile='EXCLUSIVE'" >> $INITPAR
echo "sessions=335" >> $INITPAR
echo "undo_tablespace='UNDOTBS1'" >> $INITPAR
# 创建数据库的脚本
touch /home/oracle/cr_db.sql
CR_DB=/home/oracle/cr_db.sql
echo "create database $ORACLE_SID" >> $CR_DB
echo " USER SYS IDENTIFIED BY oracle" >> $CR_DB
echo " USER SYSTEM IDENTIFIED BY oracle" >> $CR_DB
echo " LOGFILE GROUP 1 ('/oradata/$ORACLE_SID/redo01.log') SIZE 100M," >> $CR_DB
echo " GROUP 2 ('/oradata/$ORACLE_SID/redo02.log') SIZE 100M," >> $CR_DB
echo " GROUP 3 ('/oradata/$ORACLE_SID/redo03.log') SIZE 100M" >> $CR_DB
echo " MAXLOGFILES 5" >> $CR_DB
echo " MAXLOGMEMBERS 5" >> $CR_DB
echo " MAXLOGHISTORY 1" >> $CR_DB
echo " MAXDATAFILES 100" >> $CR_DB
echo " MAXINSTANCES 1" >> $CR_DB
echo " CHARACTER SET AL32UTF8" >> $CR_DB
echo " DATAFILE '/oradata/$ORACLE_SID/system01.dbf' SIZE 350M REUSE " >> $CR_DB
echo " AUTOEXTEND ON NEXT 10240K" >> $CR_DB
echo " EXTENT MANAGEMENT LOCAL" >> $CR_DB
echo " SYSAUX DATAFILE '/oradata/$ORACLE_SID/sysaux01.dbf' SIZE 325M REUSE" >> $CR_DB
echo " DEFAULT TEMPORARY TABLESPACE temp" >> $CR_DB
echo " TEMPFILE '/oradata/$ORACLE_SID/temp01.dbf'" >> $CR_DB
echo " SIZE 20M REUSE" >> $CR_DB
echo " UNDO TABLESPACE undotbs1" >> $CR_DB
echo " DATAFILE '/oradata/$ORACLE_SID/undotbs1.dbf'" >> $CR_DB
echo " SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;" >> $CR_DB
# 创建数据字典脚本 此处可能报 ORA-06553: PLS-213: package STANDARD not accessible,解决方案在文章后面
touch /home/oracle/cr_dict.sql
CR_DICT=/home/oracle/cr_dict.sql
echo "$ORACLE_HOME/rdbms/admin/catalog" >> $CR_DICT
echo "$ORACLE_HOME/rdbms/admin/catproc" >> $CR_DICT
echo "conn system/oracle" >> $CR_DICT
echo "$ORACLE_HOME/sqlplus/admin/pupbld" >> $CR_DICT
echo "conn / as sysdba" >> $CR_DICT
# 创建pfile
touch /home/oracle/cr_spfile.sql
CR_SPFILE=/home/oracle/cr_spfile.sql
echo "CREATE spfile FROM pfile;" >> $CR_SPFILE
# 创建用户表空间
touch /home/oracle/cr_users.sql
CR_USERS=/home/oracle/cr_spfile.sql
echo "CREATE TABLESPACE users" >> $CR_USERS
echo " DATAFILE '/oradata/$ORACLE_SID/user01.dbf' SIZE 100M" >> $CR_USERS
echo " AUTOEXTEND ON;" >> $CR_USERS
echo "ALTER DATABASE DEFAULT TABLESPACE users;" >> $CR_USERS
sleep 10
# Execute Script
sqlplus / as sysdba >> $LOGFILE 2>&1 << EOF
startup nomount
@$CR_DB
@$CR_DICT
@$CR_SPFILE
@$CR_USERS
EOF
# Script End
如果很快就执行完了,八成是有问题,记得看create_database.log
本人亲测,红色部分是我遇到的问题以及处理方法,若有什么其他问题,可以交流下。
关于: ORA-06553: PLS-213: package STANDARD not accessible
解决方案
sqlplus /nolog
SQL> connect / as sysdba
SQL> $ORACLE_HOME/rdbms/admin/catalog.sql
SQL> $ORACLE_HOME/rdbms/admin/catproc.sql
SQL> $ORACLE_HOME/rdbms/admin/catexp.sql
转载请附上原文链接:http://blog.csdn.net/wang_situ/article/details/39395469