﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-ＳｅｅＳｅａ-随笔分类-DB</title><link>http://www.blogjava.net/seesea/category/33149.html</link><description>Ｊａｖａ初学习</description><language>zh-cn</language><lastBuildDate>Wed, 18 Mar 2009 03:04:48 GMT</lastBuildDate><pubDate>Wed, 18 Mar 2009 03:04:48 GMT</pubDate><ttl>60</ttl><item><title>在ubuntu 8.04下安装Oracle 11g方法</title><link>http://www.blogjava.net/seesea/archive/2009/03/18/260400.html</link><dc:creator>SeesSea</dc:creator><author>SeesSea</author><pubDate>Wed, 18 Mar 2009 02:52:00 GMT</pubDate><guid>http://www.blogjava.net/seesea/archive/2009/03/18/260400.html</guid><wfw:comment>http://www.blogjava.net/seesea/comments/260400.html</wfw:comment><comments>http://www.blogjava.net/seesea/archive/2009/03/18/260400.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/seesea/comments/commentRss/260400.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/seesea/services/trackbacks/260400.html</trackback:ping><description><![CDATA[<p>项目要求使用Oracle，据说安装方式比较繁复，网上搜到两篇文章，先备着，准备日后按图索骥。<br />
第一篇<br />
地址：<a href="http://forum.ubuntu.org.cn/viewtopic.php?f=44&amp;t=136860">http://forum.ubuntu.org.cn/viewtopic.php?f=44&amp;t=136860</a><br />
</p>
<div class="postbody">在ubuntu 8.04下安装Oracle 11g <br />
本文是参考了：http://hi.baidu.com/wuxicn/blog/item/0cfdc24ac5ae372609f7ef94.html"文章，是翻译下面的这篇文章的。我主要参考的是中文的，我只是在实际操作中做了一点小小的修改，在此表示感谢！紫色为我的注释。 <br />
原文是英文,地址是： <br />
<!-- m --><a class="postlink" href="http://www.pythian.com/blogs/968/installing-oracle-11g-on-ubuntu-804-lts-hardy-heron">http://www.pythian.com/blogs/968/instal ... ardy-heron</a><!-- m -->，（转载注明出处，谢谢！！ ） <br />
共9步： <br />
<br />
Step 1 <br />
下载和安装 Ubuntu 8.04 Hardy Heron (x86-32位) 版。略。 <br />
<br />
Step 2 <br />
下载Oracle 11g： Download Oracle 11g for Linux (x86, 32-bit). <br />
现不要急着解压，一会我会告诉你解压在哪的。 <br />
<br />
Step 3 <br />
修改X server 的默认设置，点菜单的System -&gt; Administration -&gt; Login Window（系统－&gt;管理－&gt;登录窗口），选择&#8220;Security（安全）&#8221;选项卡，取消&#8220;Deny TCP connections to the Xserver（拒绝TCP连接到X服务器）&#8221;的勾，重启Xserver（或者重启系统）。然后在终端输入： <br />
user@hardy:~$ xhost +127.0.0.1 <br />
127.0.0.1 being added to access control list <br />
Step 4 <br />
打开终端，转换为超级用户：（注意，这里用sudo su -而不是sudo -s是有原因的：sudo su - 将用户转换为超级用户，并新起一个会话（空的会话），而不是像sudo -s那样将当前会话传递个新的超级用户，减少环境变量可能造成的影响和危害。 <br />
user@hardy:~$ sudo su - <br />
[sudo] password for user: <br />
root@hardy:~# apt-get update <br />
... <br />
root@hardy:~# apt-get dist-upgrade <br />
... <br />
root@hardy:~# reboot <br />
Step 5 <br />
用apt安装一些必要的工具： <br />
<br />
user@hardy:~$ sudo su - <br />
[sudo] password for user: <br />
root@hardy:~# apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm <br />
... <br />
root@hardy:~# <br />
Step 6 <br />
在装完那些工具以后，我们需要做的就是修改一些Ubuntu的/bin/sh的默认连接，千万不要略过这一步，否则安装的时候会出现很多错误。 <br />
root@hardy:~# cd /bin <br />
root@hardy:/bin# ls -l /bin/sh <br />
lrwxrwxrwx 1 root root 4 2008-04-28 19:59 /bin/sh -&gt; dash <br />
root@hardy:/bin# ln -sf bash /bin/sh <br />
root@hardy:/bin# ls -l /bin/sh <br />
lrwxrwxrwx 1 root root 4 2008-05-01 22:51 /bin/sh -&gt; bash <br />
如果你想知道为什么Ubuntu用dash作为默认的shell，看这个：a detailed explanation of why dash is the default system shell 。 <br />
Step 7 <br />
增加用户和组，并修改一些配置。这一步很重要！如果不是很有把握，不要随便改。(为了便于解释，增加了行号）： <br />
01 root@hardy:/bin# cd <br />
02 root@hardy:~# pwd <br />
/root <br />
04 root@hardy:~# addgroup oinstall <br />
Adding group `oinstall' (GID 1001) ... <br />
Done. <br />
07 root@hardy:~# addgroup dba <br />
Adding group `dba' (GID 1002) ... <br />
Done. <br />
10 root@hardy:~# addgroup nobody <br />
Adding group `nobody' (GID 1003) ... <br />
Done. <br />
13 root@hardy:~# usermod -g nobody nobody <br />
14 root@hardy:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle <br />
15 root@hardy:~# mkdir /home/oracle <br />
16 root@hardy:~# chown -R oracle:dba /home/oracle <br />
17 root@hardy:~# ln -s /usr/bin/awk /bin/awk <br />
18 root@hardy:~# ln -s /usr/bin/rpm /bin/rpm <br />
19 root@hardy:~# ln -s /usr/bin/basename /bin/basename <br />
20 root@hardy:~# mkdir /etc/rc.d <br />
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 <br />
22 root@hardy:~# mkdir -p /u01/app/oracle <br />
23 root@hardy:~# chown -R oracle:dba /u01 <br />
24 root@hardy:~# <br />
Lines 04-12: 增加我们需要的用户和组 <br />
Line 13: 让nobody用户的组变为nobody，这样Oracle的安装程序不会出问题。Ubuntu默认nobody的组是nogroup。 <br />
Lines 14-18: 创建一个oracle用户。注意，oracle用户的HOME目录不要与ORACLE_HOME相同。 <br />
Lines 19-23: 创建一些Oracle安装程序需要的工具的连接。因为Oracle安装程序是为Red Hat准备的，所以有些工具的位置和Ubuntu不一样。 <br />
Finally, on lines 24-25 创建ORACLE_BASE目录。 <br />
Step 8 <br />
修改一些系统默认值。这些修改将会增加系统文件描述符的数量、增加共享内存大小和修改一些网络子系统参数。这些修改是否会对你的系统带来影响我就不得而知了。将下面这些增加到/etc/sysctl.conf文件的末尾： <br />
fs.file-max = 65535 <br />
kernel.shmall = 2097152 <br />
kernel.shmmax = 2147483648 <br />
kernel.shmmni = 4096 <br />
kernel.sem = 250 32000 100 128 <br />
net.ipv4.ip_local_port_range = 1024 65535 <br />
net.core.rmem_default = 1048576 <br />
net.core.rmem_max = 1048576 <br />
net.core.wmem_default = 262144 <br />
net.core.wmem_max = 262144 <br />
再增加下面这些到/etc/security/limits.conf文件末尾： <br />
<br />
oracle soft nproc 2047 <br />
oracle hard nproc 16383 <br />
oracle soft nofile 1023 <br />
oracle hard nofile 65535 <br />
为了强制使用刚才我们增加的东西，我们再增加下面这些到/etc/pam.d/login文件末尾： <br />
<br />
session required /lib/security/pam_limits.so <br />
session required pam_limits.so <br />
然后通过命令：sysctl -p 让刚才增加的东西生效： <br />
<br />
root@hardy:~# sysctl -p <br />
kernel.printk = 4 4 1 7 <br />
kernel.maps_protect = 1 <br />
fs.inotify.max_user_watches = 524288 <br />
vm.mmap_min_addr = 65536 <br />
net.ipv4.conf.default.rp_filter = 1 <br />
net.ipv4.conf.all.rp_filter = 1 <br />
fs.file-max = 65535 <br />
kernel.shmall = 2097152 <br />
kernel.shmmax = 2147483648 <br />
kernel.shmmni = 4096 <br />
kernel.sem = 250 32000 100 128 <br />
net.ipv4.ip_local_port_range = 1024 65535 <br />
net.core.rmem_default = 1048576 <br />
net.core.rmem_max = 1048576 <br />
net.core.wmem_default = 262144 <br />
net.core.wmem_max = 262144 <br />
root@hardy:~# <br />
Step 9 <br />
现在我们将刚才下载的oracle11g的安装包解压到/home/oracle/install/目录下。然后进入目录，设置DISPLAY参数，开始安装： <br />
<br />
root@hardy:~# cd /home/oracle <br />
root@hardy:/home/oracle# chown -R oracle:dba install <br />
<br />
<span style="color: violet">用oracle用户登陆，(不然会出安装界面出不来)</span> <br />
oracle@hardy:~$ export DISPLAY=127.0.0.1:0.0 <br />
oracle@hardy:~$ pwd <br />
/home/oracle <br />
oracle@hardy:~$ ls -l <br />
total 4 <br />
drwxr-xr-x 6 oracle dba 4096 2007-09-18 18:50 install <br />
oracle@hardy:~$ cd install <br />
oracle@hardy:~/install$ ls -l <br />
total 28 <br />
drwxr-xr-x 11 oracle dba 4096 2007-08-06 16:02 doc <br />
drwxr-xr-x 5 oracle dba 4096 2007-08-03 13:28 install <br />
drwxr-xr-x 2 oracle dba 4096 2007-09-18 18:52 response <br />
-rwxr-xr-x 1 oracle dba 2911 2007-08-03 13:28 runInstaller <br />
drwxr-xr-x 14 oracle dba 4096 2007-08-03 13:27 stage <br />
-rw-r--r-- 1 oracle dba 4835 2007-08-06 18:19 welcome.html <br />
oracle@hardy:~/install$ ./runInstaller -ignoreSysPrereqs <br />
输入完上面命令后，就进入了Oracle 的同一安装程序了（OUI），不要急，继续按照本文一步一步的通过安装： <br />
注意：OUI安装完后，并不是真正完全安装完成，还需要就行最后的收尾工作（在最后有），而且这是必须做的工作！ <br />
<br />
<br />
点（Next）下一步。 <br />
<br />
<br />
修改&#8220;Specify Operating System group name:&#8221;为："dba"，然后点"Next". <br />
<br />
<br />
按照上图设置，点下一步。 <br />
<br />
<br />
选择"Enterprise Edition"，然后下一步。 <br />
<br />
<br />
安图设置，下一步。 <br />
<br />
<br />
继续下一步。 <br />
<br />
<br />
等待系统检查，不要担心有错误和警告。 <br />
<br />
<br />
将检查到的所有非&#8220;Succeeded&#8221;的都打上勾，下一步。 <br />
<br />
<br />
，下一步。在这一步选"Create a Database"来安装数据库。<span style="color: violet">（[color=red]原文是通过netca建立监听，dbca建库，我第一次也是这样做的，dbca建库时会报错，因为ubutunbu 不支持RPM包）。</span>[/color] <br />
<br />
将所有组都设为：dba，下一步。 <br />
<br />
现在可以点&#8220;Install&#8221;了：）时间比较长。 <br />
<br />
<br />
到了这一步不要记着点&#8220;OK&#8221;，需要做下面操作：（另起一个终端，用sudo su - 转为超级用户） <br />
<br />
root@hardy:~# /u01/app/oraInventory/orainstRoot.sh <br />
Changing permissions of /u01/app/oraInventory to 770. <br />
Changing groupname of /u01/app/oraInventory to dba. <br />
The execution of the script is complete <br />
root@hardy:~# /u01/app/oracle/product/11.1.0/db_1/root.sh <br />
Running Oracle 11g root.sh script... <br />
<br />
The following environment variables are set as: <br />
ORACLE_OWNER= oracle <br />
ORACLE_HOME= /u01/app/oracle/product/11.1.0/db_1 <br />
<br />
Enter the full pathname of the local bin directory: [/usr/local/bin]: <br />
Copying dbhome to /usr/local/bin ... <br />
Copying oraenv to /usr/local/bin ... <br />
Copying coraenv to /usr/local/bin ... <br />
<br />
Creating /etc/oratab file... <br />
Entries will be added to the /etc/oratab file as needed by <br />
Database Configuration Assistant when a database is created <br />
Finished running generic part of root.sh script. <br />
Now product-specific root actions will be performed. <br />
Finished product-specific root actions. <br />
root@hardy:~# <br />
好了，这个完成后可以点&#8220;OK&#8221;了。 <br />
安后点&#8220;Exit&#8221;退出OUI，现在可以祝贺你，OUI安装完成了：）但是还是不要急，记住咱们还有收尾工作需要做。 <br />
在/etc/profile文件中加入下面几句： <br />
<br />
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 <br />
export PATH=$PATH:/u01/app/oracle/product/11.1.0/db_1/bin <br />
创建一个Oracle 11g数据库的启动脚本，名字可以叫做：oracledb，在/u01/app/oracle/product/11.1.0/db_1/bin下建立文件：oracledb，内容： <br />
<br />
#!/bin/bash <br />
# <br />
# /etc/init.d/oracledb <br />
# <br />
# Run-level Startup script for the Oracle Listener and Instances <br />
# It relies on the information on /etc/oratab <br />
<br />
export ORACLE_BASE=/u01/app/oracle <br />
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 <br />
export ORACLE_OWNR=oracle <br />
export PATH=$PATH:$ORACLE_HOME/bin <br />
<br />
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ] <br />
then <br />
echo "Oracle startup: cannot start" <br />
exit 1 <br />
fi <br />
<br />
case "$1" in <br />
start) <br />
# Oracle listener and instance startup <br />
echo -n "Starting Oracle: " <br />
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start" <br />
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" <br />
touch /var/lock/oracle <br />
echo "OK" <br />
;; <br />
stop) <br />
# Oracle listener and instance shutdown <br />
echo -n "Shutdown Oracle: " <br />
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop" <br />
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" <br />
rm -f /var/lock/oracle <br />
echo "OK" <br />
;; <br />
reload|restart) <br />
$0 stop <br />
$0 start <br />
;; <br />
*) <br />
echo "Usage: `basename $0` start|stop|restart|reload" <br />
exit 1 <br />
esac <br />
<br />
exit 0 <br />
修改脚本为可执行的： <br />
<br />
root@hardy:~# chmod a+x /u01/app/oracle/product/11.1.0/db_1/bin/oracledb <br />
如果你希望开机自动启动Oracle 11g数据库，那么就作下面的工作： <br />
<br />
root@hardy:~# ln -s /u01/app/oracle/product/11.1.0/db_1/bin/oracledb /etc/init.d/oracledb <br />
root@hardy:~# sudo sysv-rc-conf --level 2345 oracledb on <br />
<br />
如果没有sysv-rc-conf命令，就apt-get一个。 <br />
最后，增加你自己的用户名到dba组： <br />
<br />
root@hardy:~# usermod -G dba -a user <br />
好了，至此，Oracle 11g就安装完了。重新登录后，你就可以使用oracle的命令了。 <br />
(ORACLE_SID=orcl 是你安装时候设置的值) <br />
<br />
oracle@hardy:~$ export ORACLE_SID=orcl <br />
oracle@hardy:~$ sqlplus '/as sysdba' <br />
<br />
SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 5 02:39:27 2008 <br />
<br />
Copyright (c) 1982, 2007, Oracle. All rights reserved. <br />
<br />
Connected to: <br />
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production <br />
With the Partitioning, OLAP, Data Mining and Real Application Testing options <br />
<br />
SQL&gt;connect /as sysdba <br />
Connected to an idle instance. <br />
<br />
SQL&gt;startup 启动数据库命令。 <br />
. <br />
ORACLE instance started. <br />
<br />
<br />
<br />
Total System Global Area 418484224 bytes <br />
<br />
Fixed Size 1300324 bytes <br />
<br />
Variable Size 281020572 bytes <br />
<br />
Database Buffers 130023424 bytes <br />
<br />
Redo Buffers 6139904 bytes <br />
<br />
Database mounted. <br />
<br />
Database opened. <br />
<br />
oracle@hardy:~$ export ORACLE_SID=orcl <br />
oracle@hardy:~$ emctl start dbconsole <span style="color: violet">启动EM，地址为https://yourip:1158/em/console</span>.这样你就可以通过IE登陆了。不过界面为乱码。呵呵！！解决方法自己在网上找吧！！ <br />
<br />
如果你看到了上面的结果，证明你的oracle安装成功了。</div>
<p>第二篇<br />
地址：<a href="http://www.linuxidc.com/Linux/2008-06/13855.htm">http://www.linuxidc.com/Linux/2008-06/13855.htm</a><br />
</p>
<p>花了半天时间,在<a title="Ubuntu" href="http://www.linuxidc.com/topicnews.aspx?tid=2">Ubuntu</a> 8.04 LTS上顺利安装Oracle 11G.下面说说大概的步骤.</p>
<p>1.确保安装了以下程序:</p>
<p>sudo apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm</p>
<p>2.</p>
<p>cd /bin<br />
ln -sf bash /bin/sh<!--iwms_ad_begin--><br />
<div align="center"><script language="javaScript" src="../../system/system60.js" type="text/javascript"></script><script type="text/javascript"><!-- google_ad_client="pub-5195587195407606" ;
/* Linuxidc 468x60, ????Ӛ 08-8-31 */ google_ad_slot="9963827011" ; google_ad_width="468;
google_ad_height" = 60;
//-->
</script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script><script>window.google_render_ad();</script><ins style="padding-right: 0px; padding-left: 0px; visibility: visible; padding-bottom: 0px; margin: 0px; width: 468px; border-top-style: none; padding-top: 0px; border-right-style: none; border-left-style: none; position: relative; height: 60px; border-bottom-style: none"><ins style="padding-right: 0px; display: block; padding-left: 0px; visibility: visible; padding-bottom: 0px; margin: 0px; width: 468px; border-top-style: none; padding-top: 0px; border-right-style: none; border-left-style: none; position: relative; height: 60px; border-bottom-style: none"><iframe id="google_ads_frame3" style="left: 0px; position: absolute; top: 0px" name="google_ads_frame" marginwidth="0" marginheight="0" src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-5195587195407606&amp;dt=1237343290062&amp;lmt=1232682600&amp;prev_slotnames=4448053148%2C0155470610&amp;output=html&amp;slotname=9963827011&amp;correlator=1237343289015&amp;url=http%3A%2F%2Fwww.linuxidc.com%2FLinux%2F2008-06%2F13855.htm&amp;frm=0&amp;ga_vid=1418700180.1237343289&amp;ga_sid=1237343289&amp;ga_hid=764714942&amp;flash=10.0.22.87&amp;u_h=800&amp;u_w=1280&amp;u_ah=769&amp;u_aw=1280&amp;u_cd=32&amp;u_tz=480&amp;u_java=true&amp;dtd=0&amp;w=468&amp;h=60&amp;xpc=SmYwFPsFEm&amp;p=http%3A//www.linuxidc.com" frameborder="0" width="468" scrolling="no" height="60" allowTransparency></iframe></ins></ins></div>
<p><!--iwms_ad_end--></p>
<p>&nbsp;</p>
<p>3.增加用户和组</p>
<p>addgroup oinstall<br />
addgroup dba<br />
addgroup nobody<br />
useradd -g oinstall -G dba -p passwd -d /home/oracle -s /bin/bash oracle<br />
usermod -g nobody nobody</p>
<p>4. <br />
mkdir /home/oracle<br />
chown -R oracle:dba /home/oracle</p>
<p>ln -s /usr/bin/awk /bin/awk<br />
ln -s /usr/bin/rpm /bin/rpm<br />
ln -s /usr/bin/basename /bin/basename</p>
<p>5. <br />
mkdir /etc/rc.d<br />
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</p>
<p>mkdir -p /opt/ora11<br />
chown -R oracle:dba /opt</p>
<p>6.编辑/etc/sysctl.conf,增加以下内容:</p>
<p>fs.file-max = 65535<br />
kernel.shmall = 2097152<br />
kernel.shmmax = 2147483648<br />
kernel.shmmni = 4096<br />
kernel.sem = 250 32000 100 128<br />
net.ipv4.ip_local_port_range = 1024 65535<br />
net.core.rmem_default = 1048576<br />
net.core.rmem_max = 1048576<br />
net.core.wmem_default = 262144<br />
net.core.wmem_max = 262144</p>
<p>7.编辑/etc/security/limits.conf,增加以下内容:</p>
<p>oracle soft nproc 2047<br />
oracle hard nproc 16383<br />
oracle soft nofile 1023<br />
oracle hard nofile 65535</p>
<p>8.编辑/etc/pam.d/login,增加以下内容:</p>
<p>session required /lib/security/pam_limits.so<br />
session required pam_limits.so</p>
<p>9.执行:</p>
<p>sysctl -p</p>
<p>10.</p>
<p>su - oracle</p>
<p>以上命令需以root用户执行,接下来切换至oracle用户.</p>
<p>11.切换至安装目录,开始安装.我选择了英语作为安装时显示的语言.</p>
<p>export LANG=en_CN<br />
./runInstaller</p>
<p>12.安装过程中提示运行以下两个脚本:</p>
<p>orainstRoot.sh<br />
root.sh</p>
<p>12.安装过程中检测到系统未装有GLIBC环境,忽略后,未发现对安装和运行有多大影响.</p>
<p>13.切记,安装时选择自定义,并且选择数据库的字符集为 ZHS16GBK!</p>
<p>因为忘记了这个选项,我只好删掉数据库,重新建了一个,浪费了半个小时的时间.</p>
<p>PS.ORACLE 11g好像不支持更改数据库的字符集了...或是我没有找到正确的方法</p>
<p>14.安装完成后,数据库的连接和查询异常之慢,GOOGLE之,然后尝试着把网络的DNS服务器全给删了,解决.</p>
<p>15.两个常用的工具:dbca和netca. <br />
</p>
<p><br />
<br />
&nbsp;</p>
<img src ="http://www.blogjava.net/seesea/aggbug/260400.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/seesea/" target="_blank">SeesSea</a> 2009-03-18 10:52 <a href="http://www.blogjava.net/seesea/archive/2009/03/18/260400.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>