在64位Open SUSE 11.3 中安装ORACLE 11G
参考:
http://axhtszcx.blog.163.com/blog/static/56679539201081353348276/
对于在64位Open SUSE 11.3 中安装ORACLE 11G本人参考了以上链接的做法,但在关键的地方均有做针对性修改,以下均是本人安装的具体步骤,供大家分享学习:
1. 首先是硬件需求:
安装Oracle Database 11g release1的内存需求:
至少1GB物理内存
可用下列命令检查物理内存大小:
# grep MemTotal /proc/meminfo
内存大小与配置交换空间的关系:
内存 |
需要的交换空间 |
257 MB < 内存 < 512 MB |
2倍内存大小 |
513 MB < 内存 < 2048 MB |
1.5倍内存大小 |
2049 MB < 内存 < 8192 MB |
与内存大小相同 |
可用下列命令检查配置的交换空间大小:
# grep SwapTotal /proc/meminfo
使用下列命令可以确认可用的内存和交换空间:
# free
经过查询可以看到内存基本满足要求,而且内存可以在虚拟机下调整,但是交换空间小了,按内存1G估算,交换空间设置为1.5G比较合适。(这要根据你用的是什么包而定,原则是:如果你下载的是oracle 11g的zip包,然后大小时2.1G,那么我建议你将swap的分区大小调成2.5G左右)
hawkzy@hawkzy:~> grep MemTotal /proc/meminfo
MemTotal: 909996 kB
hawkzy@hawkzy:~> grep SwapTotal /proc/meminfo
SwapTotal: 763048 kB
下面准备增加交换空间。
使用下面的命令可以查到跟swap相关的资料:
apropos ‘swap’
返回结果如下:
hawkzy@hawkzy:~> apropos 'swap'
glXSwapBuffers (3gl) - exchange front and back buffers
mkswap (8) - set up a Linux swap area
swab (3) - swap adjacent bytes
swab (3p) - swap bytes
swap_buf_le16 (9) - swap halves of 16-bit words in place
swapcontext (3) - manipulate user context
swapcontext (3p) - manipulate user contexts
swapoff (2) - start/stop swapping to file/device
swapoff (8) - enable/disable devices and files for paging and swapping
swapon (2) - start/stop swapping to file/device
swapon (8) - enable/disable devices and files for paging and swapping
swappo (1) - swap msgid and msgstr fields in a PO file
TIFFIsByteSwapped (3tiff) [TIFFquery] - query routines
TIFFswab (3tiff) - byte- and bit-swapping routines
XdbeSwapBuffers (3) - swaps front and back DBE buffers.
我们可以看到mkswap是用于设置Linux交换页,那么继续查找mkswap帮助:
man mkswap
在man帮助页中注意到:
Presently, Linux allows 32 swap areas (this was 8 before Linux 2.4.10).
The areas in use can be seen in the file /proc/swaps (since 2.1.25).
即,当前Linux允许多达32个交换空间,交换空间的设置可以在文件/proc/swaps中看到。
继续查询帮助可以看到,为了设置交换页,在使用命令mkswap初始化交换页前,应使用如下命令:
# dd if=/dev/zero of=swapfile bs=1024 count=65536
仔细阅读完帮助后,我们开始设置交换空间。
以下的操作都要在root用户下进行:
hawkzy@hawkzy:~> su -
Password:
首先先建立一个分区/home/swap,如前帮助中所述:
hawkzy:~ # dd if=/dev/zero of=/home/swap bs=1024 count=768000
768000+0 records in
768000+0 records out
786432000 bytes (786 MB) copied, 26.1333 s, 30.1 MB/s
设置交换空间:
hawkzy:~ # /sbin/mkswap /home/swap
Setting up swapspace version 1, size = 786427 kB
no label, UUID=a224db83-b072-405f-a50d-961ac2df5ba0
使临时交换空间生效:
hawkzy:~ # /sbin/swapon /home/swap
观察交换空间是否增加为1.5G,如下,已经生效:
hawkzy:~ # free
total used free shared buffers cached
Mem: 909996 896516 13480 0 1624 743232
-/+ buffers/cache: 151660 758336
Swap: 1531040 236 1530804
为了在系统重启后,交换空间任然能够生效,准备修改/etc/fstab文件:
hawkzy:~ # cat /etc/fstab
/dev/sda2 / ext3 acl,user_xattr 1 1
/dev/sda3 /home ext3 acl,user_xattr 1 2
/dev/sda1 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
hawkzy:~ # vim /etc/fstab
在/etc/fstab第3行后增加:
/home/swap swap swap defaults 0 0
修改后查询:
hawkzy:~ # cat /etc/fstab
/dev/sda2 / ext3 acl,user_xattr 1 1
/dev/sda3 /home ext3 acl,user_xattr 1 2
/dev/sda1 swap swap defaults 0 0
/home/swap swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
硬盘空间需求:
/tmp文件夹需要400MB空间
使用如下命令检查/tmp文件夹的可用空间容量:
# df -k /tmp
需要1.5~3.5G硬盘空间,具体大小取决于安装类型:
安装类型 |
文件大小(GB) |
企业版 |
3.47 |
标准版 |
3.22 |
自定义版 |
3.37 |
企业版和标准版需要1.5 GB 数据文件的硬盘空间。另外,自定义DB需要1.81 GB空间。
使用如下命令查看系统空间:
# df -k
查询结果如下,如果硬盘空间不够,可以在虚拟机中增加:
hawkzy:~ # df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 6111520 5301396 499668 92% /
udev 454996 52 454944 1% /dev
/dev/sda3 8617868 937260 7242840 12% /home
/dev/sr0 1860928 1860928 0 100% /media/Oracle 11g linux
2. 现在开始检查软件需求。
操作系统需求:
SUSE Enterprise Linux 10.0
Kernel需求:
对于SUSE 10:2.6.16.21
使用如下命令检查Kernel
uname -r
hawkzy:~ # uname -r
2.6.22.5-31-default
安装包需求:
对于SUSE 10:
binutils-2.16.91.0.5
compat-libstdc++-5.0.7
glibc-2.4-31.2
glibc-devel-2.4-31.2
gcc-4.1.0
ksh-93r-12.9
libaio-0.3.104
libaio-devel-0.3.104
libelf-0.8.5
libgcc-4.1.0
libstdc++-4.1.0
libstdc++-devel-4.1.0
make-3.80
sysstat-6.0.2
unixODBC-2.2.11
unixODBC-devel-2.2.11
使用如下命令检查是否安装了上述包文件:
# rpm -q package_name
安装这些包的方法可以通过网络配备的方法
#zypper se package_name
在列表中找到对应的package后
#sypper in package_name
也可以通过YaST检查:打开控制中心,点击YaST菜单,输入管理员命令后,在新打开的窗口中选择Add-On Product,如果虚拟机没有加载Open SUSE安装光盘,此时需要加载,然后在弹出的窗口Package Selector - YaST中,查找并安装上述缺少的包文件。
有些包文件名可能有细微差别,如:
libelf0(0.8.9)
libelf1(0.128)
libgcc42(4.2.1)
libstdc++42(4.2.1)
又或者可以通过手动下载的方法
在下面的网址中寻找Open SUSE安装光盘中没有的补丁包:
http://software.opensuse.org/search
安装下载下来的补丁包unixODBC-devel-2.2.12-55.x86_64.rpm:
hawkzy:~ # rpm -ihv /home/hawkzy/temp/unixODBC-devel-2.2.12-55.x86_64.rpm
Preparing... ########################################### [100%]
package unixODBC-devel-2.2.12-55 is intended for a x86_64 architecture
3. 配置系统参数,安装Oracle
调整内核参数的最大共享内存,在文件/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 = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
然后执行#sysctl –p
建立Oracle用户及组。以root用户登录,执行命令:
hawkzy:~ #groupadd dba
hawkzy:~ #useradd -g dba -m Oracle
hawkzy:~ #passwd Oracle
hawkzy:~ #mkdir /home/Oracle/11g /home/Oracle/orabase
hawkzy:~ #chown -R Oracle:dba /home/Oracle/11g /home/Oracle/orabase
以Oracle用户身份登录
操作命令如下:
hawkzy:~ # su - Oracle
Oracle@hawkzy:~> pwd
/home/Oracle
修改.bashrc文件,增加如下内容:
export ORACLE_SID=orcl1
export ORACLE_HOME=/home/Oracle/11g
export ORACLE_BASE=/home/Oracle/orabase
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/oracm/lib:$ORACLE_HOME/lib:.
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin:$ORACLE_HOME/bin:.:$PATH
由于/tmp空间不足400M,因此加入下参数,另外指定临时文件夹(文件夹/home/Oracle/temp必须提前建立好):
TMP=/home/Oracle/temp
TMPDIR=/home/Oracle/temp
export TMP TMPDIR
Oracle@hawkzy:~> ls -al
total 96
drwxr-xr-x 8 Oracle dba 4096 2009-04-02 21:47 .
drwxr-xr-x 5 root root 4096 2009-04-02 18:02 ..
-rw------- 1 Oracle dba 0 2009-04-02 16:28 .bash_history
-rw-r--r-- 1 Oracle dba 1177 2009-04-02 16:28 .bashrc
drwxr-xr-x 2 Oracle dba 4096 2009-04-02 16:28 bin
drwx------ 2 Oracle dba 4096 2009-04-02 16:28 Documents
-rw-r--r-- 1 Oracle dba 208 2009-04-02 16:28 .dvipsrc
-rw-r--r-- 1 Oracle dba 1637 2009-04-02 16:28 .emacs
-rw-r--r-- 1 Oracle dba 1332 2009-04-02 16:28 .exrc
drwxr-xr-x 2 Oracle dba 4096 2009-04-02 16:28 .fonts
-rw-r--r-- 1 Oracle dba 861 2009-04-02 16:28 .inputrc
-rw-r--r-- 1 Oracle dba 164 2009-04-02 16:28 .kermrc
drwxr-xr-x 2 Oracle dba 4096 2009-04-02 16:28 .mozilla
-rw-r--r-- 1 Oracle dba 6043 2009-04-02 16:28 .muttrc
-rw-r--r-- 1 Oracle dba 925 2009-04-02 16:28 .profile
drwxr-xr-x 2 Oracle dba 4096 2009-04-02 16:28 public_html
-rw-r--r-- 1 Oracle dba 311 2009-04-02 16:28 .urlview
-rw------- 1 Oracle dba 51 2009-04-02 21:47 .xauthO5kI6s
-rw-r--r-- 1 Oracle dba 7913 2009-04-02 16:28 .xcoralrc
drwxr-xr-x 2 Oracle dba 4096 2009-04-02 16:28 .xemacs
-rw-r--r-- 1 Oracle dba 1940 2009-04-02 16:28 .xim.template
-rwxr-xr-x 1 Oracle dba 1365 2009-04-02 16:28 .xinitrc.template
-rw-r--r-- 1 Oracle dba 119 2009-04-02 16:28 .xtalkrc
Oracle@hawkzy:~> vim .bashrc
Oracle@hawkzy:~> cat .bashrc
export ORACLE_SID=orcl1
export ORACLE_HOME=/home/Oracle/11g
export ORACLE_BASE=/home/Oracle/orabase
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib:$ORACLE_HOME/oracm/lib:$ORACLE_HOME/lib:.
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin:$ORACLE_HOME/bin:.:$PATH
export LIBXCB_ALLOW_SLOPPY_LOCK=true
TMP=/home/Oracle/temp
TMPDIR=/home/Oracle/temp
export TMP TMPDIR
DISPLAY=:0.0; export DISPLAY
test -s ~/.alias && . ~/.alias || true
以root用户身份登录,运行init 5切换到启动级别5,准备安装Oracle:
Oracle@hawkzy:~> su - root
Password:
hawkzy:~ # init 5
要是不能装成图形界面的话请安装gnome包
在VMware菜单里依次点击VM->Removable Devices->CD-ROM->Edit,更换光驱镜像为Oracle 11g。需要将其拷贝到硬盘中并修改为Oracle用户属性.
要是下载的zip包,将zip包解压到一目录下然后进入该目录.
建议拷贝过来后全部改为可读写执行属性。
Oracle@hawkzy:/home/hawkzy/temp> chmod +rwx -R *
执行命令安装Oracle:
Oracle@hawkzy:/home/hawkzy/temp> runInstaller
Starting Oracle Universal Installer...
在安装过程中可能出现如下提示:
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2009-04-03_12-12-54AM. Please wait ...
Oracle@hawkzy:/home/hawkzy/temp> java: xcb_xlib.c:52: xcb_xlib_unlock: Assertion `c->xlib.lock' failed.
在http://en.opensuse.org/Xlib.lock我们可以看到如下解决方法:
1. 在线升级Open SUSE 10.3
2. 在Oracle用户的配置脚本/home/Oracle/.bashrc里增加
export LIBXCB_ALLOW_SLOPPY_LOCK=true
修改后再次执行runInstaller,可顺利安装。
如果在安装中出现如下错误信息:
Checking monitor: must be configured to display at least 256 colors
>>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<<
尝试执行命令xclock,如果不成功,应修改Oracle用户的.bashrc文件,增加如下命令:
DISPLAY=127.0.0.1:0.0; export DISPLAY
然后执行命令source ~Oracle/.bashrc加载配置信息,重新尝试xclock。
如果还不成功,建议重新打开一个终端,以root登录,执行命令:
hawkzy:~ # xhost +
hawkzy:~ # xclock
如果还是不行的话,请安装gnome系列的包。
如果能够打开时钟,而以Oracle身份仍然不能打开xclock,说明显示root用户的显示设置是正确的,而Oracle用户的设置可能有问题,这时只需以root身份执行env查看DISPLAY的设置,照搬到Oracle用户,一般就可以顺利通过Oracle配置检测了。
在弹出的第一个窗口中,注意将全局数据库名(Global Datebase Name)栏修改为orcl1
图形界面的安装在很多资料都有述及,也比较简单,这里不再重复,可以在Oracle安装手册或者网上查找相关资料。
4. 安装完成后检查Oracle进程是否正常启动:
hawkzy@hawkzy:/home> ps -ef | grep ora_
Oracle 9945 1 1 12:45 ? 00:00:42 ora_pmon_orcl1
Oracle 9950 1 0 12:45 ? 00:00:00 ora_vktm_orcl1
Oracle 9962 1 0 12:45 ? 00:00:00 ora_diag_orcl1
Oracle 9970 1 0 12:45 ? 00:00:00 ora_dbrm_orcl1
Oracle 9978 1 0 12:45 ? 00:00:00 ora_psp0_orcl1
Oracle 9990 1 0 12:45 ? 00:00:01 ora_dia0_orcl1
Oracle 9995 1 0 12:45 ? 00:00:06 ora_mman_orcl1
Oracle 10000 1 0 12:45 ? 00:00:01 ora_dbw0_orcl1
Oracle 10005 1 0 12:45 ? 00:00:03 ora_lgwr_orcl1
Oracle 10010 1 0 12:45 ? 00:00:03 ora_ckpt_orcl1
Oracle 10015 1 0 12:45 ? 00:00:04 ora_smon_orcl1
Oracle 10021 1 0 12:45 ? 00:00:00 ora_reco_orcl1
Oracle 10034 1 0 12:45 ? 00:00:03 ora_mmon_orcl1
Oracle 10043 1 0 12:45 ? 00:00:01 ora_mmnl_orcl1
Oracle 10048 1 0 12:45 ? 00:00:00 ora_d000_orcl1
Oracle 10053 1 0 12:45 ? 00:00:00 ora_s000_orcl1
Oracle 10170 1 0 12:45 ? 00:00:00 ora_smco_orcl1
Oracle 10178 1 0 12:45 ? 00:00:00 ora_fbda_orcl1
Oracle 10188 1 0 12:45 ? 00:00:00 ora_qmnc_orcl1
Oracle 10212 1 0 12:45 ? 00:00:00 ora_w000_orcl1
Oracle 10293 1 0 12:45 ? 00:00:00 ora_q000_orcl1
Oracle 10598 1 0 12:45 ? 00:00:01 ora_cjq0_orcl1
Oracle 19066 1 2 13:50 ? 00:00:00 ora_j000_orcl1
hawkzy 19153 9760 0 13:50 pts/1 00:00:00 grep ora_
Oracle 21153 1 0 13:05 ? 00:00:00 ora_q002_orcl1
以sqlplus工具建立一个具有dba权限的名字和密码均为lion的用户:
Oracle@hawkzy:~> sqlplus /nolog
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Apr 3 14:07:50 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL>startup
故障现象:ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initorcl10g.ora'
原理:在oracle9i和oracle10g中,数据库默认将使用spfile启动数据库,如果spfile不存在,则就会出现上述错误。
www.2cto.com
解决办法:
方法一:将$ORACLE_BASE/admin/orcl/pfile目录下的init.ora.0212012125517形式的文件copy到$ORACLE_HOME/dbs目录下initoracl.ora即可。(注:initoracl.ora中的oracl为你的实例名 ORACLE_SID,这里我的SID为:orcl10g)
方法二:将$ORACLE_HOME/dbs目录下spflieoracl.ora改名为spfileorcl10g.ora即可。(注:spfileorcl10g.ora中的orcl10g为环境变量中设置的SID,我的是orcl10g)
SQL> connect /as sysdba
Connected.
SQL> create user lion identified by "lion";
User created.
SQL> grant dba to lion with admin option;
Grant succeeded.
SQL> grant create any table to lion with admin option;
Grant succeeded.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
以用户名lion及密码lion登录数据库:
Oracle@hawkzy:~> sqlplus lion/lion
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Apr 3 14:13:09 2009
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> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
关闭数据库:
Oracle@hawkzy:~> sqlplus /nolog
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Apr 3 14:15:15 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
关闭监听:
Oracle@hawkzy:~> lsnrctl stop
LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 03-APR-2009 14:16:27
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
启动数据库:
Oracle@hawkzy:~> sqlplus /nolog
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Apr 3 14:21:39 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL> connect /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 401752064 bytes
Fixed Size 1300184 bytes
Variable Size 159385896 bytes
Database Buffers 234881024 bytes
Redo Buffers 6184960 bytes
Database mounted.
Database opened.
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
启动监听:
Oracle@hawkzy:~> lsnrctl start
LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 03-APR-2009 14:28:52
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Starting /home/Oracle/11g/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.1.0.6.0 - Production
System parameter file is /home/Oracle/11g/network/admin/listener.ora
Log messages written to /home/Oracle/orabase/diag/tnslsnr/hawkzy/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hawkzy.vmopensuse)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.1.0.6.0 - Production
Start Date 03-APR-2009 14:28:52
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/Oracle/11g/network/admin/listener.ora
Listener Log File /home/Oracle/orabase/diag/tnslsnr/hawkzy/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hawkzy.vmopensuse)(PORT=1521)))
The listener supports no services
The command completed successfully
以TCP网络连接方式连接到数据库:
Oracle@hawkzy:~> sqlplus lion/lion@orcl1
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Apr 3 14:29:47 2009
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> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
至此,Oracle安装已经完成。