1.确定系统版本为CentOS
2.下载rpm格式的oracle XE压缩包 下载地址
里面包含windows 32、64位,Linux。选择适用于Linux系统的即可
3.然后把本地的《oracle-xe-11.2.0-1.0.x86_64.rpm.zip》上传到服务器/home/centos目录下
这里我选用的是FlashFxp
4.之后通过shell或者SecureCRT登陆服务器,解压刚刚上传的压缩包,然后输入以下命令进行安装
[root@VM_0_13_centos ~]# cd /home/centos/
[root@VM_0_13_centos centos]# ll
total 308796
-rw-r--r-- 1 root root 315891481 May 5 22:43 oracle-xe-11.2.0-1.0.x86_64.rpm.zip
[root@VM_0_13_centos centos]# unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
Archive: oracle-xe-11.2.0-1.0.x86_64.rpm.zip
creating: Disk1/
creating: Disk1/upgrade/
inflating: Disk1/upgrade/gen_inst.sql
creating: Disk1/response/
inflating: Disk1/response/xe.rsp
inflating: Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm
[root@VM_0_13_centos centos]# groupadd oinstall
[root@VM_0_13_centos centos]# groupadd dba
[root@VM_0_13_centos centos]# useradd -m -g oinstall -G dba oracle
[root@VM_0_13_centos centos]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
[root@VM_0_13_centos centos]# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
Sorry, passwords do not match.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@VM_0_13_centos centos]# mkdir u01
[root@VM_0_13_centos centos]# cd u01/
[root@VM_0_13_centos u01]# mkdir app
[root@VM_0_13_centos u01]# cd ./
[root@VM_0_13_centos centos]# chown -R oracle:oinstall u01/app
[root@VM_0_13_centos centos]# chmod -R 775 u01/app
[root@VM_0_13_centos centos]# cd Disk1
[root@VM_0_13_centos Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing... ################################# [100%]
This system does not meet the minimum requirements for swap space. Based on
the amount of physical memory available on the system, Oracle Database 11g
Express Edition requires 2048 MB of swap space. This system has 0 MB
of swap space. Configure more swap space on the system and retry the
installation.
error: %pre(oracle-xe-11.2.0-1.0.x86_64) scriptlet failed, exit status 1
error: oracle-xe-11.2.0-1.0.x86_64: install failed
5.解决安装过程中出现的错误,原因是:交换空间不足
Oracle Database 11g
Express Edition requires 2048 MB of swap space. This system has 0 MB
of swap space.
需要2048MB,但是系统的只有0MB,那么就要为系统添加
[root@VM_0_13_centos ~]# free -m
total used free shared buff/cache available
Mem: 1839 95 882 0 861 1586
Swap: 0 0 0
[root@VM_0_13_centos ~]# su - root
Last login: Sun May 6 11:31:55 CST 2018 from 219.157.149.127 on pts/3
[root@VM_0_13_centos ~]# dd if=/dev/zero of=/swapfile bs=2048 count=2097152
2097152+0 records in
2097152+0 records out
4294967296 bytes (4.3 GB) copied, 151.533 s, 28.3 MB/s
[root@VM_0_13_centos ~]# mkswap /swapfile
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=ae75d34f-637b-4b58-82e6-98794313fb98
[root@VM_0_13_centos ~]# swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
[root@VM_0_13_centos ~]# cp /etc/fstab /etc/fstab.backup_$(date +%N)
[root@VM_0_13_centos ~]# echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
[root@VM_0_13_centos ~]# chown root:root /swapfile
[root@VM_0_13_centos ~]# chmod 0600 /swapfile
[root@VM_0_13_centos ~]# swapon -a
[root@VM_0_13_centos ~]# swapon -s
Filename Type Size Used Priority
/swapfile file 4194300 0 -1
6.接下来继续刚刚的安装步骤
[root@VM_0_13_centos Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing... ################################# [100%]
/var/tmp/rpm-tmp.iRA9rd: line 271: [: 18446744073692774399: integer expression expected
Updating / installing...
1:oracle-xe-11.2.0-1.0 ################################# [100%]
Executing post-install steps...
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
[root@VM_0_13_centos 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 <Enter> to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:8080
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.
7.安装完成后,修改.bash_profile**配置文件,添加以下内容**
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=dbserver; export ORACLE_HOSTNAME
ORACLE_UNQNAME=ORADB; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; export ORACLE_HOME
ORACLE_SID=ORADB; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
具体命令如下:
[root@VM_0_13_centos Disk1]# su oracle
[oracle@VM_0_13_centos Disk1]$ cd
[oracle@VM_0_13_centos ~]$ ls -la
total 36
drwx------ 5 oracle oinstall 4096 May 6 11:44 .
drwxr-xr-x. 4 root root 4096 May 6 11:28 ..
-rw------- 1 oracle oinstall 15 May 6 11:44 .bash_history
-rw-r--r-- 1 oracle oinstall 18 Aug 3 2017 .bash_logout
-rw-r--r-- 1 oracle oinstall 193 Aug 3 2017 .bash_profile
-rw-r--r-- 1 oracle oinstall 231 Aug 3 2017 .bashrc
drwxr-xr-x 3 oracle oinstall 4096 May 6 11:44 .cache
drwxr-xr-x 3 oracle oinstall 4096 May 6 11:44 .config
drwxr-xr-x 3 oracle oinstall 4096 May 6 11:41 oradiag_oracle
[oracle@VM_0_13_centos ~]$ vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=dbserver; export ORACLE_HOSTNAME
ORACLE_UNQNAME=ORADB; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe; export ORACLE_HOME
ORACLE_SID=ORADB; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
".bash_profile" 20L, 686C written
8.测试,Oracle数据库是否成功
[oracle@VM_0_13_centos ~]$ source .bash_profile
[oracle@VM_0_13_centos ~]$ echo $ORACLE_BASE
/u01/app/oracle
[oracle@VM_0_13_centos ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sun May 6 11:46:10 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> exit
Disconnected
9.到此,CentOS上已成功安装Oracle XE