今天要重新建一个Oracle数据库,本想直接在先前的虚拟机上直建。后忽然想到Oracle的安装完全不记得了,于是想重温一下,顺便记录下操作步骤,方便以后快速安装。
  首先上传10201_database_linux32.zip到Linux上。以下为正式安装步骤:
 

1.           创建tmp

mkdir /DBServer/temp
chmod 777 /DBServer/temp

2.           创建用户

su -
/usr/sbin/groupadd -g 200 oinstall
/usr/sbin/groupadd -g 201 dba
/usr/sbin/groupadd -g 202 oper
/usr/sbin/useradd -u 203 -g oinstall -G dba,oper oracle
echo oracle|passwd --stdin oracle

3.           用户配置文件

a)         root
su -
cd
echo 'export ORACLE_SID=orcl' >> .bashrc
echo 'export ORACLE_BASE=/DBServer/app/oracle' >> .bashrc
echo 'export ORACLE_HOME=$ORACLE_BASE/product/10.2.0' >> .bashrc
echo 'export TEMP=/DBServer/temp' >> .bash_profile
echo 'export TMPDIR=$TEMP' >> .bash_profile
echo 'export NLS_LANG="SIMPLIFIED CHINESE_CHINA.UTF8"' >> .bash_profile
echo 'export LANG=en_US.UTF-8' >> .bash_profile
source .bash_profile
b)        oracle
su -
su oracle
cd ~oracle
echo export ORACLE_BASE=$ORACLE_BASE >> .bash_profile
echo export ORACLE_HOME=$ORACLE_HOME >> .bash_profile
echo export ORACLE_SID=${ORACLE_SID} >> .bash_profile
echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> .bash_profile
echo 'unset TNS_ADMIN' >>.bash_profile
echo umask 022 >> .bash_profile
echo unset LANG >> .bash_profile
echo export TMP=$TMPDIR >> .bash_profile
echo export TMPDIR=$TMPDIR >> .bash_profile
exit

4.           配置系统参数

c)         /etc/sysctl.conf file
su -
echo 'kernel.shmall = 2097152' >> /etc/sysctl.conf
 
# 8G RAM
#echo kernel.shmmax=4294967295>> /etc/sysctl.conf
echo 'kernel.shmmax = 2147483648' >> /etc/sysctl.conf
 
echo 'kernel.shmmni = 4096' >> /etc/sysctl.conf
echo 'kernel.semopm=100' >> /etc/sysctl.conf
echo 'kernel.sem = 250 32000 100 128' >> /etc/sysctl.conf
echo 'fs.file-max = 65536' >> /etc/sysctl.conf
echo 'net.ipv4.ip_local_port_range = 1024 65000' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_sack=0' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_timestamps=0' >> /etc/sysctl.conf
echo 'net.core.rmem_default = 1048576' >> /etc/sysctl.conf
echo 'net.core.rmem_max = 1048576' >> /etc/sysctl.conf
echo 'net.core.wmem_default = 262144' >> /etc/sysctl.conf
echo 'net.core.wmem_max = 262144' >> /etc/sysctl.conf
d)        /etc/security/limits.conf
echo 'oracle soft nproc 2047' >> /etc/security/limits.conf
echo 'oracle hard nproc 16384' >> /etc/security/limits.conf
echo 'oracle soft nofile 1024' >> /etc/security/limits.conf
echo 'oracle hard nofile 65536' >> /etc/security/limits.conf
e)          vi /etc/pam.d/login
vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
f)          vi /etc/profile
vi /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi

5.           目录

su -
mkdir -p $ORACLE_BASE
chown -R oracle:oinstall $ORACLE_BASE
chmod -R 775 $ORACLE_BASE
 
cd /install
unzip 10201_database_linux32.zip

6.           reboot

7.           安装(GUI

oracle登录GUI
cd /install/database
./runInstaller &
安装时请选择高级安装模式,以选择中文字符集ZHS16GBK

8.           自动启动

vi /etc/oratab
        Change the last field for each to Y.
vi /etc/init.d/dbora
ORA_HOME=/u01/app/oracle/product/10.2.0
ORA_OWNER=oracle
 
case "$1" in
'start')
su - $ORA_OWNER -c "lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
;;
'stop')
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "lsnrctl stop"
;;
esac
chmod 755 /etc/init.d/dbora
 
vi /bin/dbstart
/etc/init.d/dbora start
vi /bin/dbstop
/etc/init.d/dbora stop
chmod 755 /bin/dbstart /bin/dbstop
 
ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
ln -s /etc/init.d/dbora /etc/rc6.d/K10dbora
 
ln -s /etc/init.d/dbora /etc/rc2.d/S98dbora
ln -s /etc/init.d/dbora /etc/rc3.d/S98dbora
ln -s /etc/init.d/dbora /etc/rc5.d/S98dbora