在ubuntu 8.04下安装Oracle 11g方法

Web、Mail、Ftp、DNS、Proxy、VPN、Samba、LDAP 等基础网络服务
zm508_china
帖子: 8
注册时间: 2007-12-14 9:39

在ubuntu 8.04下安装Oracle 11g方法

#1

帖子 zm508_china » 2008-07-16 12:51

在ubuntu 8.04下安装Oracle 11g
本文是参考了:http://hi.baidu.com/wuxicn/blog/item/0c ... 94.html"文章,是翻译下面的这篇文章的。我主要参考的是中文的,我只是在实际操作中做了一点小小的修改,在此表示感谢!紫色为我的注释。
原文是英文,地址是:
http://www.pythian.com/blogs/968/instal ... ardy-heron,(转载注明出处,谢谢!! )
共9步:

Step 1
下载和安装 Ubuntu 8.04 Hardy Heron (x86-32位) 版。略。

Step 2
下载Oracle 11g: Download Oracle 11g for Linux (x86, 32-bit).
现不要急着解压,一会我会告诉你解压在哪的。

Step 3
修改X server 的默认设置,点菜单的System -> Administration -> Login Window(系统->管理->登录窗口),选择“Security(安全)”选项卡,取消“Deny TCP connections to the Xserver(拒绝TCP连接到X服务器)”的勾,重启Xserver(或者重启系统)。然后在终端输入:
user@hardy:~$ xhost +127.0.0.1
127.0.0.1 being added to access control list
Step 4
打开终端,转换为超级用户:(注意,这里用sudo su -而不是sudo -s是有原因的:sudo su - 将用户转换为超级用户,并新起一个会话(空的会话),而不是像sudo -s那样将当前会话传递个新的超级用户,减少环境变量可能造成的影响和危害。
user@hardy:~$ sudo su -
[sudo] password for user:
root@hardy:~# apt-get update
...
root@hardy:~# apt-get dist-upgrade
...
root@hardy:~# reboot
Step 5
用apt安装一些必要的工具:

user@hardy:~$ sudo su -
[sudo] password for user:
root@hardy:~# apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm
...
root@hardy:~#
Step 6
在装完那些工具以后,我们需要做的就是修改一些Ubuntu的/bin/sh的默认连接,千万不要略过这一步,否则安装的时候会出现很多错误。
root@hardy:~# cd /bin
root@hardy:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-04-28 19:59 /bin/sh -> dash
root@hardy:/bin# ln -sf bash /bin/sh
root@hardy:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-05-01 22:51 /bin/sh -> bash
如果你想知道为什么Ubuntu用dash作为默认的shell,看这个:a detailed explanation of why dash is the default system shell 。
Step 7
增加用户和组,并修改一些配置。这一步很重要!如果不是很有把握,不要随便改。(为了便于解释,增加了行号):
01 root@hardy:/bin# cd
02 root@hardy:~# pwd
/root
04 root@hardy:~# addgroup oinstall
Adding group `oinstall' (GID 1001) ...
Done.
07 root@hardy:~# addgroup dba
Adding group `dba' (GID 1002) ...
Done.
10 root@hardy:~# addgroup nobody
Adding group `nobody' (GID 1003) ...
Done.
13 root@hardy:~# usermod -g nobody nobody
14 root@hardy:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
15 root@hardy:~# mkdir /home/oracle
16 root@hardy:~# chown -R oracle:dba /home/oracle
17 root@hardy:~# ln -s /usr/bin/awk /bin/awk
18 root@hardy:~# ln -s /usr/bin/rpm /bin/rpm
19 root@hardy:~# ln -s /usr/bin/basename /bin/basename
20 root@hardy:~# mkdir /etc/rc.d
21 root@hardy:~# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
22 root@hardy:~# mkdir -p /u01/app/oracle
23 root@hardy:~# chown -R oracle:dba /u01
24 root@hardy:~#
Lines 04-12: 增加我们需要的用户和组
Line 13: 让nobody用户的组变为nobody,这样Oracle的安装程序不会出问题。Ubuntu默认nobody的组是nogroup。
Lines 14-18: 创建一个oracle用户。注意,oracle用户的HOME目录不要与ORACLE_HOME相同。
Lines 19-23: 创建一些Oracle安装程序需要的工具的连接。因为Oracle安装程序是为Red Hat准备的,所以有些工具的位置和Ubuntu不一样。
Finally, on lines 24-25 创建ORACLE_BASE目录。
Step 8
修改一些系统默认值。这些修改将会增加系统文件描述符的数量、增加共享内存大小和修改一些网络子系统参数。这些修改是否会对你的系统带来影响我就不得而知了。将下面这些增加到/etc/sysctl.conf文件的末尾:
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
再增加下面这些到/etc/security/limits.conf文件末尾:

oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
为了强制使用刚才我们增加的东西,我们再增加下面这些到/etc/pam.d/login文件末尾:

session required /lib/security/pam_limits.so
session required pam_limits.so
然后通过命令:sysctl -p 让刚才增加的东西生效:

root@hardy:~# sysctl -p
kernel.printk = 4 4 1 7
kernel.maps_protect = 1
fs.inotify.max_user_watches = 524288
vm.mmap_min_addr = 65536
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
root@hardy:~#
Step 9
现在我们将刚才下载的oracle11g的安装包解压到/home/oracle/install/目录下。然后进入目录,设置DISPLAY参数,开始安装:

root@hardy:~# cd /home/oracle
root@hardy:/home/oracle# chown -R oracle:dba install

用oracle用户登陆,(不然会出安装界面出不来)
oracle@hardy:~$ export DISPLAY=127.0.0.1:0.0
oracle@hardy:~$ pwd
/home/oracle
oracle@hardy:~$ ls -l
total 4
drwxr-xr-x 6 oracle dba 4096 2007-09-18 18:50 install
oracle@hardy:~$ cd install
oracle@hardy:~/install$ ls -l
total 28
drwxr-xr-x 11 oracle dba 4096 2007-08-06 16:02 doc
drwxr-xr-x 5 oracle dba 4096 2007-08-03 13:28 install
drwxr-xr-x 2 oracle dba 4096 2007-09-18 18:52 response
-rwxr-xr-x 1 oracle dba 2911 2007-08-03 13:28 runInstaller
drwxr-xr-x 14 oracle dba 4096 2007-08-03 13:27 stage
-rw-r--r-- 1 oracle dba 4835 2007-08-06 18:19 welcome.html
oracle@hardy:~/install$ ./runInstaller -ignoreSysPrereqs
输入完上面命令后,就进入了Oracle 的同一安装程序了(OUI),不要急,继续按照本文一步一步的通过安装:
注意:OUI安装完后,并不是真正完全安装完成,还需要就行最后的收尾工作(在最后有),而且这是必须做的工作!


点(Next)下一步。


修改“Specify Operating System group name:”为:"dba",然后点"Next".


按照上图设置,点下一步。


选择"Enterprise Edition",然后下一步。


安图设置,下一步。


继续下一步。


等待系统检查,不要担心有错误和警告。


将检查到的所有非“Succeeded”的都打上勾,下一步。


,下一步。在这一步选"Create a Database"来安装数据库。原文是通过netca建立监听,dbca建库,我第一次也是这样做的,dbca建库时会报错,因为ubutunbu 不支持RPM包)。

将所有组都设为:dba,下一步。

现在可以点“Install”了:)时间比较长。


到了这一步不要记着点“OK”,需要做下面操作:(另起一个终端,用sudo su - 转为超级用户)

root@hardy:~# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory to 770.
Changing groupname of /u01/app/oraInventory to dba.
The execution of the script is complete
root@hardy:~# /u01/app/oracle/product/11.1.0/db_1/root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.1.0/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
root@hardy:~#
好了,这个完成后可以点“OK”了。
安后点“Exit”退出OUI,现在可以祝贺你,OUI安装完成了:)但是还是不要急,记住咱们还有收尾工作需要做。
在/etc/profile文件中加入下面几句:

export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export PATH=$PATH:/u01/app/oracle/product/11.1.0/db_1/bin
创建一个Oracle 11g数据库的启动脚本,名字可以叫做:oracledb,在/u01/app/oracle/product/11.1.0/db_1/bin下建立文件:oracledb,内容:

#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi

case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac

exit 0
修改脚本为可执行的:

root@hardy:~# chmod a+x /u01/app/oracle/product/11.1.0/db_1/bin/oracledb
如果你希望开机自动启动Oracle 11g数据库,那么就作下面的工作:

root@hardy:~# ln -s /u01/app/oracle/product/11.1.0/db_1/bin/oracledb /etc/init.d/oracledb
root@hardy:~# sudo sysv-rc-conf --level 2345 oracledb on

如果没有sysv-rc-conf命令,就apt-get一个。
最后,增加你自己的用户名到dba组:

root@hardy:~# usermod -G dba -a user
好了,至此,Oracle 11g就安装完了。重新登录后,你就可以使用oracle的命令了。
(ORACLE_SID=orcl 是你安装时候设置的值)

oracle@hardy:~$ export ORACLE_SID=orcl
oracle@hardy:~$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 5 02:39:27 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>connect /as sysdba
Connected to an idle instance.

SQL>startup 启动数据库命令。
.
ORACLE instance started.



Total System Global Area 418484224 bytes

Fixed Size 1300324 bytes

Variable Size 281020572 bytes

Database Buffers 130023424 bytes

Redo Buffers 6139904 bytes

Database mounted.

Database opened.

oracle@hardy:~$ export ORACLE_SID=orcl
oracle@hardy:~$ emctl start dbconsole 启动EM,地址为https://yourip:1158/em/console.这样你就可以通过IE登陆了。不过界面为乱码。呵呵!!解决方法自己在网上找吧!!

如果你看到了上面的结果,证明你的oracle安装成功了。
上次由 zm508_china 在 2008-08-11 16:06,总共编辑 3 次。
ubuntukumao
帖子: 26
注册时间: 2008-06-19 22:22

#2

帖子 ubuntukumao » 2008-07-17 10:24

very good!
安装好图形界面后试试。
谢谢LZ分享!
头像
timebomb
帖子: 153
注册时间: 2008-04-09 11:01

Re: 在ubuntu 8.04下安装Oracle 11g方法

#3

帖子 timebomb » 2009-07-20 21:14

这么好的东西怎么没有人顶呢,郁闷。

谢谢搂住了 :em02
flytoj2ee
帖子: 1
注册时间: 2009-08-14 16:30

Re: 在ubuntu 8.04下安装Oracle 11g方法

#4

帖子 flytoj2ee » 2009-08-14 16:32

:em01

感谢楼主的工作.

我按照这文章装好了oracle 11g.
expipi
帖子: 27
注册时间: 2008-04-15 14:57
来自: sdust.B14.603

Re: 在ubuntu 8.04下安装Oracle 11g方法

#5

帖子 expipi » 2009-08-16 21:07

谢谢!
先mark着
头像
tigerdoo
帖子: 327
注册时间: 2006-11-17 23:02

Re: 在ubuntu 8.04下安装Oracle 11g方法

#6

帖子 tigerdoo » 2009-08-20 16:17

安装Oracle必须要x吗?没有x的服务器环境怎么安?
IBM T41-P4M 1.5G/1GB/40GB HDD/DVD/14.1TFT/IPW2100 & 10-100M
OS:Xubuntu 11.10
生活就是折腾
活在成都
使用update-rc.d管理Linux服务
guoyu841020
帖子: 15
注册时间: 2009-09-04 14:33

Re: 在ubuntu 8.04下安装Oracle 11g方法

#7

帖子 guoyu841020 » 2009-09-05 13:57

太应该顶了,我要顶
davidchenbin
帖子: 62
注册时间: 2008-08-22 20:04

Re: 在ubuntu 8.04下安装Oracle 11g方法

#8

帖子 davidchenbin » 2009-09-20 0:58

tigerdoo 写了:安装Oracle必须要x吗?没有x的服务器环境怎么安?
http://www.itpub.net/thread-1216438-1-1.html
可以参考这个安装,oracle有一个静默安装的参数
头像
Heraclesun
帖子: 38
注册时间: 2008-11-19 14:16

Re: 在ubuntu 8.04下安装Oracle 11g方法

#9

帖子 Heraclesun » 2009-12-02 17:39

会用到,留脚印
Botswana National Library Service
sdmc
帖子: 2
注册时间: 2008-01-06 17:49

Re: 在ubuntu 8.04下安装Oracle 11g方法

#10

帖子 sdmc » 2009-12-08 20:11

顶一个,支持一下。
fanghongzhou
帖子: 1
注册时间: 2010-01-13 13:52

Re: 在ubuntu 8.04下安装Oracle 11g方法

#11

帖子 fanghongzhou » 2010-01-16 16:01

正要装,先顶一个,希望带来好运,呵呵
tiantang146
帖子: 4
注册时间: 2009-06-07 2:01

Re: 在ubuntu 8.04下安装Oracle 11g方法

#12

帖子 tiantang146 » 2010-10-02 16:03

我装了两天了 也没有装好 觉得你写的应该不错 回去了试试
头像
chinacode
帖子: 21
注册时间: 2009-09-15 12:17
联系:

Re: 在ubuntu 8.04下安装Oracle 11g方法

#13

帖子 chinacode » 2010-10-11 18:08

:em11
mark 一下。
很多号邮箱平台:很多号邮箱平台
谷歌邮箱购买:谷歌邮箱购买
shore1111
帖子: 2
注册时间: 2010-10-20 9:03

Re: 在ubuntu 8.04下安装Oracle 11g方法

#14

帖子 shore1111 » 2010-10-20 11:09

修改X server 的默认设置,点菜单的System -> Administration -> Login Window(系统->管理->登录窗口),选择“Security(安全)”选项卡,取消“Deny TCP connections to the Xserver(拒绝TCP连接到X服务器)”的勾,重启Xserver(或者重启系统)。然后在终端输入:
user@hardy:~$ xhost +127.0.0.1
127.0.0.1 being added to access control list

我的是Ubuntu10.10。 xhost命令无法执行,页面也无法显示。
shore1111
帖子: 2
注册时间: 2010-10-20 9:03

Re: 在ubuntu 8.04下安装Oracle 11g方法

#15

帖子 shore1111 » 2010-10-20 11:25

已经成功了
回复