Ubuntu 下安装 oracle
Oracle 11 的下载地址:http://www.oracle.com/technology/software/products/database/oracle11g/111060_linuxsoft.html
在Ubuntu 8.04 LTS上顺利安装Oracle 11G.下面说说大概的步骤.
(
?first , let root login , to do this:
sudo passwd root
System->Adminstrator->Login Window -> Security -> allow local system administrator login? Checked!
newsea.
)
?
1.确保安装了以下程序:
sudo apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm
(mybe return a error code ,but can continu ; newsea.)
2.
cd /bin
ln -sf bash /bin/sh
3.增加用户和组
addgroup oinstall
addgroup dba
addgroup nobody
useradd -g oinstall -G dba -p passwd -d /home/oracle -s /bin/bash oracle
usermod -g nobody nobody
4.
mkdir /home/oracle
chown -R oracle:dba /home/oracle
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
5.
mkdir /etc/rc.d
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
mkdir -p /opt/ora11
chown -R oracle:dba /opt
6.编辑/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
7.编辑/etc/security/limits.conf,增加以下内容:
oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
8.编辑/etc/pam.d/login,增加以下内容:
session required /lib/security/pam_limits.so
session required pam_limits.so
9.执行:
sysctl -p
10.
su - oracle
以上命令需以root用户执行,接下来切换至oracle用户.
11.切换至安装目录,开始安装.我选择了英语作为安装时显示的语言.
export LANG=en_CN
./runInstaller
(
出错:Exception in thread "main" java.lang.InternalError:can't connect to x11 window server using "localhost:0.0" at
解决 : sudo xhost +
如果显示值不正确,把 系统 ->系统管理 ->登录窗口->远程->样式: 与本地相同。export DISPLAY = 127.0.0.1:0.0 (觉着这一步最管事。) 即可 。
newsea.
)
(
选高级,路径用默认:/home/oracle/oraInventory ,指定组名 dba , 企业版? , 自定义,OracleBase:/home/oracle/app/oracle, Oracle Name : OraDb11g_home1 ,Oracle Path : /home/oracle/app/oracle/product/11.1.0/db_1 ,全选, 全选,默认选中OSDBA Group : dba , osoper group : oinstall , osasm group :oinstall ,选中 create database ,。net configuration assistant : default check,LISTENER ,TCP ,1521 。 Database configureation assistant :
customer, golbal database name : orcl ,SID: orcl , password: 选同样的密码: newsea . 以后默认选: file system , 内存自定义: 160 + 30 .
)
12.安装过程中提示运行以下两个脚本:
orainstRoot.sh
root.sh
12.安装过程中检测到系统未装有GLIBC环境,忽略后,未发现对安装和运行有多大影响.
13.切记,安装时选择自定义,并且选择数据库的字符集为 ZHS16GBK!
因为忘记了这个选项,我只好删掉数据库,重新建了一个,浪费了半个小时的时间.
PS.ORACLE 11g好像不支持更改数据库的字符集了...或是我没有找到正确的方法
14.安装完成后,数据库的连接和查询异常之慢,GOOGLE之,然后尝试着把网络的DNS服务器全给删了,解决.
15.两个常用的工具:dbca和netca.
原文:http://www.linuxidc.com/Linux/2008-06/13855.htm
?
?
------------------------------
后记
Oracle 11.2 安装界面与 11.1 不同, 但步骤大同小异.
可以在普通用户下安装 . 而不 一定非要建 oracle? 帐号.http://meteoren.iteye.com/blog/640894 , 我建了oracle 帐号, 把我的帐号添加到了 oinstall ,dba 组 (用 Kuser ),但是在普通帐号上安装的数据库软件(无实例), 安装过程报错, 忽略后,成功.
如果不指定jre , 中文字体显示不出来, 指定 sun 的 jre ,就可以.
./runInstaller -jreLoc /usr/lib/jvm/java-6-sun/jre
?
?
?
附另一种安装方法:
user@hardy:~$ xhost +127.0.0.1127.0.0.1 being added to access control listStep 4
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注: 如果用新用户 oracle 登录的话, 这里可能会出现不能使用 sudo 命令的时候,用下面几步实现:?1>、进入超级用户模式。也就是输入"su?-",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用户登录)????2>、添加文件的写权限。也就是输入命令"chmod?u+w?/etc/sudoers"。????3>、编辑/etc/sudoers文件。也就是输入命令"vim?/etc/sudoers",输入"i"进入编辑模式,找到这一行:"root?ALL=(ALL)?ALL"在起下面添加"xxx?ALL=(ALL)?ALL"(这里的xxx是你的用户名),然后保存(就是先摁一?下Esc键,然后输入":wq")退出。????4>、最后去掉文件的写权限。也就是输入命令"chmod?u-w?/etc/sudoers"。Step 5
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用dash作为默认的shell,看这个:a detailed explanation of why dash is the default system shell 。
Step 701 root@hardy:/bin# cd02 root@hardy:~# pwd /root04 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 nobody14 root@hardy:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle15 root@hardy:~# passwd -l oracle Password changed.17 root@hardy:~# mkdir /home/oracle18 root@hardy:~# chown -R oracle:dba /home/oracle19 root@hardy:~# ln -s /usr/bin/awk /bin/awk20 root@hardy:~# ln -s /usr/bin/rpm /bin/rpm21 root@hardy:~# ln -s /usr/bin/basename /bin/basename22 root@hardy:~# mkdir /etc/rc.d23 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 ; done24 root@hardy:~# mkdir -p /u01/app/oracle25 root@hardy:~# chown -R oracle:dba /u0126 root@hardy:~#Lines 04-12: 增加我们需要的用户和组Line 13: 让nobody用户的组变为nobody,这样Oracle的安装程序不会出问题。Ubuntu默认nobody的组是nogroup。Lines 14-18: 创建一个oracle用户,并锁定用户,以阻止别人通过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 = 65535kernel.shmall = 2097152kernel.shmmax = 2147483648kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 1024 65535net.core.rmem_default = 1048576net.core.rmem_max = 1048576net.core.wmem_default = 262144net.core.wmem_max = 262144再增加下面这些到
/etc/security/limits.conf文件末尾:oracle soft nproc 2047oracle hard nproc 16383oracle soft nofile 1023oracle hard nofile 65535为了强制使用刚才我们增加的东西,我们再增加下面这些到/etc/pam.d/login文件末尾:session required /lib/security/pam_limits.sosession required pam_limits.so然后通过命令:
sysctl -p 让刚才增加的东西生效:root@hardy:~# sysctl -pkernel.printk = 4 4 1 7kernel.maps_protect = 1fs.inotify.max_user_watches = 524288vm.mmap_min_addr = 65536net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.all.rp_filter = 1fs.file-max = 65535kernel.shmall = 2097152kernel.shmmax = 2147483648kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 1024 65535net.core.rmem_default = 1048576net.core.rmem_max = 1048576net.core.wmem_default = 262144net.core.wmem_max = 262144root@hardy:~#Step 9
root@hardy:~# cd /home/oracleroot@hardy:/home/oracle# chown -R oracle:dba installroot@hardy:/home/oracle# su - oracleYour account has expired; please contact your system administratorsu: User account has expired(Ignored)oracle@hardy:~$ export DISPLAY=127.0.0.1:0.0oracle@hardy:~$ pwd/home/oracleoracle@hardy:~$ ls -ltotal 4drwxr-xr-x 6 oracle dba 4096 2007-09-18 18:50 installoracle@hardy:~$ cd installoracle@hardy:~/install$ ls -ltotal 28drwxr-xr-x 11 oracle dba 4096 2007-08-06 16:02 docdrwxr-xr-x 5 oracle dba 4096 2007-08-03 13:28 installdrwxr-xr-x 2 oracle dba 4096 2007-09-18 18:52 response-rwxr-xr-x 1 oracle dba 2911 2007-08-03 13:28 runInstallerdrwxr-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.htmloracle@hardy:~/install$ ./runInstaller -ignoreSysPrereqs输入完上面命令后,就进入了Oracle 的同一安装程序了(OUI),不要急,继续按照本文一步一步的通过安装:
点(Next)下一步。
修改“Specify Operating System group name:”为:"dba",然后点"Next".
按照上图设置,点下一步。
选择"Enterprise Edition",然后下一步。
安图设置,下一步。
继续下一步。
等待系统检查,不要担心有错误和警告。
将检查到的所有非“Succeeded”的都打上勾,下一步。
选择“Install Software Only”,等装完以后再通过dbca装数据库,下一步。你也可以在这一步选"Create a Database"来安装数据库。
将所有组都设为:dba,下一步。
现在可以点“Install”了:)这个过程会等很久,而且其中系统会变慢,所以你最好拿本书在旁边,喝杯咖啡。
到了这一步不要记着点“OK”,需要做下面操作:(另起一个终端,用sudo su - 转为超级用户)
root@hardy:~# /u01/app/oraInventory/orainstRoot.shChanging permissions of /u01/app/oraInventory to 770.Changing groupname of /u01/app/oraInventory to dba.The execution of the script is completeroot@hardy:~# /u01/app/oracle/product/11.1.0/db_1/root.shRunning 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_1Enter 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 byDatabase Configuration Assistant when a database is createdFinished running generic part of root.sh script.Now product-specific root actions will be performed.Finished product-specific root actions.root@hardy:~#好了,这个完成后可以点“OK”了。
/etc/profile文件中加入下面几句:export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1export 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/oratabexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1export ORACLE_OWNR=oracleexport PATH=$PATH:$ORACLE_HOME/binif [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]then echo "Oracle startup: cannot start" exit 1ficase "$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 1esacexit 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/oracledbroot@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@hardy:~$ export ORACLE_SID=heronoracle@hardy:~$ sqlplus '/as sysdba'SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 5 02:39:27 2008Copyright (c) 1982, 2007, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL>如果你看到了上面的结果,证明你的oracle安装成功了。