Install oracle for centos5.9(安装文档)
文档目录
一、系统安装oracle需求
二、开机自动启动数据库
三、维护脚本(个人维护脚本,不适应大多数用户)
四、解决10.2.0.1一些基本应用BUG问题
系统硬件配置 PowerEdge R720
硬件 |
型号 |
大小 |
处理器 |
E5-2609 (2.40GHz,10M 缓存, 6.4GT/s QPI, 无Turbo, 4C, 80W) |
4C*2=8C |
内存 |
4GB RDIMM, 1600 MHz, 标准电压, 双列, x8 带宽 |
4*8=32G |
硬盘 |
600GB 3.5英寸15K RPM 6Gbps SAS热插拔硬盘 |
600*4=2.4T Raid10可用磁盘1.2T |
主板 |
PowerEdge R720 NTPM |
|
操作系统:centos5.9 64bit
Oracle: 10.2.0.1
一、系统安装oracle需求
1、 RAM与swap规划
RAM |
Swap Space |
Between 1024 MB and 2048 MB |
1.5 times the size of RAM |
Between 2049 MB and 8192 MB |
Equal to the size of RAM |
More than 8192 MB |
0.75 times the size of RAM |
2、 系统软件包支持
for i in binutils compat-gcc-34 compat-libstdc++-296 control-center \
gcc gcc-c++ glibc glibc-common glibc-devel libaio libgcc \
libstdc++ libstdc++-devel libXp make openmotif22 setarch
do
rpm -q $i &>/dev/null || F="$F $i"
done ;echo $F;unset F
3、 系统版本环境修改(10g 支持 redhat 4,所以修改一下版本骗过检验)
vi /ect/redhat-release
4、 建立用户,环境变量,目录,DNS解析(私人维护目录)
groupadd -g 1000 oinstall
groupadd -g 1001 dba
useradd -u 1000 oracle -g oinstall -G dba
passwd oracle
mkdir -p /u01/oracle
chown oracle:oinstall /u01/oracle
设置oracle环境变量
vi .bash_profile
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=doudou
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
添加/etc/hosts中dns解析信息
192.168.1.241 doudou
个人维护目录
/u01/oracle/
/rman/archivelog
/rman/backup
/rman/backup/arch
/rman/backup/data
/home/oracle/log
/home/oracle/scripts
5、 操作系统资源限制(sysctl –p 加载参数立刻生效,32G)
vi /etc/sysctl.conf 文件底端
kernel.shmall =8388608
kernel.shmmax =17179869184
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
*********************************************************************
kernel.shmall = 8388608
kernel.shmmax = 17179869184
kernel.shmall为物理内存除以pagesize; --获取pagesize:getconf PAGESIZE
kernel.shmmax为物理内存的一半;
*********************************************************************
6、shell限制
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
vi /etc/pam.d/system-auth
session required pam_limits.so
7、使用xmanger映射出图形界面
export DISPLAY=192.168.1.15:0.0
xclock 出现图表图样说明xmanger配置成功
[oracle@gaokao ~]$ xclock
export LANG=C
8、安装oracle镜像加压及oracle软件安装
10201_database_linux_x86_64.iso
mount –o loop 10201_database_linux_x86_64.iso /guazai
cp /guazai/10201_database_linux_x86_64.cpio.gz /u01/oracle
10201_database_linux_x86_64.cpio.gz解压
gunzip10201_database_linux_x86_64.cpio.gz
cpio -idmv <10201_database_linux_x86_64.cpio
[oracle@dyora ~]$ /u01/oracle/database/runInstaller -ignoreSysPreReqs
9、安装过程中出现错误
error in invoking target 'ntcontab.o' of makefile
解决:
没有满足系统软件包支持,安装所需软件包问题解决
二、开机自动启动数据库
1、 修改 /etc/oratab
doudou:/opt/oracle/product/10.2.0:Y
2、修改$ORACLE_HOME/bin/dbstart脚本中的一处错误
将ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle修改成ORACLE_HOME_LISTNER=$ORACLE_HOME
3、 创建database脚本
vi /etc/rc.d/init.d/database
#!/bin/bash
# chkconfig: 35 85 90
# description: Oracle auto start-stop script.
# AUTH:seker
. /etc/init.d/functions
start(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"cannot start database: database is already running."
failure $"cannot start database: database is already running."
echo
exit 1
else
echo -n $"Starting Database: "
daemon su - $ORA_OWNER -c "dbstart" && touch /var/lock/subsys/`basename $0`
echo
fi
}
stop(){
if ps aux | grep ora_ | grep -v grep &>/dev/null
then
echo -n $"Stoping Database: "
daemon su - $ORA_OWNER -c "dbshut" && rm -f /var/lock/subsys/`basename $0`
echo
else
echo -n $"cannot stop database:Database is not already running."
failure $"cannot stop database:Database is not already running."
echo
exit 1
fi
}
ORA_OWNER=oracle
case "$1" in
start)
start
;;
stop)
stop
;;
emstart)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && echo "OEM is already running" || emctl start dbconsole'
;;
emstop)
su - $ORA_OWNER -c 'emctl status dbconsole &>/dev/null && emctl stop dbconsole || echo "OEM is not running"'
;;
isqlstart)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null || isqlplusctl start'
;;
isqlstop)
su - $ORA_OWNER -c 'ps aux | grep 'isqlplus/config/server.xml' | grep -v grep &>/dev/null && isqlplusctl stop || echo "isqlplus is not running"'
;;
lsnstart)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && echo "listen is already running" || lsnrctl start &>/dev/null'
;;
lsnstop)
su - $ORA_OWNER -c 'lsnrctl status &>/dev/null && lsnrctl stop &>/dev/null || echo "lsnrctl is not already running"'
;;
*)
echo "USAGE: $0 {start|stop|lsnstart|lsnstop|emstart|emstop|isqlstart|isqlstop}"
echo -e "\tstart : database start"
echo -e "\tstop : database stop"
echo -e "\tlsnstart : listen start"
echo -e "\tlsnstop : listen stop"
echo -e "\temstart : OEM start"
echo -e "\temstop : OEM stop"
echo -e "\tisqlstart : isqlplus start"
echo -e "\tisqlstop : isqlplus stop"
esac
4、 修改执行权限chmod 755 ora
chmod 755/etc/rc.d/init.d/database
5、 修改chkconfig database on 开机自动启动
chkconfig --add database
chkconfig --list database
chkconfig database on
6、使用service是否可以开启,关闭数据库
service database start
service database stop
7、reboot
OK,开机自动启动数据库了
三、维护脚本
[oracle@neworadb ~]$ crontab -l
0 4 * * 0 sh /home/oracle/scripts/orcl_backup_level0.sh
0 4 * * 3,5 sh /home/oracle/scripts/orcl_backup_level1.sh
0 4 * * 1,2,4,6 sh /home/oracle/scripts/orcl_backup_level2.sh
0 3 * * 2,4,6 sh /home/oracle/scripts/delete_rman_db.sh
30 4 * * * sh /home/oracle/scripts/orcl_rman_db_validate.sh
0 5 * * * sh /home/oracle/scripts/alert_orcl.log.sh
2 5 * * * sh /home/oracle/scripts/orcl_tablespace.sh
20 5 * * * sh /home/oracle/scripts/alert.log.sh
10 10 * * * sh /home/oracle/scripts/delete_alert.log.sh
vi orcl_backup_level0.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
rman target / nocatalog log=/home/oracle/log/rman_db_level0.log <<EOF
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
backup as compressed backupset incremental level 0 database filesperset 4 format
'/rman/backup/data/level0_%d_%s_%p_%u_%T.bak' include current controlfile;
sql 'alter system archive log current';
backup archivelog all filesperset 10 format '/rman/backup/arch/arc_%d_%s_%p_%u_%T.bak';
release channel d1;
release channel d2;
release channel d3;
crosscheck backup;
}
exit
EOF
vi orcl_backup_level1.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
rman target / nocatalog log=/home/oracle/log/rman_db_level1.log <<EOF
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
backup as compressed backupset incremental level 1 database filesperset 4 format
'/rman/backup/data/level1_%d_%s_%p_%u_%T.bak' include current controlfile;
sql 'alter system archive log current';
backup archivelog all filesperset 10 format '/rman/backup/arch/arc_%d_%s_%p_%u_%T.bak';
release channel d1;
release channel d2;
release channel d3;
crosscheck backup;
}
exit
EOF
vi orcl_backup_level2.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
rman target / nocatalog log=/home/oracle/log/rman_db_level2.log <<EOF
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
backup as compressed backupset incremental level 2 database filesperset 4 format
'/rman/backup/data/level2_%d_%s_%p_%u_%T.bak' include current controlfile;
sql 'alter system archive log current';
backup archivelog all filesperset 10 format '/rman/backup/arch/arc_%d_%s_%p_%u_%T.bak';
release channel d1;
release channel d2;
release channel d3;
crosscheck backup;
}
exit
EOF
vi delete_rman_db.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
rman target / nocatalog log=/home/oracle/log/delete_orcl.log <<EOF
run {
crosscheck backup;
delete noprompt expired backup ;
delete noprompt obsolete;}
exit
EOF
vi orcl_rman_db_validate.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
rman target / nocatalog log=/home/oracle/log/orcl_rman_db_validate.log <<EOF
restore validate controlfile;
restore validate database;
exit
EOF
vi alert_orcl.log.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
cd $ORACLE_BASE/admin/orcl/bdump
if [ -f alert_orcl.log ]
then
tail -60 alert_orcl.log >>alert_dba.log
grep ORA- alert_dba.log >>alert_err.log
mv alert_dba.log /home/oracle/log/orcl_alert_dba.log
mv alert_err.log /home/oracle/log/orcl_alert_err.log
fi
vi orcl_tablespace.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
cd /home/oracle/log
sqlplus -s '/ as sysdba' <<EOF
set feed off
set linesize 100
set pagesize 200
column "USED (MB)" format a10
column "FREE (MB)" format a10
column "TOTAL (MB)" format a10
column PER_FREE format a10
column TABLESPACE_NAME format a25
spool orcl_tablespace.alert
SELECT F.TABLESPACE_NAME,
TO_CHAR ((T.TOTAL_SPACE - F.FREE_SPACE),'999,999') "USED (MB)",
TO_CHAR (F.FREE_SPACE, '999,999') "FREE (MB)",
TO_CHAR (T.TOTAL_SPACE, '999,999') "TOTAL (MB)",
TO_CHAR ((ROUND ((F.FREE_SPACE/T.TOTAL_SPACE)*100)),'999')||' %' PER_FREE
FROM (
SELECT TABLESPACE_NAME,
ROUND (SUM (BLOCKS*(SELECT VALUE/1024
FROM V\$PARAMETER
WHERE NAME = 'db_block_size')/1024)
) FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME
) F,
(
SELECT TABLESPACE_NAME,
ROUND (SUM (BYTES/1048576)) TOTAL_SPACE
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME
) T
WHERE F.TABLESPACE_NAME = T.TABLESPACE_NAME
AND (ROUND ((F.FREE_SPACE/T.TOTAL_SPACE)*100)) < 20;
spool off
exit
EOF
vi alert.log.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
cd /home/oracle/log
hostname >> alert.log
export ORACLE_SID=orcl
echo $ORACLE_SID>>alert.log
cat orcl_alert_err.log>> alert.log
date >> alert.log
export orcl_tablespace=orcl____tablespace
echo $orcl_tablespace>>alert.log
cat orcl_tablespace.alert >> alert.log
grep Finished backup at /home/oracle/log/rman_db_level0.log >> alert.log
grep Finished backup at /home/oracle/log/rman_db_level1.log >> alert.log
grep Finished backup at /home/oracle/log/rman_db_level2.log >> alert.log
ls -l /home/oracle/log >> alert.log
df -h >> alert.log
du -ms /rman >> alert.log
du -ms /rman/archivelog >> alert.log
grep Finished /home/oracle/log/orcl_rman_db_validate.log >> alert.log
vi delete_alert.log.sh
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
cd /home/oracle/log/
rm -rf alert.log
四、解决10.2.0.1一些基本应用BUG问题
1、 添加日志(INACTIVE状态的才可以删除)
alter database drop logfile ‘/u01/oracle/oradata/doudou/redo01.log’;
alter database add logfile group 1 ‘/u01/oracle/oradata/doudou/redo01.log’ size 200m reuse;
2、添加隐含参数来解决Heap size 2294K exceeds notification threshold (2048K)
alter system set "_kgl_large_heap_warning_threshold"=8388608 scope=spfile ;
3、打补丁patch 4612267 ,来解决sqlplus没有反应问题
3-1:安装补丁
a)关闭监听,dbconsole,数据库
lsnrctl stop
emctl stop dbconsole
shutdown immediate
b)安装patch
mkdir $ORACLE_BASE/patches
cp p4612267_10201_Linux-x86-64.zip $ORACLE_BASE/patches
unzip p4612267_10201_Linux-x86-64.zip
cd 4612267/
$ORACLE_HOME/OPatch/opatch apply
c)验证patch
$ORACLE_HOME/OPatch/opatch lsinventory
d)开启数据库,dbconsole,监听
startup
emctl start dbconsole
lsnrctl start
3-2:卸载补丁
a)关闭监听,dbconsole,数据库
lsnrctl stop
emctl stop dbconsole
shutdown immediate
b)删除patch
cd $ORACLE_BASE/patches/4612267
$ORACLE_HOME/OPatch/opatch rollback -id 4612267
c)验证patch
$ORACLE_HOME/OPatch/opatch lsinventory
d)开启数据库,dbconsole,监听
startup
emctl start dbconsole
lsnrctl start