A continuación se detallan los pasos a seguir para poder instalar correctamente un servidor de base de datos Oracle XE.
Para empezar, será necesario descargar el fichero de instalación para Linux del Oracle Server; para ello es necesario tener una cuenta en Oracle, que es gratuita, pero que resulta un poco molesta crear, sobre todo porque vas a acceder a un software gratuito, pero es un peaje que hay que pagar.
Una vez descargado el ejecutable procedemos a descomprimirlo
sudo unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip -d
E intentamos ejecutar el instalable
sudo rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Lo cual produce el siguiente mensaje de error
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: install: %pre scriptlet failed (2), skipping oracle-xe-11.2.0-1.0
Para evitar este error
sudo dd if=/dev/zero of=/swapfile bs=1024 count=2097152
2097152+0 records in
2097152+0 records out
2147483648 bytes (2.1 GB) copied, 36.531 s, 58.8 MB/s
Generamos la partición de swap
sudo mkswap /swapfile
mkswap: /swapfile: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=132a8739-0156-4c57-b3f8-b35bf8830085
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.orig
sudo chmod 777 /etc/fstab.orig
sudo chmod 777 /etc/fstab
sudo echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
Para comprobar que esta bien:
sudo swapon -a
sudo swapon -s
Filename Type Size Used Priority
/swapfile file 2097148 0 -1
Y ahora sí que ejecutamos el instalable
sudo 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.
sudo /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
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:
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
initial configuration:
Confirm the password:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:
Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.
sudo /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
Conectar a la base de datos
Con el usuario oracle
./sqlplus / as sysdba
Crear usuario de acceso a base de datos
CREATE USER MYUSER IDENTIFIED BY MYPWD;
Dar permiso de conexión al usuario recién creado
grant create session to MYUSER;
Iniciar la instancia XE de base de datos
Después de conectarse como SYS as SYSDBA
./sqlplus SYS@XE as SYSDBA
STARTUP pfile=/RUTA-INSTALACION-ORACLE/app/oracle/product/11.2.0/xe/dbs/spfileXE.ora