Debian3.1下Oracle XE的安装 作者 blue_stone E-mail: blue_stone@xinhuanet.com Blog: http://bluestone.cublog.cn 版本:v1.0 原始链接: http://www.cublog.cn/u/7667/?u=http://www.cublog.cn/u/7667/showart.php?id=80769 转载请保留作者信息和原始链接. 本文档的最新版本, 可以在原始链接处找到. Oracle Database Express Edition正式版已经提供下载了, 虽然在Oracle XE官方安装文档中说支持Debian, 但官方文档 中的方法无法成功在Debian下安装Oracle XE. 本文描述了Debian 3.1下Oracle XE的安装. 如果您有什么意见或者好的建议, 请 和作者联系. 1 软件下载 oracle xe oracle xe可以从如下链接下载 http://www.oracle.com/technology/software/products/database/xe/index.html 下载需要Oracle Technology Network帐号, Oracle Technology Network帐号可免费注册. oracle xe有两个不同的版本, 一个是通用字符集的版本, 支持中文字符, 内码为AL32UTF8,下载文件为 oracle-xe-univ-10.2.0.1-1.0.i386.rpm, 一种是西欧字符集的版本, 只支持英文, 下载文件为 oracle-xe-10.2.0.1-1.0.i386.rpm . 我们需要下载支持中文字符的版本, 既下载 oracle-xe-univ-10.2.0.1-1.0.i386.rpm. libaio 在Debian3.1中, 并不提供libaio, 所以需要使用unstable或者experimental中的libaio. 如下页面包含了unstable 中libaio的信息: http://packages.debian.org/cgi-bin/download.pl?arch=i386&file=pool%2Fmain%2Fliba%2Flibaio%2Flibaio_0.3.104-1_i386.deb&md5sum=8c0a386e55630b3b1c4f1e1c4f45459a&arch=i386&type=main 可以选择比较近的地址下载libaio, 我下载到的文件是libaio_0.3.104-1_i386.deb 2 安装oracle xe oracle xe只提供了rpm包, 不能直接在debian中使用, 需要使用alien先转换为deb包, 如果alien软件包还没有安装, 请使用 apt-get install alien安装alien. debxe:~# alien -d oracle-xe-univ-10.2.0.1-1.0.i386.rpm oracle-xe-univ_10.2.0.1-2_i386.deb generated -d指转换成deb包格式, 转换过程需要比较长的时间. 转换完成后, 就可以使用dpkg来安装生成的deb包: debxe:~# dpkg -i oracle-xe-univ_10.2.0.1-2_i386.deb Selecting previously deselected package oracle-xe-univ. (Reading database ... 20241 files and directories currently installed.) Unpacking oracle-xe-univ (from oracle-xe-univ_10.2.0.1-2_i386.deb) ... Setting up oracle-xe-univ (10.2.0.1-2) ... 3 oracle xe配置前的准备 3.1 配置内核变量 将如下内容添加到/etc/sysctl.conf kernel.sem = 250 32000 100 128 kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 然后运行sysctl -p使设置生效 debxe:~# sysctl -p kernel.sem = 250 32000 100 128 kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 3.2 配置oracle用户, oracle用户用来运行oracle xe服务器. debxe:~# groupadd dba debxe:~# useradd -g dba -d /home/oracle -s /bin/bash oracle debxe:~# passwd oracle Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully debxe:~# mkdir /home/oracle debxe:~# cp /etc/skel/.bash* /home/oracle debxe:~# chown -R oracle:dba /home/oracle 在/home/oracle/.bash_profile中添加如下内容 ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server ORACLE_SID=XE export ORACLE_HOME export ORACLE_SID export PATH=$ORACLE_HOME/bin:$PATH export LANG=zh_CN.GBK export LC_ALL=zh_CN.GBK export LANGUAGE=zh_CN.GBK export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" 3.3 修改oracle xe安装后的文件属主和文件权限的问题 使用alien转换后的deb包安装Oracle XE /usr/lib/oracle目录下的文件的所有者和所有者组是root, oracle没有写入的权限, 将无法建立数据库, 所以将/usr/lib/oracle目录下的所有文件所有这修改为oracle, 所有者组修改为dba debxe:~# chown -R oracle:dba /usr/lib/oracle /etc/init.d/oracle-xe的权限为444,无法执行, 使用chmod命令赋于所有用户执行权限 debxe:~# chmod a+x /etc/init.d/oracle-xe 3.4 修改xe例程的初始化参数: 修改/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts目录下的 init.ora和initXETemp.ora change init.ora initXETemp.ora 将 sga_target=%sga_target% 修改为 sga_target=150000000 即设置sga_target为150m. 如果运行oracle xe的机器内存比较小, 可适当调小这个值.使用80000000也可以成功建立数据库 将 pga_aggregate_target=%pga_aggregate_target% 修改为 pga_aggregate_target=70000000 即设置pga_aggregate_target为70m. 如果运行oracle xe的机器内存比较小, 可适当调小这个值.使用20000000也可以成功建立 数据库. 3.5 安装libaio debian:~# dpkg -i libaio_0.3.104-1_i386.deb Selecting previously deselected package libaio. (Reading database ... 20245 files and directories currently installed.) Unpacking libaio (from libaio_0.3.104-1_i386.deb) ... Setting up libaio (0.3.104-1) ... 4 配置oracle xe数据库 debxe:~# /etc/init.d/oracle-xe configure Oracle Database 10g Express Edition Configuration ------------------------------------------------- This will configure on-boot properties of Oracle Database 10g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press <Enter> to accept the defaults. Ctrl-C will abort. 指定Oracle Application Express使用的端口, 如果直接按<Enter>则使用默认的8080端口 Specify the HTTP port that will be used for Oracle Application Express [8080]: 指定Oracle listener的端口, 默认端口为1521 Specify a port that will be used for the database listener [1521]: Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after 指定SYS和SYSTEM用户的密码, 输入的密码将不回显, 需要重复输入2遍. initial configuration: Confirm the password: 指定是否在启动时自动启动oracle xe 数据库, 在debian中, 即使输入y, 也不能自动启动, 请参考本文5.2节. Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]: Starting Oracle Net Listener...Done Configuring Database...Done Starting Oracle Database 10g Express Edition Instance...Done Installation Completed Successfully. To access the Database Home Page go to "http://127.0.0.1:8080/apex" 配置完成以后可以在/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/log查看配置记录 debxe:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/log# ls -al total 28 drwxr-xr-x 2 oracle dba 4096 2006-03-03 20:32 . drwxr-xr-x 4 oracle dba 4096 2006-03-03 20:33 .. -rw-r--r-- 1 oracle dba 5269 2006-03-03 20:32 cloneDBCreation.log -rw-r--r-- 1 oracle dba 1369 2006-03-03 20:31 CloneRmanRestore.log -rw-r--r-- 1 oracle dba 1123 2006-03-03 20:33 postDBCreation.log -rw-r--r-- 1 oracle dba 121 2006-03-03 20:32 postScripts.log 使用ps -ef|grep oracle可以看到所有包含oracle的进程 debxe:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/log# ps -ef| grep oracle oracle 884 1 0 20:28 ? 00:00:00 /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/tnslsnr LISTENER -inherit oracle 988 1 0 20:32 ? 00:00:00 xe_pmon_XE oracle 990 1 0 20:32 ? 00:00:00 xe_psp0_XE oracle 992 1 0 20:32 ? 00:00:00 xe_mman_XE oracle 994 1 0 20:32 ? 00:00:00 xe_dbw0_XE oracle 996 1 0 20:32 ? 00:00:00 xe_lgwr_XE oracle 998 1 0 20:32 ? 00:00:00 xe_ckpt_XE oracle 1000 1 0 20:32 ? 00:00:01 xe_smon_XE oracle 1002 1 0 20:32 ? 00:00:00 xe_reco_XE oracle 1004 1 0 20:32 ? 00:00:00 xe_cjq0_XE oracle 1006 1 0 20:32 ? 00:00:01 xe_mmon_XE oracle 1008 1 0 20:32 ? 00:00:00 xe_mmnl_XE oracle 1010 1 0 20:32 ? 00:00:00 xe_d000_XE oracle 1012 1 0 20:32 ? 00:00:00 xe_s000_XE oracle 1014 1 0 20:32 ? 00:00:00 xe_s001_XE oracle 1016 1 0 20:32 ? 00:00:00 xe_s002_XE oracle 1018 1 0 20:32 ? 00:00:00 xe_s003_XE oracle 1022 1 0 20:32 ? 00:00:00 xe_qmnc_XE oracle 1049 1 0 20:33 ? 00:00:00 xe_q000_XE oracle 1051 1 0 20:33 ? 00:00:00 xe_q001_XE 进程号为884的进程就是oracle监听程序的进程, xe_开始的进程就是XE实例的进程. XE实例的跟踪文件放在了/usr/lib/oracle/xe/app/oracle/admin/XE下, /usr/lib/oracle/xe/app/oracle/admin/XE/bdump/alert_XE.log文件中包含了如下行: Database Characterset is AL32UTF8 表明XE实例使用的字符集是AL32UTF8. 配置完成后可以通过http://127.0.0.1:8080/apex访问Oracle Application Express. 5 配置以后的修改 5.1 配置完成后Oracle Application Express 只监听127.0.0.1的8080端口, 不可以在别的机器上通过浏览器访问xe实例, debxe:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/log# netstat -lnp |grep tnslsnr tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 884/tnslsnr tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 884/tnslsnr unix 2 [ ACC ] STREAM LISTENING 4141 884/tnslsnr /var/tmp/.oracle/sEXTPROC_FOR_XE unix 2 [ ACC ] STREAM LISTENING 4143 884/tnslsnr /var/tmp/.oracle/s#884.1 unix 2 [ ACC ] STREAM LISTENING 4150 884/tnslsnr /var/tmp/.oracle/s#884.2 如果需要在别的机器上访问数据库服务器上的xe实例, 可以以system身份登陆xe数据库, 然后运行EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE); debxe:~# su - oracle oracle@debxe:~$ sqlplus SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 3月 3 20:59:18 2006 Copyright (c) 1982, 2005, Oracle. All rights reserved. 请输入用户名: system/oracle 连接到: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE); PL/SQL 过程已成功完成. SQL> exit 从 Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production 断开 其中, oracle是我的xe数据库的system用户的密码. 修改完毕后使用netstat -lnp |grep tnslsnr查看修改的结果 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 884/tnslsnr tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 884/tnslsnr unix 2 [ ACC ] STREAM LISTENING 4141 884/tnslsnr /var/tmp/.oracle/sEXTPROC_FOR_XE unix 2 [ ACC ] STREAM LISTENING 4143 884/tnslsnr /var/tmp/.oracle/s#884.1 unix 2 [ ACC ] STREAM LISTENING 4150 884/tnslsnr /var/tmp/.oracle/s#884.2 5.2 即使在第4步中配置oracle自动启动, 在debian系统中, oracle xe也无法自动启动. 如果需要设置oracle xe自动启动, 可在 在相应的位置建立符号链接, 建立过程如下 debxe:~# cd /etc/rc2.d debxe:/etc/rc2.d# ln -s ../init.d/oracle-xe S80oracle-xe debxe:/etc/rc2.d# cd ../rc3.d/ debxe:/etc/rc3.d# ln -s ../init.d/oracle-xe S80oracle-xe debxe:/etc/rc3.d# cd ../rc4.d/ debxe:/etc/rc4.d# ln -s ../init.d/oracle-xe S80oracle-xe debxe:/etc/rc4.d# cd ../rc5.d/ debxe:/etc/rc5.d# ln -s ../init.d/oracle-xe S80oracle-xe debxe:/etc/rc5.d# cd ../rc6.d/ debxe:/etc/rc6.d# ln -s ../init.d/oracle-xe K20oracle-xe debxe:/etc/rc6.d# cd ../rc0.d debxe:/etc/rc0.d# ln -s ../init.d/oracle-xe K20oracle-xe debxe:/etc/rc0.d# cd ../rc1.d debxe:/etc/rc1.d# ln -s ../init.d/oracle-xe K20oracle-xe debxe:/etc/rc1.d# 6 版本变更 v0.1 2006年3月1日, 初稿. v1.0 2006年3月3日, 第一版, 按照文档重新做了1遍, 修改不分错误, 增加了更多阅读部分. 7 更多阅读 Oracle Database Express Edition 10g Release 2 (10.2) Document Library http://www.oracle.com/pls/xe102/homepage Oracle® Database Express Edition Installation Guide 10g Release 2 (10.2) for Linux http://download-west.oracle.com/docs/cd/B25329_01/doc/install.102/b25144/toc.htm Oracle® Database Express Edition 2 Day DBA 10g Release 2 (10.2) http://download-west.oracle.com/docs/cd/B25329_01/doc/admin.102/b25107/toc.htm -- ==================== 快乐着你的快乐! 幸福着你的幸福!! ====================
Attachment:
pgp7EeT6BmJbR.pgp
Description: PGP signature