OS:ubuntu-10.04-server-amd64(在线升级安装了GNOME基本版本,详见 Ubuntu Server 安装图形桌面环境 )
DB:10201_database_linux_x86_64.cpio.gz
apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm x-window-system-core gdm ubuntu-desktop gnome-core xinit x11-utils
2.ORACLE安装环境准备
获取root权限:
sudo su -
执行如下代码:
apt-get install gcc gcc-multilib libaio1 libaio-dev lesstif2 lesstif2-dev libc6 libc6-dev-i386 libc6-dev-i386 libc6-i386 ia32-libs libelf-dev lsb-cxx make rpm build-essential unixODBC unixODBC-dev pdksh expat sysstat elfutils binutils binutils-dev binutils-source lesstif2 libc6 libc6-dev libmotif3 libstdc++6 alien
解决安装过程中出现"ctx/lib/ins_ctx.mk.."错误:
执行如下代码:
http://security.ubuntu.com/ubuntu/pool/universe/g/gcc-3.3/
cd /tmp
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3.6-17ubuntu1_amd64.deb
dpkg-deb -x libstdc++5_3.3.6-17ubuntu1_amd64.deb ia64-libs
cp ia64-libs/usr/lib/libstdc++.so.5.0.7 /usr/lib64/
cd /usr/lib64/
ln -s libstdc++.so.5.0.7 libstdc++.so.5
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3.6-17ubuntu1_amd64.deb
dpkg-deb -x libstdc++5_3.3.6-17ubuntu1_amd64.deb ia64-libs
cp ia64-libs/usr/lib/libstdc++.so.5.0.7 /usr/lib64/
cd /usr/lib64/
ln -s libstdc++.so.5.0.7 libstdc++.so.5
cd /tmp
wget http://mirrors.kernel.org/ubuntu/pool/universe/i/ia32-libs/ia32-libs_2.7ubuntu6.1_amd64.deb
dpkg-deb -x ia32-libs_2.7ubuntu6.1_amd64.deb ia32-libs
cp ia32-libs/usr/lib32/libstdc++.so.5.0.7 /usr/lib32/
cd /usr/lib32
ln -s libstdc++.so.5.0.7 libstdc++.so.5
wget http://mirrors.kernel.org/ubuntu/pool/universe/i/ia32-libs/ia32-libs_2.7ubuntu6.1_amd64.deb
dpkg-deb -x ia32-libs_2.7ubuntu6.1_amd64.deb ia32-libs
cp ia32-libs/usr/lib32/libstdc++.so.5.0.7 /usr/lib32/
cd /usr/lib32
ln -s libstdc++.so.5.0.7 libstdc++.so.5
cd /tmp
rm *.deb
rm -r ia64-libs
rm -r ia32-libs
rm *.deb
rm -r ia64-libs
rm -r ia32-libs
3.建立软链接解决一些安装过程中的错误信息
避免调用编译文件时idg4odbc出现错误:
ln -s /usr/bin/basename /bin/basename
避免执行脚本root.sh出错:
ln -s /usr/bin/awk /bin/awk
其他太多相关的脚本如下:
ln -s /usr/bin/rpm /bin/rpm
ln -s /lib/libgcc_s.so.1 /lib/libgcc_s.so
ln -s /lib/libgcc_s.so.1 /lib/libgcc_s.so
4.更改配置
备份sysctl.conf
cp /etc/sysctl.conf /etc/sysctl.original
nano /etc/sysctl.conf
添加以下行到/etc/sysctl.conf中
kernel.shmall = 2097152
kernel.shmmax = 2147483648
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 = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
vm.swappiness=5
kernel.shmmax = 2147483648
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 = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144
vm.swappiness=5
更新系统运行:
sysctl -p
备份limits.conf
cp /etc/security/limits.conf /etc/security/limits.conf.original
nano /etc/security/limits.conf
添加以下行到/etc/security/limits.con中
#Oracle 10gR2 shell limits:
oracle soft nproc 2048
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2048
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
5.设置用户和用户组
我们需要为安装程序创建一个oracle用户和两个组。
groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba oracle
usermod -s /bin/bash oracle
passwd oracle
groupadd nobody
usermod -g nobody nobody
groupadd dba
useradd -m -g oinstall -G dba oracle
usermod -s /bin/bash oracle
passwd oracle
groupadd nobody
usermod -g nobody nobody
执行如下代码:
id oracle
显示如下代码:
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
里面的数字因系统原因不一定相同
6.ORACLE安装目录准备及环境准备
我们使得/opt/oracle为安装目录
mkdir -p /opt/oracle
mkdir -p /opt/oraInventory
chown oracle:oinstall /opt/oracle
chown oracle:oinstall /opt/oraInventory
chmod 750 /opt/oracle
chmod 750 /opt/oraInventory
mkdir -p /opt/oraInventory
chown oracle:oinstall /opt/oracle
chown oracle:oinstall /opt/oraInventory
chmod 750 /opt/oracle
chmod 750 /opt/oraInventory
通过创建一个新文件/etc/redhat-release并添加以下行,欺骗安装程序让它以为我们
的系统是RedHat:
Red Hat Linux release 4.1
修改oracle环境
nano /home/oracle/.bashrc
增加如下代码:
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
ORACLE_SID=km
export ORACLE_BASE ORACLE_HOME ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH:.
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LD_LIBRARY_PATH CLASSPATH
alias sqlplus='rlwrap sqlplus'
ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
ORACLE_SID=km
export ORACLE_BASE ORACLE_HOME ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH:.
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LD_LIBRARY_PATH CLASSPATH
alias sqlplus='rlwrap sqlplus'
7.ORACLE的安装
将oracle安装文件解压得到database文件夹,如果解压详见 linux下.cpio.gz文件的解压
执行如下代码:
chown -R oracle:oinstall /opt/soft/database
改变目录权限前提是oracle为文件一样。如果不一样使用你自己的目录
退出系统以oracle用户登陆进GDM环境,打开终端:
export LANG=en_CN
cd /opt/soft/database
./runInstaller
cd /opt/soft/database
./runInstaller
只要安装软件就行了。不要安装示例数据库
如果安装过程中出现如下错误:
引用
Error in invoking target 'collector' of makefile '/opt/oracle/10g/product/10.2.0/db_1/sysman/lib/ins_emdb.mk'.
请跳过.
安装完成后,我们完成后来解决上一错误:
cd $ORACLE_HOME/bin
mv oracle oracle.bin
cat >oracle <<"EOF"
#!/bin/bash
export DISABLE_HUGETLBFS=1
exec $ORACLE_HOME/bin/oracle.bin $@
EOF
chmod +x oracle
mv oracle oracle.bin
cat >oracle <<"EOF"
#!/bin/bash
export DISABLE_HUGETLBFS=1
exec $ORACLE_HOME/bin/oracle.bin $@
EOF
chmod +x oracle
8.设置自启动
创建自启动脚本 创建 oracledb 脚本到/etc/init.d/oracledb,内容如下
获取root权限:
sudo su -
nano /etc/init.d/oracledb
#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
export ORACLE_SID=km
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/oracle
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
rm -f /var/lock/oracle
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_HOME=/opt/oracle/product/10.2.0/db_1
export ORACLE_SID=km
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
touch /var/lock/oracle
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
rm -f /var/lock/oracle
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
设置权限,放到启动脚本中去
chmod 755 /etc/init.d/oracledb
update-rc.d oracledb defaults 99
update-rc.d oracledb defaults 99
还需要编辑一下/etc/oratab,把其中的N改成Y,不然上述脚本中所调用的$ORACLE_HOME/bin/dbstart在执行时不会自动启动相应的数据库实例