Categorias
banco de dados Linux

o último guia de instalação do Oracle para Linux

Há quase duas décadas eu fiz um dos primeiros tutoriais de instalação de Oracle para Linux, e agora vou escrever o último deles.

Não é o último pelo fato de ser mais atual, e sim porque depois da invenção do Docker , o mundo das instalações ficou infinitamente mais fácil.

Então, se você não conhece Docker vou deixar algumas dicas aqui:

livro gratuito em português;
– vídeos sobre o conceito e alguns exemplos de Docker;

Com o conhecimento básico de Docker, vou considerar que ele já está instalado em seu sistema.

Basicamente a instalação do Oracle se resume aos passos:

  1. Baixar os scripts Docker do Oracle
  2. Baixar o instalador do Oracle para Linux
  3. Gerar uma imagem Docker do Oracle
  4. Usar a imagem Docker do Oracle

Passo 1 – Baixar os scripts Docker do Oracle

$ docker -v 
Docker version 18.06.1-ce, build e68fc7a215 
$

Agora precisamos baixar o repositório oficial do Oracle na sua máquina:

$ git clone https://github.com/oracle/docker-images.git
Cloning into 'docker-images'...
remote: Enumerating objects: 28, done.
remote: Counting objects: 100% (28/28), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 8809 (delta 5), reused 7 (delta 3), pack-reused 8781
Receiving objects: 100% (8809/8809), 9.94 MiB | 2.39 MiB/s, done.
Resolving deltas: 100% (5013/5013), done.
$

Passo 2 – Baixar o instalador do Oracle para Linux

Esse método serve para diversas versões do Oracle, mas esse artigo é para a versão gratuita Oracle Database Express Edition 11g Release 2, que está disponível no site da Oracle, ou diretamente nesse link.

O arquivo baixado será esse: oracle-xe-11.2.0-1.0.x86_64.rpm.zip

$ du -h oracle-xe-11.2.0-1.0.x86_64.rpm.zip
302M    oracle-xe-11.2.0-1.0.x86_64.rpm.zip
$ md5sum oracle-xe-11.2.0-1.0.x86_64.rpm.zip
dd7881a55569d890241f11cd0eeb7d48  oracle-xe-11.2.0-1.0.x86_64.rpm.zip

Passo 3 – Gerar uma imagem Docker do Oracle

Antes de gerarmos a imagem do Docker precisamos copiar o ZIP do instalador para o diretório do Oracle 11:

$ cp oracle-xe-11.2.0-1.0.x86_64.rpm.zip docker-images/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/ 
$
$ cd  docker-images/OracleDatabase/SingleInstance/dockerfiles
$ ./buildDockerImage.sh -v 11.2.0.2 -x
Checking if required packages are present and valid...
oracle-xe-11.2.0-1.0.x86_64.rpm.zip: OK
==========================
DOCKER info:
Containers: 57
 Running: 0
 Paused: 0
 Stopped: 57
Images: 27
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.18.9-arch1-1-ARCH
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.61GiB
Name: cascao
ID: PWRJ:HPXK:XVIN:XOLY:QEGE:ZFER:ZBYD:J3S5:5AXQ:ASUP:BV5H:IRNC
Docker Root Dir: /files3/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 22
 Goroutines: 42
 System Time: 2018-09-22T22:46:43.854985195-03:00
 EventsListeners: 0
Username: boaglio
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 192.168.0.6:5000
 127.0.0.0/8
Live Restore Enabled: false

==========================
Building image 'oracle/database:11.2.0.2-xe' ...
Sending build context to Docker daemon  315.9MB
Step 1/10 : FROM oraclelinux:7-slim
 ---> 0e3d3a8c0f61
Step 2/10 : MAINTAINER Gerald Venzl 
 ---> Running in 4254d8333c96
Removing intermediate container 4254d8333c96
 ---> 594213b92ad2
Step 3/10 : ENV ORACLE_BASE=/u01/app/oracle     ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe     ORACLE_SID=XE     INSTALL_FILE_1="oracle-xe-11.2.0-1.0.x86_64.rpm.zip"     INSTALL_DIR="$HOME/install"     CONFIG_RSP="xe.rsp"     RUN_FILE="runOracle.sh"     PWD_FILE="setPassword.sh"     CHECK_DB_FILE="checkDBStatus.sh"
 ---> Running in 22a66de8637f
Removing intermediate container 22a66de8637f
 ---> 97ad14986627
Step 4/10 : ENV PATH=$ORACLE_HOME/bin:$PATH
 ---> Running in f07311fec050
Removing intermediate container f07311fec050
 ---> e1b5c33545db
Step 5/10 : COPY $INSTALL_FILE_1 $CONFIG_RSP $RUN_FILE $PWD_FILE $CHECK_DB_FILE $INSTALL_DIR/
 ---> e28fb4ebb839
