Oracle Express Edition安装

Oracle 11g XE 是 Oracle 数据库的免费版本,支持标准版的大部分功能,11g XE 提供 Windows 和 Linux 版本(有32位和64位之分)。 Oracle XE版本也称”快捷版本“,是给个人学习、熟悉Oracle的简化版,可能是由于标准版oracle的安装(在linux、unix下)非常复杂,所以,oracle公司在最近才发布了这个快捷版本。

Oracle XE做为免费的 Oracle 数据库版本, 主要的限制是:

  • 最大数据库大小为 11 GB;
  • 可使用的最大内存是 1G;
  • 一台机器上只能安装一个 XE 实例 ;
  • XE 只能使用单 CPU

接下来,介绍在centos6(64位)上如何安装Oracle XE。

一下载Oracle XE

1
wget http://download.oracle.com/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip

二安装依赖

1
yum install libaio libaio-devel bc -y

三安装

以下操作,都是用root

解压、检测

1
2
3
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip  
cd Disk1
rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm

安装时会对系统进行检测,最好内存有1G,SWAP要求是内存的2倍。检测结果如下:

[root@server01 Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing… ########################################### [100%]
1:oracle-xe ########################################### [100%]
Executing post-install steps…

You must run ‘/etc/init.d/oracle-xe configure’ as the root user to configure the database.

根据提示安装,但如果tmpfs小于2G,会报错:

Database Configuration failed. Look into /u01/app/oracle/product/11.2.0/xe/config/log for details

1、修改/etc/fstab文件

1
2
3
4
5
vim /etc/fstab
将:
tmpfs /dev/shm tmpfs defaults 0 0
改为:
tmpfs /dev/shm tmpfs defaults,size=2048M 0 0

2、重新加载tmpfs

1
2
umount /dev/shm
mount /dev/shm

3、检查

1
2
3
df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
none 2.0G 243M 1.8G 12% /dev/shm

根据提示安装XE

1
[root@server01 Disk1]# /etc/init.d/oracle-xe configure

之后,会引导用户进行简单的几项设置:

Oracle Database 11g Express Edition Configuration
-————————————————
This will configure on-boot properties of Oracle Database 11g 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 to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:8081

Specify a port that will be used for the database listener [1521]: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
initial configuration:
Confirm the password:

Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y

Starting Oracle Net Listener…Done
Configuring database…Done
Starting Oracle Database 11g Express Edition instance…Done
Installation completed successfully.

输入的四项内容是:

  • http访问时的端口
  • 数据库的监听端口
  • SYS和SYSTEM用户的密码
  • 是否开机启动(并没有开机启动,可能还有地方要设置)。

安装完成后:

  • 会自动建立一个名为oracle的用户,家目录/u01/app/oracle。
  • 会建立dba组,oracle用户属于这个组。
  • 会自动生成一个数据库实例,名为XE。/u01/app/oracle/product/11.2.0/xe/dbs/spfileXE.ora

设置oracle的环境变量

使用oracle用户

vim /etc/profile

加入:

1
2
3
4
5
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`

之后,注销用户,使用oracle用户重新登录,就可以用sqlplus登录oracle,进而操作。

sqlplus / as sysdba