您的位置:首页 > 数据库 > Oracle

Ubuntu 10.10 安装Oracle10g安装指南

2014-12-16 17:51 281 查看
第一步,下载oracle10安装包(服务器和客户端)

http://download.oracle.com/otn/linux/oracle10g/10201/10201_client_linux32.zip

http://download.oracle.com/otn/linux/oracle10g/10201/10201_database_linux32.zip

第二步,安装必须的包

32位:apt-get install gcc make binutils lesstif2 libc6 libc6-dev rpm libmotif3 libaio1 libstdc++6 alien
64位:sudo apt-get install gcc libaio1 lesstif2 lesstif2-dev make libc6 libc6-i386 libc6-dev-i386 libstdc++5 lib32stdc++6 lib32z1 ia32-libs
在使用Ubuntu10.10安装oracle时,会报告一个错误,这是应该Ubuntu默认安装了libstdc++6,而oracle安装程序要使用的是libstc++5,可以使用sudo apt-get install libstdc++5. 

第三步,创建用户

# adduser oracle
正在添加用户"oracle"...
正在添加新组"oracle" (1001)...
正在添加新用户"oracle" (1002) 到组"oracle"...
创建主目录"/home/oracle"...
正在从"/etc/skel"复制文件...
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
Changing the user information for oracle
Enter the new value, or press ENTER for the default
Full Name []: oracle
Room Number []:
Work Phone []:
Home Phone []:
Other []:


第四步,修改设置

1) 设置swap区

oracle 10g至少需要500M的内存和400M的交换空间,使用cat /proc/meminfo 查看交换空间大小,如果小于400M空间,那么就需要增加swap的大小。

dd if=/dev/zero of=tmp_swap bs=1k count=900000
chmod 600 tmp_swap
mkswap tmp_swap
swapon tmp_swap


完成安装后,可以释放这个空间

swapoff tmp_swap
rm tmp_swap


count值根据调整的交换区大小来定。

2) 修改该sysctl.conf

添加如下的行到/etc/sysctl.conf中:

kernel.shmmax = 3147483648
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
note: shmmax(最大共享内存)是一个很重要的参数,根据机器的内存来设定,一般为物理内存的一半。

3) 修改limits.conf

添加如下行到/etc/security/limits.conf中:

oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384


4) 修改pam.d

添加如下行到/etc/pam.d/login

session    required   pam_limits.so
session    required   /lib/security/pam_limits.so


5) 让修改生效

重启系统,或者使用sudo sysctl -p

6) 产生相应的软连接

创建ch.sh,内容如下

#!/bin/bash
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
mkdir /etc/rc.d
ln -s /etc/rc0.d /etc/rc.d/rc0.d
ln -s /etc/rc2.d /etc/rc.d/rc2.d
ln -s /etc/rc3.d /etc/rc.d/rc3.d
ln -s /etc/rc4.d /etc/rc.d/rc4.d
ln -s /etc/rc5.d /etc/rc.d/rc5.d
ln -s /etc/rc6.d /etc/rc.d/rc6.d
ln -s /etc/init.d /etc/rc.d/init.d
创建后使用sudo chmod u+x ch.sh改为可执行,sudo ch.sh执行。

7) 创建版本申明文件

在使用sudo vi /etc/redhat-release添加一下申明,使得安装程序认为在一个RedHat的系统上安装,redhat-release在Ubuntu中没有,是新添加的。

Red Hat Linux release 3.1 (drupal)
8) 修改环境变量

编辑/home/oracle/.bashrc,增加一下内容。

export ORACLE_HOME=/opt/ora10
export ORACLE_OWNER=oracle
export ORACLE_SID=ora1
export ORACLE_TERM=xterm
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin:$PATH
第五步, 开始安装

重新用oracle用户登录,用env查看一下环境变量是否生效,~/tmp 是oracle安装包所在的目录。