Step 6/10 : RUN yum -y install unzip libaio bc initscripts net-tools openssl &&     rm -rf /var/cache/yum &&     cd $INSTALL_DIR &&     unzip $INSTALL_FILE_1 &&     rm $INSTALL_FILE_1 &&        cat() { declare -A PROC=(["/proc/sys/kernel/shmmax"]=4294967295 ["/proc/sys/kernel/shmmni"]=4096 ["/proc/sys/kernel/shmall"]=2097152 ["/proc/sys/fs/file-max"]=6815744); [[ ${PROC[$1]} == "" ]] && /usr/bin/cat $* || echo ${PROC[$1]}; } &&     free() { echo "Swap: 2048 0 2048"; } &&     export -f cat free &&     rpm -i Disk1/*.rpm &&        unset -f cat free &&     mkdir -p $ORACLE_BASE/scripts/setup &&     mkdir $ORACLE_BASE/scripts/startup &&     ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d &&     mkdir $ORACLE_BASE/oradata &&     chown -R oracle:dba $ORACLE_BASE &&     mv $INSTALL_DIR/$CONFIG_RSP $ORACLE_BASE/ &&     mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ &&     mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ &&     mv $INSTALL_DIR/$CHECK_DB_FILE $ORACLE_BASE/ &&     ln -s $ORACLE_BASE/$PWD_FILE / &&     cd $HOME &&     rm -rf $INSTALL_DIR &&     chmod ug+x $ORACLE_BASE/*.sh
 ---> Running in dd64dbc938b1
Loaded plugins: ovl
Resolving Dependencies
--> Running transaction check
---> Package bc.x86_64 0:1.06.95-13.el7 will be installed
---> Package initscripts.x86_64 0:9.49.41-1.0.4.el7_5.1 will be installed
--> Processing Dependency: udev >= 125-1 for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: sysvinit-tools >= 2.87-5 for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: util-linux >= 2.16 for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: /sbin/arping for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: systemd for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: iproute for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: hostname for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: /sbin/sysctl for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
--> Processing Dependency: module-init-tools for package: initscripts-9.49.41-1.0.4.el7_5.1.x86_64
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
---> Package openssl.x86_64 1:1.0.2k-12.0.1.el7 will be installed
--> Processing Dependency: make for package: 1:openssl-1.0.2k-12.0.1.el7.x86_64
---> Package unzip.x86_64 0:6.0-19.el7 will be installed
--> Running transaction check
---> Package hostname.x86_64 0:3.13-3.el7 will be installed
---> Package iproute.x86_64 0:4.11.0-14.el7 will be installed
--> Processing Dependency: libmnl.so.0(LIBMNL_1.0)(64bit) for package: iproute-4.11.0-14.el7.x86_64
--> Processing Dependency: libmnl.so.0()(64bit) for package: iproute-4.11.0-14.el7.x86_64
--> Processing Dependency: libxtables.so.10()(64bit) for package: iproute-4.11.0-14.el7.x86_64
---> Package iputils.x86_64 0:20160308-10.el7 will be installed
---> Package kmod.x86_64 0:20-21.0.1.el7 will be installed
--> Processing Dependency: /usr/bin/gzip for package: kmod-20-21.0.1.el7.x86_64
--> Processing Dependency: /usr/bin/xz for package: kmod-20-21.0.1.el7.x86_64
--> Processing Dependency: /usr/bin/nm for package: kmod-20-21.0.1.el7.x86_64
--> Processing Dependency: dracut for package: kmod-20-21.0.1.el7.x86_64
---> Package make.x86_64 1:3.82-23.el7 will be installed
---> Package procps-ng.x86_64 0:3.3.10-17.el7_5.2 will be installed
--> Processing Dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit) for package: procps-ng-3.3.10-17.el7_5.2.x86_64
--> Processing Dependency: libsystemd.so.0()(64bit) for package: procps-ng-3.3.10-17.el7_5.2.x86_64
---> Package systemd.x86_64 0:219-57.0.1.el7_5.1 will be installed
--> Processing Dependency: dbus for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: acl for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libkmod.so.2(LIBKMOD_5)(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libpam.so.0(LIBPAM_1.0)(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libcryptsetup.so.4(CRYPTSETUP_1.0)(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.122)(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.158)(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libdw.so.1(ELFUTILS_0.130)(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: liblz4.so.1()(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libdw.so.1()(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libkmod.so.2()(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libpam.so.0()(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libqrencode.so.3()(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
--> Processing Dependency: libcryptsetup.so.4()(64bit) for package: systemd-219-57.0.1.el7_5.1.x86_64
---> Package sysvinit-tools.x86_64 0:2.88-14.dsf.el7 will be installed
---> Package util-linux.x86_64 0:2.23.2-52.el7_5.1 will be installed
--> Processing Dependency: libblkid = 2.23.2-52.el7_5.1 for package: util-linux-2.23.2-52.el7_5.1.x86_64
--> Processing Dependency: libmount = 2.23.2-52.el7_5.1 for package: util-linux-2.23.2-52.el7_5.1.x86_64
--> Processing Dependency: libuuid = 2.23.2-52.el7_5.1 for package: util-linux-2.23.2-52.el7_5.1.x86_64
--> Processing Dependency: libutempter.so.0(UTEMPTER_1.1)(64bit) for package: util-linux-2.23.2-52.el7_5.1.x86_64
--> Processing Dependency: libutempter.so.0()(64bit) for package: util-linux-2.23.2-52.el7_5.1.x86_64
--> Processing Dependency: libuser.so.1()(64bit) for package: util-linux-2.23.2-52.el7_5.1.x86_64
--> Running transaction check
---> Package acl.x86_64 0:2.2.51-14.el7 will be installed
---> Package binutils.x86_64 0:2.27-28.base.el7_5.1 will be installed
---> Package cryptsetup-libs.x86_64 0:1.7.4-4.el7 will be installed
--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) for package: cryptsetup-libs-1.7.4-4.el7.x86_64
--> Processing Dependency: libdevmapper.so.1.02(Base)(64bit) for package: cryptsetup-libs-1.7.4-4.el7.x86_64
--> Processing Dependency: libdevmapper.so.1.02()(64bit) for package: cryptsetup-libs-1.7.4-4.el7.x86_64
---> Package dbus.x86_64 1:1.10.24-7.0.1.el7 will be installed
--> Processing Dependency: dbus-libs(x86-64) = 1:1.10.24-7.0.1.el7 for package: 1:dbus-1.10.24-7.0.1.el7.x86_64
--> Processing Dependency: libdbus-1.so.3(LIBDBUS_PRIVATE_1.10.24)(64bit) for package: 1:dbus-1.10.24-7.0.1.el7.x86_64
--> Processing Dependency: libdbus-1.so.3(LIBDBUS_1_3)(64bit) for package: 1:dbus-1.10.24-7.0.1.el7.x86_64
--> Processing Dependency: libdbus-1.so.3()(64bit) for package: 1:dbus-1.10.24-7.0.1.el7.x86_64
---> Package dracut.x86_64 0:033-535.0.5.el7_5.1 will be installed
--> Processing Dependency: /usr/bin/pkg-config for package: dracut-033-535.0.5.el7_5.1.x86_64
--> Processing Dependency: kpartx for package: dracut-033-535.0.5.el7_5.1.x86_64
--> Processing Dependency: tar for package: dracut-033-535.0.5.el7_5.1.x86_64
--> Processing Dependency: hardlink for package: dracut-033-535.0.5.el7_5.1.x86_64
---> Package elfutils-libs.x86_64 0:0.170-4.el7 will be installed
--> Processing Dependency: default-yama-scope for package: elfutils-libs-0.170-4.el7.x86_64
---> Package gzip.x86_64 0:1.5-10.el7 will be installed
---> Package iptables.x86_64 0:1.4.21-24.1.el7_5 will be installed
--> Processing Dependency: libnetfilter_conntrack.so.3()(64bit) for package: iptables-1.4.21-24.1.el7_5.x86_64
--> Processing Dependency: libnfnetlink.so.0()(64bit) for package: iptables-1.4.21-24.1.el7_5.x86_64
---> Package kmod-libs.x86_64 0:20-21.0.1.el7 will be installed
---> Package libblkid.x86_64 0:2.23.2-52.el7 will be updated
---> Package libblkid.x86_64 0:2.23.2-52.el7_5.1 will be an update
---> Package libmnl.x86_64 0:1.0.3-7.el7 will be installed
---> Package libmount.x86_64 0:2.23.2-52.el7 will be updated
---> Package libmount.x86_64 0:2.23.2-52.el7_5.1 will be an update
---> Package libuser.x86_64 0:0.60-9.el7 will be installed
---> Package libutempter.x86_64 0:1.1.6-4.el7 will be installed
---> Package libuuid.x86_64 0:2.23.2-52.el7 will be updated
---> Package libuuid.x86_64 0:2.23.2-52.el7_5.1 will be an update
---> Package lz4.x86_64 0:1.7.5-2.el7 will be installed
---> Package pam.x86_64 0:1.1.8-22.el7 will be installed
--> Processing Dependency: libpwquality >= 0.9.9 for package: pam-1.1.8-22.el7.x86_64
--> Processing Dependency: cracklib-dicts >= 2.8 for package: pam-1.1.8-22.el7.x86_64
--> Processing Dependency: libcrack.so.2()(64bit) for package: pam-1.1.8-22.el7.x86_64
---> Package qrencode-libs.x86_64 0:3.4.1-3.el7 will be installed
---> Package systemd-libs.x86_64 0:219-57.0.1.el7_5.1 will be installed
---> Package xz.x86_64 0:5.2.2-1.el7 will be installed
--> Running transaction check
---> Package cracklib.x86_64 0:2.9.0-11.el7 will be installed
---> Package cracklib-dicts.x86_64 0:2.9.0-11.el7 will be installed
---> Package dbus-libs.x86_64 1:1.10.24-7.0.1.el7 will be installed
---> Package device-mapper-libs.x86_64 7:1.02.146-4.0.2.el7 will be installed
--> Processing Dependency: device-mapper = 7:1.02.146-4.0.2.el7 for package: 7:device-mapper-libs-1.02.146-4.0.2.el7.x86_64
---> Package elfutils-default-yama-scope.noarch 0:0.170-4.el7 will be installed
---> Package hardlink.x86_64 1:1.0-19.el7 will be installed
---> Package kpartx.x86_64 0:0.4.9-119.el7_5.1 will be installed
---> Package libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3 will be installed
---> Package libnfnetlink.x86_64 0:1.0.1-4.el7 will be installed
---> Package libpwquality.x86_64 0:1.2.3-5.el7 will be installed
---> Package pkgconfig.x86_64 1:0.27.1-4.el7 will be installed
---> Package tar.x86_64 2:1.26-34.el7 will be installed
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.146-4.0.2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                     Arch   Version                    Repository  Size
================================================================================
Installing:
 bc                          x86_64 1.06.95-13.el7             ol7_latest 114 k
 initscripts                 x86_64 9.49.41-1.0.4.el7_5.1      ol7_latest 437 k
 libaio                      x86_64 0.3.109-13.el7             ol7_latest  24 k
 net-tools                   x86_64 2.0-0.22.20131004git.el7   ol7_latest 305 k
 openssl                     x86_64 1:1.0.2k-12.0.1.el7        ol7_latest 492 k
 unzip                       x86_64 6.0-19.el7                 ol7_latest 169 k
Installing for dependencies:
 acl                         x86_64 2.2.51-14.el7              ol7_latest  81 k
 binutils                    x86_64 2.27-28.base.el7_5.1       ol7_latest 5.9 M
 cracklib                    x86_64 2.9.0-11.el7               ol7_latest  79 k
 cracklib-dicts              x86_64 2.9.0-11.el7               ol7_latest 3.6 M
 cryptsetup-libs             x86_64 1.7.4-4.el7                ol7_latest 222 k
 dbus                        x86_64 1:1.10.24-7.0.1.el7        ol7_latest 244 k
 dbus-libs                   x86_64 1:1.10.24-7.0.1.el7        ol7_latest 168 k
 device-mapper               x86_64 7:1.02.146-4.0.2.el7       ol7_latest 289 k
 device-mapper-libs          x86_64 7:1.02.146-4.0.2.el7       ol7_latest 316 k
 dracut                      x86_64 033-535.0.5.el7_5.1        ol7_latest 326 k
 elfutils-default-yama-scope noarch 0.170-4.el7                ol7_latest  31 k
 elfutils-libs               x86_64 0.170-4.el7                ol7_latest 267 k
 gzip                        x86_64 1.5-10.el7                 ol7_latest 129 k
 hardlink                    x86_64 1:1.0-19.el7               ol7_latest  14 k
 hostname                    x86_64 3.13-3.el7                 ol7_latest  16 k
 iproute                     x86_64 4.11.0-14.el7              ol7_latest 762 k
 iptables                    x86_64 1.4.21-24.1.el7_5          ol7_latest 431 k
 iputils                     x86_64 20160308-10.el7            ol7_latest 147 k
 kmod                        x86_64 20-21.0.1.el7              ol7_latest 120 k
 kmod-libs                   x86_64 20-21.0.1.el7              ol7_latest  50 k
 kpartx                      x86_64 0.4.9-119.el7_5.1          ol7_latest  75 k
 libmnl                      x86_64 1.0.3-7.el7                ol7_latest  22 k
 libnetfilter_conntrack      x86_64 1.0.6-1.el7_3              ol7_latest  55 k
 libnfnetlink                x86_64 1.0.1-4.el7                ol7_latest  25 k
 libpwquality                x86_64 1.2.3-5.el7                ol7_latest  84 k
 libuser                     x86_64 0.60-9.el7                 ol7_latest 400 k
 libutempter                 x86_64 1.1.6-4.el7                ol7_latest  24 k
 lz4                         x86_64 1.7.5-2.el7                ol7_latest  98 k
 make                        x86_64 1:3.82-23.el7              ol7_latest 420 k
 pam                         x86_64 1.1.8-22.el7               ol7_latest 719 k
 pkgconfig                   x86_64 1:0.27.1-4.el7             ol7_latest  53 k
 procps-ng                   x86_64 3.3.10-17.el7_5.2          ol7_latest 289 k
 qrencode-libs               x86_64 3.4.1-3.el7                ol7_latest  49 k
 systemd                     x86_64 219-57.0.1.el7_5.1         ol7_latest 5.0 M
 systemd-libs                x86_64 219-57.0.1.el7_5.1         ol7_latest 402 k
 sysvinit-tools              x86_64 2.88-14.dsf.el7            ol7_latest  62 k
 tar                         x86_64 2:1.26-34.el7              ol7_latest 845 k
 util-linux                  x86_64 2.23.2-52.el7_5.1          ol7_latest 2.0 M
 xz                          x86_64 5.2.2-1.el7                ol7_latest 228 k
Updating for dependencies:
 libblkid                    x86_64 2.23.2-52.el7_5.1          ol7_latest 178 k
 libmount                    x86_64 2.23.2-52.el7_5.1          ol7_latest 179 k
 libuuid                     x86_64 2.23.2-52.el7_5.1          ol7_latest  80 k

Transaction Summary
================================================================================
Install  6 Packages (+39 Dependent packages)
Upgrade             (  3 Dependent packages)

Total download size: 26 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
--------------------------------------------------------------------------------
Total                                              3.5 MB/s |  26 MB  00:07     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libuuid-2.23.2-52.el7_5.1.x86_64                            1/51 
  Updating   : libblkid-2.23.2-52.el7_5.1.x86_64                           2/51 
  Installing : gzip-1.5-10.el7.x86_64                                      3/51 
  Installing : cracklib-2.9.0-11.el7.x86_64                                4/51 
  Installing : cracklib-dicts-2.9.0-11.el7.x86_64                          5/51 
  Updating   : libmount-2.23.2-52.el7_5.1.x86_64                           6/51 
  Installing : libnfnetlink-1.0.1-4.el7.x86_64                             7/51 
  Installing : lz4-1.7.5-2.el7.x86_64                                      8/51 
  Installing : xz-5.2.2-1.el7.x86_64                                       9/51 
  Installing : libmnl-1.0.3-7.el7.x86_64                                  10/51 
  Installing : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                11/51 
  Installing : iptables-1.4.21-24.1.el7_5.x86_64                          12/51 
  Installing : iproute-4.11.0-14.el7.x86_64                               13/51 
  Installing : libpwquality-1.2.3-5.el7.x86_64                            14/51 
  Installing : pam-1.1.8-22.el7.x86_64                                    15/51 
  Installing : libuser-0.60-9.el7.x86_64                                  16/51 
  Installing : libutempter-1.1.6-4.el7.x86_64                             17/51 
  Installing : 1:hardlink-1.0-19.el7.x86_64                               18/51 
  Installing : hostname-3.13-3.el7.x86_64                                 19/51 
  Installing : binutils-2.27-28.base.el7_5.1.x86_64                       20/51 
install-info: /usr/share/info/dir: could not read (No such file or directory) and could not create (No such file or directory)
install-info: /usr/share/info/dir: could not read (No such file or directory) and could not create (No such file or directory)
install-info: /usr/share/info/dir: could not read (No such file or directory) and could not create (No such file or directory)
install-info: /usr/share/info/dir: could not read (No such file or directory) and could not create (No such file or directory)
install-info: /usr/share/info/dir: could not read (No such file or directory) and could not create (No such file or directory)
  Installing : 1:make-3.82-23.el7.x86_64                                  21/51 
  Installing : kmod-libs-20-21.0.1.el7.x86_64                             22/51 
  Installing : qrencode-libs-3.4.1-3.el7.x86_64                           23/51 
  Installing : acl-2.2.51-14.el7.x86_64                                   24/51 
  Installing : sysvinit-tools-2.88-14.dsf.el7.x86_64                      25/51 
  Installing : 1:pkgconfig-0.27.1-4.el7.x86_64                            26/51 
  Installing : 2:tar-1.26-34.el7.x86_64                                   27/51 
  Installing : util-linux-2.23.2-52.el7_5.1.x86_64                        28/51 
  Installing : procps-ng-3.3.10-17.el7_5.2.x86_64                         29/51 
  Installing : kpartx-0.4.9-119.el7_5.1.x86_64                            30/51 
  Installing : 7:device-mapper-1.02.146-4.0.2.el7.x86_64                  31/51 
  Installing : 7:device-mapper-libs-1.02.146-4.0.2.el7.x86_64             32/51 
  Installing : cryptsetup-libs-1.7.4-4.el7.x86_64                         33/51 
  Installing : dracut-033-535.0.5.el7_5.1.x86_64                          34/51 
  Installing : kmod-20-21.0.1.el7.x86_64                                  35/51 
  Installing : elfutils-libs-0.170-4.el7.x86_64                           36/51 
  Installing : systemd-libs-219-57.0.1.el7_5.1.x86_64                     37/51 
  Installing : 1:dbus-libs-1.10.24-7.0.1.el7.x86_64                       38/51 
  Installing : systemd-219-57.0.1.el7_5.1.x86_64                          39/51 
  Installing : elfutils-default-yama-scope-0.170-4.el7.noarch             40/51 
  Installing : 1:dbus-1.10.24-7.0.1.el7.x86_64                            41/51 
  Installing : iputils-20160308-10.el7.x86_64                             42/51 
  Installing : initscripts-9.49.41-1.0.4.el7_5.1.x86_64                   43/51 
  Installing : net-tools-2.0-0.22.20131004git.el7.x86_64                  44/51 
  Installing : 1:openssl-1.0.2k-12.0.1.el7.x86_64                         45/51 
  Installing : unzip-6.0-19.el7.x86_64                                    46/51 
  Installing : libaio-0.3.109-13.el7.x86_64                               47/51 
  Installing : bc-1.06.95-13.el7.x86_64                                   48/51 
  Cleanup    : libmount-2.23.2-52.el7.x86_64                              49/51 
  Cleanup    : libblkid-2.23.2-52.el7.x86_64                              50/51 
  Cleanup    : libuuid-2.23.2-52.el7.x86_64                               51/51 
  Verifying  : 2:tar-1.26-34.el7.x86_64                                    1/51 
  Verifying  : systemd-219-57.0.1.el7_5.1.x86_64                           2/51 
  Verifying  : libmnl-1.0.3-7.el7.x86_64                                   3/51 
  Verifying  : gzip-1.5-10.el7.x86_64                                      4/51 
  Verifying  : 1:pkgconfig-0.27.1-4.el7.x86_64                             5/51 
  Verifying  : net-tools-2.0-0.22.20131004git.el7.x86_64                   6/51 
  Verifying  : systemd-libs-219-57.0.1.el7_5.1.x86_64                      7/51 
  Verifying  : initscripts-9.49.41-1.0.4.el7_5.1.x86_64                    8/51 
  Verifying  : kmod-20-21.0.1.el7.x86_64                                   9/51 
  Verifying  : sysvinit-tools-2.88-14.dsf.el7.x86_64                      10/51 
  Verifying  : iproute-4.11.0-14.el7.x86_64                               11/51 
  Verifying  : acl-2.2.51-14.el7.x86_64                                   12/51 
  Verifying  : bc-1.06.95-13.el7.x86_64                                   13/51 
  Verifying  : cryptsetup-libs-1.7.4-4.el7.x86_64                         14/51 
  Verifying  : 1:openssl-1.0.2k-12.0.1.el7.x86_64                         15/51 
  Verifying  : kpartx-0.4.9-119.el7_5.1.x86_64                            16/51 
  Verifying  : elfutils-default-yama-scope-0.170-4.el7.noarch             17/51 
  Verifying  : dracut-033-535.0.5.el7_5.1.x86_64                          18/51 
  Verifying  : 7:device-mapper-libs-1.02.146-4.0.2.el7.x86_64             19/51 
  Verifying  : qrencode-libs-3.4.1-3.el7.x86_64                           20/51 
  Verifying  : kmod-libs-20-21.0.1.el7.x86_64                             21/51 
  Verifying  : elfutils-libs-0.170-4.el7.x86_64                           22/51 
  Verifying  : libmount-2.23.2-52.el7_5.1.x86_64                          23/51 
  Verifying  : libaio-0.3.109-13.el7.x86_64                               24/51 
  Verifying  : 7:device-mapper-1.02.146-4.0.2.el7.x86_64                  25/51 
  Verifying  : util-linux-2.23.2-52.el7_5.1.x86_64                        26/51 
  Verifying  : libuuid-2.23.2-52.el7_5.1.x86_64                           27/51 
  Verifying  : 1:dbus-1.10.24-7.0.1.el7.x86_64                            28/51 
  Verifying  : iputils-20160308-10.el7.x86_64                             29/51 
  Verifying  : xz-5.2.2-1.el7.x86_64                                      30/51 
  Verifying  : lz4-1.7.5-2.el7.x86_64                                     31/51 
  Verifying  : iptables-1.4.21-24.1.el7_5.x86_64                          32/51 
  Verifying  : 1:make-3.82-23.el7.x86_64                                  33/51 
  Verifying  : libpwquality-1.2.3-5.el7.x86_64                            34/51 
  Verifying  : binutils-2.27-28.base.el7_5.1.x86_64                       35/51 
  Verifying  : procps-ng-3.3.10-17.el7_5.2.x86_64                         36/51 
  Verifying  : hostname-3.13-3.el7.x86_64                                 37/51 
  Verifying  : libnfnetlink-1.0.1-4.el7.x86_64                            38/51 
  Verifying  : cracklib-dicts-2.9.0-11.el7.x86_64                         39/51 
  Verifying  : pam-1.1.8-22.el7.x86_64                                    40/51 
  Verifying  : libuser-0.60-9.el7.x86_64                                  41/51 
  Verifying  : libblkid-2.23.2-52.el7_5.1.x86_64                          42/51 
  Verifying  : 1:hardlink-1.0-19.el7.x86_64                               43/51 
  Verifying  : cracklib-2.9.0-11.el7.x86_64                               44/51 
  Verifying  : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                45/51 
  Verifying  : unzip-6.0-19.el7.x86_64                                    46/51 
  Verifying  : 1:dbus-libs-1.10.24-7.0.1.el7.x86_64                       47/51 
  Verifying  : libutempter-1.1.6-4.el7.x86_64                             48/51 
  Verifying  : libblkid-2.23.2-52.el7.x86_64                              49/51 
  Verifying  : libmount-2.23.2-52.el7.x86_64                              50/51 
  Verifying  : libuuid-2.23.2-52.el7.x86_64                               51/51 

Installed:
  bc.x86_64 0:1.06.95-13.el7                                                    
  initscripts.x86_64 0:9.49.41-1.0.4.el7_5.1                                    
  libaio.x86_64 0:0.3.109-13.el7                                                
  net-tools.x86_64 0:2.0-0.22.20131004git.el7                                   
  openssl.x86_64 1:1.0.2k-12.0.1.el7                                            
  unzip.x86_64 0:6.0-19.el7                                                     

Dependency Installed:
  acl.x86_64 0:2.2.51-14.el7                                                    
  binutils.x86_64 0:2.27-28.base.el7_5.1                                        
  cracklib.x86_64 0:2.9.0-11.el7                                                
  cracklib-dicts.x86_64 0:2.9.0-11.el7                                          
  cryptsetup-libs.x86_64 0:1.7.4-4.el7                                          
  dbus.x86_64 1:1.10.24-7.0.1.el7                                               
  dbus-libs.x86_64 1:1.10.24-7.0.1.el7                                          
  device-mapper.x86_64 7:1.02.146-4.0.2.el7                                     
  device-mapper-libs.x86_64 7:1.02.146-4.0.2.el7                                
  dracut.x86_64 0:033-535.0.5.el7_5.1                                           
  elfutils-default-yama-scope.noarch 0:0.170-4.el7                              
  elfutils-libs.x86_64 0:0.170-4.el7                                            
  gzip.x86_64 0:1.5-10.el7                                                      
  hardlink.x86_64 1:1.0-19.el7                                                  
  hostname.x86_64 0:3.13-3.el7                                                  
  iproute.x86_64 0:4.11.0-14.el7                                                
  iptables.x86_64 0:1.4.21-24.1.el7_5                                           
  iputils.x86_64 0:20160308-10.el7                                              
  kmod.x86_64 0:20-21.0.1.el7                                                   
  kmod-libs.x86_64 0:20-21.0.1.el7                                              
  kpartx.x86_64 0:0.4.9-119.el7_5.1                                             
  libmnl.x86_64 0:1.0.3-7.el7                                                   
  libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3                                 
  libnfnetlink.x86_64 0:1.0.1-4.el7                                             
  libpwquality.x86_64 0:1.2.3-5.el7                                             
  libuser.x86_64 0:0.60-9.el7                                                   
  libutempter.x86_64 0:1.1.6-4.el7                                              
  lz4.x86_64 0:1.7.5-2.el7                                                      
  make.x86_64 1:3.82-23.el7                                                     
  pam.x86_64 0:1.1.8-22.el7                                                     
  pkgconfig.x86_64 1:0.27.1-4.el7                                               
  procps-ng.x86_64 0:3.3.10-17.el7_5.2                                          
  qrencode-libs.x86_64 0:3.4.1-3.el7                                            
  systemd.x86_64 0:219-57.0.1.el7_5.1                                           
  systemd-libs.x86_64 0:219-57.0.1.el7_5.1                                      
  sysvinit-tools.x86_64 0:2.88-14.dsf.el7                                       
  tar.x86_64 2:1.26-34.el7                                                      
  util-linux.x86_64 0:2.23.2-52.el7_5.1                                         
  xz.x86_64 0:5.2.2-1.el7                                                       

Dependency Updated:
  libblkid.x86_64 0:2.23.2-52.el7_5.1    libmount.x86_64 0:2.23.2-52.el7_5.1   
  libuuid.x86_64 0:2.23.2-52.el7_5.1    

Complete!
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  
Executing post-install steps...
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.

Removing intermediate container dd64dbc938b1
 ---> e7afbb955509
Step 7/10 : VOLUME ["$ORACLE_BASE/oradata"]
 ---> Running in 1e24e74abeb3
Removing intermediate container 1e24e74abeb3
 ---> 20ed796ff28f
Step 8/10 : EXPOSE 1521 8080
 ---> Running in a21f6c923bdd
Removing intermediate container a21f6c923bdd
 ---> f96b43bbfda3
Step 9/10 : HEALTHCHECK --interval=1m --start-period=5m    CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
 ---> Running in 556fe943b7a0
Removing intermediate container 556fe943b7a0
 ---> 236a255eb19c
Step 10/10 : CMD exec $ORACLE_BASE/$RUN_FILE
 ---> Running in db7d7ec658c2
Removing intermediate container db7d7ec658c2
 ---> b0ccccafa578
[Warning] One or more build-args [DB_EDITION] were not consumed
Successfully built b0ccccafa578
Successfully tagged oracle/database:11.2.0.2-xe


  Oracle Database Docker Image for 'xe' version 11.2.0.2 is ready to be extended: 
    
    --> oracle/database:11.2.0.2-xe

  Build completed in 156 seconds.
$
$ docker images | grep oracle
oracle/database                           11.2.0.2-xe              b0ccccafa578        About an hour ago   1.13GB
$

Passo 4 – Usar a imagem Docker do Oracle

Inicialmente vamos ajustar o usuário do Linux oracle, ele precisa estar no grupo dba e tanto o UID como o GID precisa ser 1000, para ser a mesmo valor do usuário da instância Oracle do Docker:

$ groupdel dba
$ groupadd -g 1000 dba 
$ userdel oracle
$ useradd -u 1000 -m -G dba oracle
$ chmod -R 777 $HOME/docker/oracle11
$ chown -R 1000:1000 $HOME/docker/oracle11

Talvez já exista um usuário ou grupo com id 1000, nesse caso podemos ignorar os erros.

Considerando o diretório $HOME/docker/oracle11 sendo o lugar que ficarão os arquivos do banco de dados, então o comando para subir o Oracle é:

$ docker rm oracle11
$ docker run --name oracle11 --shm-size=1g -p 1521:1521 -p 8080:8080 -e ORACLE_PWD=boaglio -v $HOME/docker/oracle11:/u01/app/oracle/oradata oracle/database:11.2.0.2-xe
ORACLE PASSWORD FOR SYS AND SYSTEM: boaglio

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]:
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.

SQL*Plus: Release 11.2.0.2.0 Production on Sun Sep 23 05:08:18 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> 
PL/SQL procedure successfully completed.

SQL> 
Database altered.

SQL> 
Database altered.

SQL> 
Database altered.

SQL> 
System altered.

SQL> 
System altered.

SQL> 
System altered.

SQL> 
Database altered.

SQL> 
Database altered.

SQL> SQL> 
System altered.

SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
  Current log# 5 seq# 4 mem# 0: /u01/app/oracle/oradata/XE/redo05.log
      ALTER DATABASE DROP LOGFILE GROUP 1
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/XE/onlinelog/o1_mf_1_ftg7wl24_.log
Completed:       ALTER DATABASE DROP LOGFILE GROUP 1
      ALTER DATABASE DROP LOGFILE GROUP 2
Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/XE/onlinelog/o1_mf_2_ftg7wlvc_.log
Completed:       ALTER DATABASE DROP LOGFILE GROUP 2
Cleared LOG_ARCHIVE_DEST_1 parameter default value
Using LOG_ARCHIVE_DEST_1 parameter default value as /u01/app/oracle/product/11.2.0/xe/dbs/arch
ALTER SYSTEM SET db_recovery_file_dest='' SCOPE=BOTH;

Depois podemos verificar que o diretório $HOME/docker/oracle11 tem novos arquivos:

$ cd $HOME/docker/oracle11
$ tree
.
├── dbconfig
│   └── XE
│       ├── listener.ora
│       ├── oracle-xe
│       ├── orapwXE
│       ├── oratab
│       ├── spfileXE.ora
│       └── tnsnames.ora
└── XE
    ├── control.dbf
    ├── redo04.log
    ├── redo05.log
    ├── redo06.log
    ├── sysaux.dbf
    ├── system.dbf
    ├── temp.dbf
    ├── undotbs1.dbf
    └── users.dbf

3 directories, 15 files
$ du -h
1.3G    ./XE
24K     ./dbconfig/XE
24K     ./dbconfig
1.3G    .
$

 

Com isso podemos acessar nossa imagem com o usuário system e senha boaglio usando um SQL*Plus instalado do Oracle ou usando um do Docker:

Nesse teste o IP da máquina rodando o Docker é 192.168.0.11:

$ docker run --rm -ti oracle/database:11.2.0.2-xe sqlplus system/boaglio@192.168.0.11:1521/XE

SQL*Plus: Release 11.2.0.2.0 Production on Sun Sep 23 05:17:24 2018

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> 
SQL> 
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> exit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
$

Ou também pelo Oracle SQL Developer:

Se quiser usar a interface gráfica APEX (que é uma GUI para o clássico Oracle Enterprise Manager), acesse http://127.0.0.1:8080/apex/apex_admin , entre com usuário admin e senha boaglio:

Em seguida teremos que mudar a senha, que precisa seguir essas regras:

  • Ter pelo menos 6 caracteres.
  • Ter um número (0123456789).
  • Ter um caracter especial(!”#$%&()“*+,-/:;<=>?_).
  • Ter uma letra maiúscula.
  • Não pode ter o username (nesse caso é o admin).

Uma senha compatível com as regras é: Oracle123!

Depois de mudar a senha podemos acessar normalmente e fazer manutenção no banco de dados:

Um exemplo é a criação de usuários:

A versão instalada é a Application Express 4.0.2.00.09, para mais informações acesse aqui e se desejar atualizar tente esse tutorial.

Fernando Boaglio, para a comunidade

Por Fernando Boaglio