环境CentOS 5.3+Oracle 10.2.0.1.0
1. 安装前的准备工作
1.1 创建oracle用户及组
# groupadd oinstall
# groupadd dba
# useradd -g oinstall -G dba oracle
# passwd oracle
1.2 建立目录
# mkdir /oracle
# chown -R oracle:oinstall /oracle
1.3 配置系统内核参数
cat >> /etc/sysctl.conf <
########oracle add########
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
########oracle add end########
EOF
#执行生效
sysctl -p
1.4 设置用户资源限制
a)
cat >> /etc/security/limits.conf <
####oracle add####
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
####oracle add end####
EOF
b)
cat >> /etc/pam.d/login <
####oracle add####
session required /lib/security/pam_limits.so
####oracle add end####
EOF
c)
cat >> /etc/profile <
####oracle add####
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
####oracle add end####
EOF
#############################################
注:c)步骤执行后,进入oracle用户的时候会报错
# su - oracle
-bash: ulimit: open files: cannot modify limit: 不允许的操作
造成此问题的原因是root用户设置了ulimit -n打开文件数的上限值为65535,oracle用户ulimit -n设置为65536后超过了root用户打开文件数的上限,
只要增大root用户对应的ulimit -n的上限值即可。
解决办法:
在执行c)步骤前,先在root用户下执行以下操作,增大root用户的ulimit -n值即可解决出现的问题:
echo "ulimit -n 65536 > /dev/null 2>&1">>/etc/profile
#############################################
1.5 安装依赖包
# rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXp make sysstat unixODBC unixODBC-devel|grep "not installed"|sort
package libaio-devel is not installed
package libXp is not installed
package sysstat is not installed
package unixODBC-devel is not installed
在redhat 5.3的光盘里找到上述的rpm包,并安装
# rpm -ivh libaio-devel-0.3.106-3.2.i386.rpm
Preparing... ########################################### [100%]
1:libaio-devel ########################################### [100%]
# rpm -ivh libXp-1.0.0-8.1.el5.i386.rpm
Preparing... ########################################### [100%]
1:libXp ########################################### [100%]
# rpm -ivh sysstat-7.0.2-3.el5.i386.rpm
Preparing... ########################################### [100%]
1:sysstat ########################################### [100%]
# rpm -ivh unixODBC-devel-2.2.11-7.1.i386.rpm
Preparing... ########################################### [100%]
1:unixODBC-devel ########################################### [100%]
1.6 修改系统版本
修改后结果如下:
# cat /etc/redhat-release
CentOS release 4 (Final)
2. 安装数据库并手动建库
2.1 设置oracle环境变量
$ vi ~/.bash_profile
##增加如下内容:
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=ora10g
export NLS_LANG=AMERICAN_AMERICA.zhs16gbk
export PATH=${PATH}:$HOME/bin:$ORACLE_HOME/bin:/usr/bin:/bin:/sbin:/usr/sbin
使环境变量生效:
$ source ~/.bash_profile
2.2 编辑静默安装需要的应答文件
以enterprise.rsp为例
$ cat /opt/oracle10gsetup/database/response/enterprise.rsp |grep -v ^#|grep -v ^$ >/home/oracle/myinstalloraen.rsp
$ cat myinstalloraentest.rsp |grep "
"
ORACLE_HOME=
ORACLE_HOME_NAME=
s_nameForDBAGrp=
s_nameForOPERGrp=
n_configurationOption=
n_dbType=
s_globalDBName=
s_dbSid=
其中“Vaule Required”字样的属性值为必填;涉及到文件路径的,必须使用全路径;应该文件中的默认值不可以删除,且各属性项的顺序不可以改变。
修改后如下:
ORACLE_HOME=/oracle/product/10.2.0/db_1 ##Oracle家目录(oracle软件安装后所在的目录)
ORACLE_HOME_NAME=OraHome1 ##Oracle家目录名字
s_nameForDBAGrp=oinstall
s_nameForOPERGrp=oinstall
n_configurationOption=3 ##数据库安装的动作类型:1.安装并创建数据库 2.配置一个ASM实例 3.仅安装数据库软件
n_dbType=1 ##创建的数据库类型:1.通用目的的数据库 2.联机事务处理的数据库 3.用作数据仓库的数据库 4.高级配置
s_globalDBName=ora10g ##数据库的全局名
s_dbSid=ora10g ##数据库实例名
s_dbRetChar="ZHS16GBK" ##数据库字符集
2.3 然后执行安装:
$ ./runInstaller -silent -responseFile /home/oracle/myinstalloraen.rsp
最后以 root 权限运行脚本
/oracle/oraInventory/orainstRoot.sh
/oracle/product/10.2.0/db_1/root.sh
安装完成。
2.4 手动建库
2.4.1环境变量设置
环境变量已经在数据库安装阶段设置完毕,此处不需再次设置
2.4.2创建目录
$ mkdir -p admin/ora10g/adump
$ mkdir -p admin/ora10g/bdump
$ mkdir -p admin/ora10g/cdump
$ mkdir -p admin/ora10g/udump
$ mkdir -p oradata/ora10g/disk1
$ mkdir -p oradata/ora10g/disk2
$ mkdir -p oradata/ora10g/disk3
2.4.3生成密码文件
$ orapwd --help
Usage: orapwd file= password= entries= force=
where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA and force - whether to overwrite existing file (opt),
OPERs (opt),
There are no spaces around the equal-to (=) character.
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapwORA10G password=oracle entries=30
$ chmod u+s orapwORA10G
$ ll -tr
总计 36
-rw-r----- 1 oracle oinstall 8385 1998-09-11 init.ora
-rw-r----- 1 oracle oinstall 12920 2001-05-03 initdw.ora
-rwSr----- 1 oracle oinstall 5120 03-12 10:58 orapwORA10G
2.4.4生成pfile文件,并由pfile文件生成spfile
$ cd $ORACLE_HOME/dbs
$ cat init.ora |grep -v ^#|grep -v ^$ >initora10g.ora
$ vi initora10g.ora ##修改后如下
db_name=ora10g
db_files = 100 # SMALL
db_file_multiblock_read_count = 8 # SMALL
db_block_buffers = 100 # SMALL
shared_pool_size = 3500000 # SMALL
log_checkpoint_interval = 10000
processes = 200 # SMALL
parallel_max_servers = 5 # SMALL
log_buffer = 32768 # SMALL
max_dump_file_size = 10240 # limit trace file size to 5 Meg each
global_names = TRUE
control_files = (/oracle/oradata/ora10g/disk1/control01.ctl, /oracle/oradata/ora10g/disk2/control2.ctl,/oracle/oradata/ora10g/disk3/control03.ctl)
生成spfile文件
$ sqlplus "/as sysdba"
SQL> create spfile from pfile;
File created.
SQL> startup nomount;
ORA-00371: not enough shared pool memory, should be atleast 72265318 bytes
################################################################################
解决ORA-00371问题的办法如下(增大shared_pool_size值后,重新生成spfile):
#db_block_buffers = 100 # SMALL
shared_pool_size = 268435456 # SMALL
################################################################################
SQL> create spfile from pfile;
File created.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 348127232 bytes
Fixed Size 1219352 bytes
Variable Size 293602536 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
2.4.5执行建库脚本
在官方文档()
Books → Administrator's Guide → 2 Creating an Oracle Database → Manually
Creating an Oracle Database → Creating the Database → Step 7: Issue the CREATE DATABASE Statement
取得建库脚本:
CREATE DATABASE ora10g
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/oracle/oradata/ora10g/disk1/redo01.log') SIZE 100M,
GROUP 2 ('/oracle/oradata/ora10g/disk2/redo02.log') SIZE 100M,
GROUP 3 ('/oracle/oradata/ora10g/disk3/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/oracle/oradata/ora10g/disk1/system01.dbf' SIZE 500M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/oracle/oradata/ora10g/disk1/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/oracle/oradata/ora10g/disk1/users01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/oracle/oradata/ora10g/disk1/temp01.dbf'
SIZE 500M REUSE
UNDO TABLESPACE undotbs
DATAFILE '/oracle/oradata/ora10g/disk1/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
将其保存为createora10gdb.sql,然后执行
SQL> @/oracle/createora10gdb.sql
################################################################################
执行建库sql的时候,报以下错误:
CREATE DATABASE ora10g
*
ERROR at line 1:
ORA-30014: operation only supported in Automatic Undo Management mode
报错原因:UNDO未处于自动管理模式,该参数默认是MANUAL
SQL> set line 200;
SQL> show parameter undo_management;
NAME TYPE VALUE
------------------------------------ --------------- ------------------------------
undo_management string MANUAL
解决办法:将UNDO置为自动管理模式
SQL> alter system set undo_management=AUTO scope=spfile;
System altered.
再重新生成一下pfile
SQL> create pfile from spfile;
File created.
###############################################################################
重启数据库然后再查询:
SQL> show parameter undo_management;
NAME TYPE VALUE
------------------------------------ --------------- ------------------------------
undo_management string AUTO
再执行建库sql
SQL> @/oracle/createora10gdb.sql
CREATE DATABASE ora10g
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
##########################################################################################
查看alter日志报错如下:
Errors in file /oracle/admin/ora10g/udump/ora10g_ora_5969.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-02236: invalid file name
Tue Mar 12 18:50:20 2013
Errors in file /oracle/admin/ora10g/udump/ora10g_ora_5969.trc:
ORA-01501: CREATE DATABASE failed
ORA-01519: error while processing file '?/rdbms/admin/sql.bsq' near line 6262
ORA-00604: error occurred at recursive SQL level 1
ORA-02236: invalid file name
继续查看/oracle/admin/ora10g/udump/ora10g_ora_5969.trc内容如下:
*** 2013-03-12 18:50:20.428
ORA-00604: error occurred at recursive SQL level 1
ORA-02236: invalid file name
Offending statement at line 6262
CREATE TABLESPACE TBS_1 DATAFILE SEGMENT SPACE MANAGEMENT MANUAL
ORA-01501: CREATE DATABASE failed
ORA-01519: error while processing file '?/rdbms/admin/sql.bsq' near line 6262
ORA-00604: error occurred at recursive SQL level 1
ORA-02236: invalid file name
发现其中提到TBS_1这个表空间,回去查看建库sql的时候,里面有如下内容:
SYSAUX DATAFILE '/oracle/oradata/ora10g/disk1/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1
对比侯老师建库sql,发现SYSAUX的默认表空间为tbs_1,将此两行内容更改为如下内容:
SYSAUX DATAFILE '/oracle/oradata/ora10g/disk1/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/oracle/oradata/ora10g/disk1/users01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
##########################################################################################
第三次执行建库sql
$ rm -rf disk1/*
$ rm -rf disk2/*
$ rm -rf disk3/*
SQL> startup nomount;
SQL> @/oracle/createora10gdb.sql
Database created.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
建库成功。
2.4.6执行必须的sql脚本
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
2.4.7查看数据库版本
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
5 rows selected.
阅读(3486) | 评论(0) | 转发(1) |