sudo mkdir /opt/ora10
sudo chown -R oracle:oracle /opt/ora10
cd ~/tmp
./runInstaller
在安装过程中,使用Advanced Installation,然后按默认的设置进行安装,到窗单名为 “Specify Database Configuration Options”的时候,要修改以下设置: Database Character Set 中选择 Simplified Chinese ZHS16GBK 在安装的後期,系统提示需要用 root 用户去运行两个脚本文件orainstRoot.sh和root.sh,安装完毕後,Oracle是正常启动着的,你可以试一下连接数据库,同时也可以使用浏览器去设置一下Oracle,(url:http:
//localhost:1158/em/)(Oracle 10g与之前的版本都不一样,使用WEB页的企业管理器来代替以前的C/S版JAVA企业管理器)。

第六步,设置自动启动脚本

创建自启动脚本 创建 oracledb 脚本到/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/ora10
export ORACLE_SID=ora1
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 Error] dbstart command does not exist, quitting..."
exit 1
else
echo "[Oracle Info] dbstart existance check OK"
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 "[Oracle Info] Starting oracle"
echo "[Oracle Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/lsnrctl start"
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
if [ $? -ne 0 ]
then
echo "[Oracle Error] listener failed to start"
exit 1
else
echo "[Oracle Info] listener start OK"
fi

su $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
echo "[Oracel Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
if [ $? -ne 0 ]
then
echo "[Oracle Error] dbstart failed to start"
exit 1
else
echo "[Oracle Info] dbstart OK"
fi
touch /var/lock/oracle
echo "[Oracle Info]su $ORA_OWNR -c ""$ORACLE_HOME/bin/emctl start dbconsole"
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
if [ $? -ne 0 ]
then
echo "[Oracle Error] dbconsole failed to start"
exit 1
else
echo "[Oracle Info] dbconsole start OK"
fi
echo "[Oracle Info] Starting oracle ended OK"
;;
stop)
# Oracle listener and instance shutdown
echo "[Oracle Info] Shutdown Oracle: "
echo "[Oracle Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/lsnrctl stop"
su $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
echo "[Oracle Info] su $ORA_OWNR -c ""$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
su $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f /var/lock/oracle
echo "[Oracle Info]su $ORA_OWNR -c ""$ORACLE_HOME/bin/emctl stop dbconsole"
su $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "[Oracle Info] Shutdown Oracle ended OK"
;;
reload|restart)
echo "[Oracle Info]: $1 oracle"
$0 stop
$0 start
;;
*)
echo "[Oracle Error] Unknown context: $1"
echo "[Oracle Info]  Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
设置权限,放到启动脚本中去

chmod 755 /etc/init.d/oracledb
update-rc.d oracledb defaults 99
还需要编辑一下/etc/oratab,把其中的N改成Y,不然上述脚本中所调用的$ORACLE_HOME/bin/dbstart在执行时不会自动启动相应的数据库实例(这里的数据库实例是ora1)。文件内容如下:
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
ora1:/opt/ora10:Y
如果只用上述的脚本是不能启动 listener的,要修改一下: 修改 /opt/ora10/bin/dbstart文件 

# Set this to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
改为:

# Set this to bring up Oracle Net Listener
ORACLE_HOME_LISTNER=$ORACLE_HOME
设置后,测试一下

cd /etc/init.d
./oracledb reload

如果一切正常,关闭后会重启。

安装过程中出现的问题:

问题一:



该问题是因为在缺少库文件,网上很多人碰到这个问题,是因为缺少libstdc++.so.5,但是我出现的问题是缺少libstdgcc.so.1,具体问题需要查看log文件。

问题二:



该问题是因为在/etc/hosts文件中所指定的ip有问题,更改过来,retry即可。

问题三:

在安装完成后使用root.sh执行后出现'nobody'无效,需要添加相应的用户。

参考博客:

http://wiki.ubuntu.org.cn/Ubuntu%E4%B8%8AOracle10g%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97#.E7.AC.AC.E4.BA.8C.E6.AD.A5.EF.BC.8C.E5.AE.89.E8.A3.85.E5.BF.85.E9.9C.80.E7.9A.84.E5.8C.85

http://blog.csdn.net/jeffygn2006/article/details/6082151
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: