lunes, 5 de marzo de 2018

Oracle 12c VMs en Windows 10 con Vagrant y Ubuntu (WLS)

En el post anterior mostré como crear en Windows un ambiente virtual (VirtualBox) Oracle 12c en una configuración Standby (dos VMs y dataguard) de forma automática usando Vagrant/Ansible: .

Hay otras forma de hacer lo mismo en Windows 10, y de paso experimentar con Ubuntu usando el Windows Subsystem for Linux (WSL).
En realidad es el objetivo de este post, usando como excusa algo que ya conocemos un poco y nos interesa seguir aprendiendo.

Voy a usar el repositorio vagrant-builder de Frits Hoogland, que tiene documentado el uso de diferentes versiones de OS y BD, incluyendo la que me interesaba probar: OEL 6.9 y 11.2.0.4.0.

Podría usar el mismo repositorio que antes, de oravirt, pero es interesante probar este uso de vagrant que no usa ansible_local, por lo que no funciona en Windows.

Hace unos días Oracle hizo público su propio repositorio Vagrant, incluyendo dos configuraciones: 12.2.0.1 y XE 11.2.0.2.
También es un buen candidato a probar, aunque sea una versión distinta a la que me interesa usar ahora.
Pero esta prueba ya la tengo en draft desde hace algunas semanas y casi pronta para publicar, así que ese queda para otro post.

Durante esta prueba encontré varios problemas que los incluyo en otro post (parte 2) para mantener éste lo más simple posible.
Sólo voy a mencionar acá las soluciones a errores que no evité de forma definitiva.
O sea, los que corregí a mano para poder continuar, pero que se van a repetir si arrancamos el proceso desde el principio.


Ubuntu en Windows 10


Esta funcionalidad es para desarrolladores y todavía en beta.
Algo interesante es que los programas que ejecutamos desde la consola Ubuntu en Windows no usa los binarios que ya tenemos instalados en Windows, sino que tenemos que instalar nuevos binarios para ubuntu, aunque tengamos el mismo programa funcionando en Windows.
Por más detalles de porqué esto es así, ver este link.

Yo seguí la documentación de Microsoft para habiliar WSL, usando la opción de Microsoft Store.
Todo funcionó como tal como se describe en esa guía sin problemas.

Una vez instalado, al abrir una consola Ubuntu por primera vez, se completa la instalación (botón launch como se describe arriba, o buscar "ubuntu" en el menú de inicio de Windows):

    Installing, this may take a few minutes...
    Installation successful!
    Please create a default UNIX user account. The username does not need to match your Windows username.
    For more information visit: https://aka.ms/wslusers
    Enter new UNIX username: ncalero
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    Default UNIX user set to: ncalero
    To run a command as administrator (user "root"), use "sudo ".
    See "man sudo_root" for details.

Como ven se pide crear un usuario unix. Yo creé ncalero.


Instalar Ansible en Ubuntu WSL


Para instalar Ansible se tienen que hacer unos pasos extras. Yo seguí esta guía.

Si no se ejecuta primero 'apt-get update' como se describe, vamos a tener este error:

    ncalero@H6RMYZ1:~$ sudo apt-get -y install python-pip python-dev libffi-dev libssl-dev
    [sudo] password for ncalero:
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package python-pip

Este es el detalle de ejecutar esos pasos.
Hice una pequeña variante instalando primero un solo paquete (python-dev) para confirmar que funcione como se espera, y después el resto:

    ncalero@H6RMYZ1:~$ sudo su -
    root@H6RMYZ1:~# apt-get update
    Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
    Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
    Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
    Get:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
    Get:5 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7532 kB]
    Get:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [425 kB]
    Get:7 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [186 kB]
    Get:8 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [7224 B]
    Get:9 http://security.ubuntu.com/ubuntu xenial-security/restricted Translation-en [2152 B]
    Get:10 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [196 kB]
    Get:11 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [101 kB]
    Get:12 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3208 B]
    Get:13 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [1408 B]
    Get:14 http://archive.ubuntu.com/ubuntu xenial/universe Translation-en [4354 kB]
    Get:15 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [144 kB]
    Get:16 http://archive.ubuntu.com/ubuntu xenial/multiverse Translation-en [106 kB]
    Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [700 kB]
    Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [292 kB]
    Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [7624 B]
    Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/restricted Translation-en [2272 B]
    Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [574 kB]
    Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [232 kB]
    Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.2 kB]
    Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse Translation-en [8052 B]
    Get:25 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [4840 B]
    Get:26 http://archive.ubuntu.com/ubuntu xenial-backports/main Translation-en [3220 B]
    Get:27 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6612 B]
    Get:28 http://archive.ubuntu.com/ubuntu xenial-backports/universe Translation-en [3768 B]
    Fetched 15.2 MB in 56s (268 kB/s)
    Reading package lists... Done
    root@H6RMYZ1:~#
    root@H6RMYZ1:~# apt-get install python-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following package was automatically installed and is no longer required:
      libfreetype6
    Use 'apt autoremove' to remove it.
    The following additional packages will be installed:
      libc-dev-bin libc6 libc6-dev libexpat1-dev libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev
      libpython2.7-minimal libpython2.7-stdlib linux-libc-dev manpages-dev python python-minimal python2.7 python2.7-dev
      python2.7-minimal
    Suggested packages:
      glibc-doc python-doc python-tk python2.7-doc binutils binfmt-support
    The following NEW packages will be installed:
      libc-dev-bin libc6-dev libexpat1-dev libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev
      libpython2.7-minimal libpython2.7-stdlib linux-libc-dev manpages-dev python python-dev python-minimal python2.7
      python2.7-dev python2.7-minimal
    The following packages will be upgraded:
      libc6
    1 upgraded, 17 newly installed, 0 to remove and 82 not upgraded.
    Need to get 38.4 MB/40.8 MB of archives.
    After this operation, 84.4 MB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [340 kB]
    Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [1261 kB]
    Get:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6 amd64 2.23-0ubuntu10 [2580 kB]
    Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1ubuntu0~16.04.3 [1880 kB]
    Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1ubuntu0~16.04.3 [224 kB]
    Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu10 [68.7 kB]
    Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-libc-dev amd64 4.4.0-109.132 [829 kB]
    Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu10 [2079 kB]
    Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7 amd64 2.7.12-1ubuntu0~16.04.3 [1070 kB]
    Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-dev amd64 2.7.12-1ubuntu0~16.04.3 [27.8 MB]
    Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7-dev amd64 2.7.12-1ubuntu0~16.04.3 [276 kB]
    Fetched 38.4 MB in 2min 39s (240 kB/s)
    Preconfiguring packages ...
    Selecting previously unselected package libpython2.7-minimal:amd64.
    (Reading database ... 25532 files and directories currently installed.)
    Preparing to unpack .../libpython2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
    Unpacking libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Selecting previously unselected package python2.7-minimal.
    Preparing to unpack .../python2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
    Unpacking python2.7-minimal (2.7.12-1ubuntu0~16.04.3) ...
    Selecting previously unselected package python-minimal.
    Preparing to unpack .../python-minimal_2.7.11-1_amd64.deb ...
    Unpacking python-minimal (2.7.11-1) ...
    Preparing to unpack .../libc6_2.23-0ubuntu10_amd64.deb ...
    Unpacking libc6:amd64 (2.23-0ubuntu10) over (2.23-0ubuntu9) ...
    Setting up libc6:amd64 (2.23-0ubuntu10) ...
    Processing triggers for libc-bin (2.23-0ubuntu9) ...
    Processing triggers for man-db (2.7.5-1) ...
    Selecting previously unselected package libpython2.7-stdlib:amd64.
    (Reading database ... 25769 files and directories currently installed.)
    Preparing to unpack .../libpython2.7-stdlib_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
    Unpacking libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Selecting previously unselected package python2.7.
    Preparing to unpack .../python2.7_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
    Unpacking python2.7 (2.7.12-1ubuntu0~16.04.3) ...
    Selecting previously unselected package libpython-stdlib:amd64.
    Preparing to unpack .../libpython-stdlib_2.7.11-1_amd64.deb ...
    Unpacking libpython-stdlib:amd64 (2.7.11-1) ...
    Processing triggers for mime-support (3.59ubuntu1) ...
    Processing triggers for man-db (2.7.5-1) ...
    Setting up libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Setting up python2.7-minimal (2.7.12-1ubuntu0~16.04.3) ...
    Linking and byte-compiling packages for runtime python2.7...
    Setting up python-minimal (2.7.11-1) ...
    Selecting previously unselected package python.
    (Reading database ... 26278 files and directories currently installed.)
    Preparing to unpack .../python_2.7.11-1_amd64.deb ...
    Unpacking python (2.7.11-1) ...
    Selecting previously unselected package libc-dev-bin.
    Preparing to unpack .../libc-dev-bin_2.23-0ubuntu10_amd64.deb ...
    Unpacking libc-dev-bin (2.23-0ubuntu10) ...
    Selecting previously unselected package linux-libc-dev:amd64.
    Preparing to unpack .../linux-libc-dev_4.4.0-109.132_amd64.deb ...
    Unpacking linux-libc-dev:amd64 (4.4.0-109.132) ...
    Selecting previously unselected package libc6-dev:amd64.
    Preparing to unpack .../libc6-dev_2.23-0ubuntu10_amd64.deb ...
    Unpacking libc6-dev:amd64 (2.23-0ubuntu10) ...
    Selecting previously unselected package libexpat1-dev:amd64.
    Preparing to unpack .../libexpat1-dev_2.1.0-7ubuntu0.16.04.3_amd64.deb ...
    Unpacking libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.3) ...
    Selecting previously unselected package libpython2.7:amd64.
    Preparing to unpack .../libpython2.7_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
    Unpacking libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Selecting previously unselected package libpython2.7-dev:amd64.
    Preparing to unpack .../libpython2.7-dev_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
    Unpacking libpython2.7-dev:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Selecting previously unselected package libpython-dev:amd64.
    Preparing to unpack .../libpython-dev_2.7.11-1_amd64.deb ...
    Unpacking libpython-dev:amd64 (2.7.11-1) ...
    Selecting previously unselected package manpages-dev.
    Preparing to unpack .../manpages-dev_4.04-2_all.deb ...
    Unpacking manpages-dev (4.04-2) ...
    Selecting previously unselected package python2.7-dev.
    Preparing to unpack .../python2.7-dev_2.7.12-1ubuntu0~16.04.3_amd64.deb ...
    Unpacking python2.7-dev (2.7.12-1ubuntu0~16.04.3) ...
    Selecting previously unselected package python-dev.
    Preparing to unpack .../python-dev_2.7.11-1_amd64.deb ...
    Unpacking python-dev (2.7.11-1) ...
    Processing triggers for man-db (2.7.5-1) ...
    Processing triggers for libc-bin (2.23-0ubuntu9) ...
    Setting up libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Setting up python2.7 (2.7.12-1ubuntu0~16.04.3) ...
    Setting up libpython-stdlib:amd64 (2.7.11-1) ...
    Setting up python (2.7.11-1) ...
    Setting up libc-dev-bin (2.23-0ubuntu10) ...
    Setting up linux-libc-dev:amd64 (4.4.0-109.132) ...
    Setting up libc6-dev:amd64 (2.23-0ubuntu10) ...
    Setting up libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.3) ...
    Setting up libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Setting up libpython2.7-dev:amd64 (2.7.12-1ubuntu0~16.04.3) ...
    Setting up libpython-dev:amd64 (2.7.11-1) ...
    Setting up manpages-dev (4.04-2) ...
    Setting up python2.7-dev (2.7.12-1ubuntu0~16.04.3) ...
    Setting up python-dev (2.7.11-1) ...
    Processing triggers for libc-bin (2.23-0ubuntu9) ...
    root@H6RMYZ1:~# apt-get -y install python-pip libffi-dev libssl-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following package was automatically installed and is no longer required:
      libfreetype6
    Use 'apt autoremove' to remove it.
    The following additional packages will be installed:
      binutils build-essential cpp cpp-5 dpkg-dev fakeroot g++ g++-5 gcc gcc-5 gcc-5-base libalgorithm-diff-perl
      libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libatomic1 libcc1-0 libcilkrts5 libdpkg-perl libfakeroot
      libfile-fcntllock-perl libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0 libpython-all-dev
      libquadmath0 libssl-doc libssl1.0.0 libstdc++-5-dev libstdc++6 libtsan0 libubsan0 make python-all python-all-dev
      python-pip-whl python-pkg-resources python-setuptools python-wheel zlib1g-dev
    Suggested packages:
      binutils-doc cpp-doc gcc-5-locales debian-keyring g++-multilib g++-5-multilib gcc-5-doc libstdc++6-5-dbg
      gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-5-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg
      libatomic1-dbg libasan2-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg
      libstdc++-5-doc make-doc python-setuptools-doc
    The following NEW packages will be installed:
      binutils build-essential cpp cpp-5 dpkg-dev fakeroot g++ g++-5 gcc gcc-5 libalgorithm-diff-perl
      libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan2 libatomic1 libcc1-0 libcilkrts5 libdpkg-perl libfakeroot
      libffi-dev libfile-fcntllock-perl libgcc-5-dev libgomp1 libisl15 libitm1 liblsan0 libmpc3 libmpx0 libpython-all-dev
      libquadmath0 libssl-dev libssl-doc libstdc++-5-dev libtsan0 libubsan0 make python-all python-all-dev python-pip
      python-pip-whl python-pkg-resources python-setuptools python-wheel zlib1g-dev
    The following packages will be upgraded:
      gcc-5-base libssl1.0.0 libstdc++6
    3 upgraded, 44 newly installed, 0 to remove and 79 not upgraded.
    Need to get 39.4 MB of archives.
    After this operation, 135 MB of additional disk space will be used.
    Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB]
    Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5-base amd64 5.4.0-6ubuntu1~16.04.5 [17.1 kB]
    Get:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libstdc++6 amd64 5.4.0-6ubuntu1~16.04.5 [393 kB]
    Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl1.0.0 amd64 1.0.2g-1ubuntu4.10 [1083 kB]
    Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.6 [2311 kB]
    Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB]
    Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.5 [7786 kB]
    Get:8 http://archive.ubuntu.com/ubuntu xenial/main amd64 cpp amd64 4:5.3.1-1ubuntu1 [27.7 kB]
    Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcc1-0 amd64 5.4.0-6ubuntu1~16.04.5 [38.8 kB]
    Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgomp1 amd64 5.4.0-6ubuntu1~16.04.5 [55.1 kB]
    Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libitm1 amd64 5.4.0-6ubuntu1~16.04.5 [27.4 kB]
    Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libatomic1 amd64 5.4.0-6ubuntu1~16.04.5 [8920 B]
    Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasan2 amd64 5.4.0-6ubuntu1~16.04.5 [264 kB]
    Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblsan0 amd64 5.4.0-6ubuntu1~16.04.5 [105 kB]
    Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtsan0 amd64 5.4.0-6ubuntu1~16.04.5 [244 kB]
    Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libubsan0 amd64 5.4.0-6ubuntu1~16.04.5 [95.3 kB]
    Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcilkrts5 amd64 5.4.0-6ubuntu1~16.04.5 [40.1 kB]
    Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libmpx0 amd64 5.4.0-6ubuntu1~16.04.5 [9786 B]
    Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libquadmath0 amd64 5.4.0-6ubuntu1~16.04.5 [131 kB]
    Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.5 [2226 kB]
    Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5 amd64 5.4.0-6ubuntu1~16.04.5 [8638 kB]
    Get:22 http://archive.ubuntu.com/ubuntu xenial/main amd64 gcc amd64 4:5.3.1-1ubuntu1 [5244 B]
    Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libstdc++-5-dev amd64 5.4.0-6ubuntu1~16.04.5 [1430 kB]
    Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 g++-5 amd64 5.4.0-6ubuntu1~16.04.5 [8435 kB]
    Get:25 http://archive.ubuntu.com/ubuntu xenial/main amd64 g++ amd64 4:5.3.1-1ubuntu1 [1504 B]
    Get:26 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB]
    Get:27 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libdpkg-perl all 1.18.4ubuntu1.3 [195 kB]
    Get:28 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 dpkg-dev all 1.18.4ubuntu1.3 [584 kB]
    Get:29 http://archive.ubuntu.com/ubuntu xenial/main amd64 build-essential amd64 12.1ubuntu2 [4758 B]
    Get:30 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfakeroot amd64 1.20.2-1ubuntu1 [25.5 kB]
    Get:31 http://archive.ubuntu.com/ubuntu xenial/main amd64 fakeroot amd64 1.20.2-1ubuntu1 [61.8 kB]
    Get:32 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47.6 kB]
    Get:33 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4build1 [11.0 kB]
    Get:34 http://archive.ubuntu.com/ubuntu xenial/main amd64 libalgorithm-merge-perl all 0.08-3 [12.0 kB]
    Get:35 http://archive.ubuntu.com/ubuntu xenial/main amd64 libfile-fcntllock-perl amd64 0.22-3 [32.0 kB]
    Get:36 http://archive.ubuntu.com/ubuntu xenial/main amd64 libpython-all-dev amd64 2.7.11-1 [992 B]
    Get:37 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.1 [168 kB]
    Get:38 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-dev amd64 1.0.2g-1ubuntu4.10 [1341 kB]
    Get:39 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-doc all 1.0.2g-1ubuntu4.10 [1079 kB]
    Get:40 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-all amd64 2.7.11-1 [978 B]
    Get:41 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-all-dev amd64 2.7.11-1 [1000 B]
    Get:42 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python-pip-whl all 8.1.1-2ubuntu0.4 [1110 kB]
    Get:43 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python-pip all 8.1.1-2ubuntu0.4 [144 kB]
    Get:44 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-pkg-resources all 20.7.0-1 [108 kB]
    Get:45 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-setuptools all 20.7.0-1 [169 kB]
    Get:46 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python-wheel all 0.29.0-1 [48.0 kB]
    Get:47 http://archive.ubuntu.com/ubuntu xenial/main amd64 libffi-dev amd64 3.2.1-4 [161 kB]
    Fetched 39.4 MB in 3min 18s (198 kB/s)
    Extracting templates from packages: 100%
    Preconfiguring packages ...
    Selecting previously unselected package libmpc3:amd64.
    (Reading database ... 29867 files and directories currently installed.)
    Preparing to unpack .../libmpc3_1.0.3-1_amd64.deb ...
    Unpacking libmpc3:amd64 (1.0.3-1) ...
    Preparing to unpack .../gcc-5-base_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking gcc-5-base:amd64 (5.4.0-6ubuntu1~16.04.5) over (5.4.0-6ubuntu1~16.04.4) ...
    Setting up gcc-5-base:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    (Reading database ... 29872 files and directories currently installed.)
    Preparing to unpack .../libstdc++6_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libstdc++6:amd64 (5.4.0-6ubuntu1~16.04.5) over (5.4.0-6ubuntu1~16.04.4) ...
    Processing triggers for libc-bin (2.23-0ubuntu9) ...
    Setting up libstdc++6:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Processing triggers for libc-bin (2.23-0ubuntu9) ...
    (Reading database ... 29872 files and directories currently installed.)
    Preparing to unpack .../libssl1.0.0_1.0.2g-1ubuntu4.10_amd64.deb ...
    Unpacking libssl1.0.0:amd64 (1.0.2g-1ubuntu4.10) over (1.0.2g-1ubuntu4.8) ...
    Selecting previously unselected package binutils.
    Preparing to unpack .../binutils_2.26.1-1ubuntu1~16.04.6_amd64.deb ...
    Unpacking binutils (2.26.1-1ubuntu1~16.04.6) ...
    Selecting previously unselected package libisl15:amd64.
    Preparing to unpack .../libisl15_0.16.1-1_amd64.deb ...
    Unpacking libisl15:amd64 (0.16.1-1) ...
    Selecting previously unselected package cpp-5.
    Preparing to unpack .../cpp-5_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking cpp-5 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package cpp.
    Preparing to unpack .../cpp_4%3a5.3.1-1ubuntu1_amd64.deb ...
    Unpacking cpp (4:5.3.1-1ubuntu1) ...
    Selecting previously unselected package libcc1-0:amd64.
    Preparing to unpack .../libcc1-0_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libgomp1:amd64.
    Preparing to unpack .../libgomp1_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libgomp1:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libitm1:amd64.
    Preparing to unpack .../libitm1_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libitm1:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libatomic1:amd64.
    Preparing to unpack .../libatomic1_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libatomic1:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libasan2:amd64.
    Preparing to unpack .../libasan2_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libasan2:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package liblsan0:amd64.
    Preparing to unpack .../liblsan0_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking liblsan0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libtsan0:amd64.
    Preparing to unpack .../libtsan0_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libtsan0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libubsan0:amd64.
    Preparing to unpack .../libubsan0_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libubsan0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libcilkrts5:amd64.
    Preparing to unpack .../libcilkrts5_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libmpx0:amd64.
    Preparing to unpack .../libmpx0_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libmpx0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libquadmath0:amd64.
    Preparing to unpack .../libquadmath0_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package libgcc-5-dev:amd64.
    Preparing to unpack .../libgcc-5-dev_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package gcc-5.
    Preparing to unpack .../gcc-5_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking gcc-5 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package gcc.
    Preparing to unpack .../gcc_4%3a5.3.1-1ubuntu1_amd64.deb ...
    Unpacking gcc (4:5.3.1-1ubuntu1) ...
    Selecting previously unselected package libstdc++-5-dev:amd64.
    Preparing to unpack .../libstdc++-5-dev_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package g++-5.
    Preparing to unpack .../g++-5_5.4.0-6ubuntu1~16.04.5_amd64.deb ...
    Unpacking g++-5 (5.4.0-6ubuntu1~16.04.5) ...
    Selecting previously unselected package g++.
    Preparing to unpack .../g++_4%3a5.3.1-1ubuntu1_amd64.deb ...
    Unpacking g++ (4:5.3.1-1ubuntu1) ...
    Selecting previously unselected package make.
    Preparing to unpack .../archives/make_4.1-6_amd64.deb ...
    Unpacking make (4.1-6) ...
    Selecting previously unselected package libdpkg-perl.
    Preparing to unpack .../libdpkg-perl_1.18.4ubuntu1.3_all.deb ...
    Unpacking libdpkg-perl (1.18.4ubuntu1.3) ...
    Selecting previously unselected package dpkg-dev.
    Preparing to unpack .../dpkg-dev_1.18.4ubuntu1.3_all.deb ...
    Unpacking dpkg-dev (1.18.4ubuntu1.3) ...
    Selecting previously unselected package build-essential.
    Preparing to unpack .../build-essential_12.1ubuntu2_amd64.deb ...
    Unpacking build-essential (12.1ubuntu2) ...
    Selecting previously unselected package libfakeroot:amd64.
    Preparing to unpack .../libfakeroot_1.20.2-1ubuntu1_amd64.deb ...
    Unpacking libfakeroot:amd64 (1.20.2-1ubuntu1) ...
    Selecting previously unselected package fakeroot.
    Preparing to unpack .../fakeroot_1.20.2-1ubuntu1_amd64.deb ...
    Unpacking fakeroot (1.20.2-1ubuntu1) ...
    Selecting previously unselected package libalgorithm-diff-perl.
    Preparing to unpack .../libalgorithm-diff-perl_1.19.03-1_all.deb ...
    Unpacking libalgorithm-diff-perl (1.19.03-1) ...
    Selecting previously unselected package libalgorithm-diff-xs-perl.
    Preparing to unpack .../libalgorithm-diff-xs-perl_0.04-4build1_amd64.deb ...
    Unpacking libalgorithm-diff-xs-perl (0.04-4build1) ...
    Selecting previously unselected package libalgorithm-merge-perl.
    Preparing to unpack .../libalgorithm-merge-perl_0.08-3_all.deb ...
    Unpacking libalgorithm-merge-perl (0.08-3) ...
    Selecting previously unselected package libfile-fcntllock-perl.
    Preparing to unpack .../libfile-fcntllock-perl_0.22-3_amd64.deb ...
    Unpacking libfile-fcntllock-perl (0.22-3) ...
    Selecting previously unselected package libpython-all-dev:amd64.
    Preparing to unpack .../libpython-all-dev_2.7.11-1_amd64.deb ...
    Unpacking libpython-all-dev:amd64 (2.7.11-1) ...
    Selecting previously unselected package zlib1g-dev:amd64.
    Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.1_amd64.deb ...
    Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
    Selecting previously unselected package libssl-dev:amd64.
    Preparing to unpack .../libssl-dev_1.0.2g-1ubuntu4.10_amd64.deb ...
    Unpacking libssl-dev:amd64 (1.0.2g-1ubuntu4.10) ...
    Selecting previously unselected package libssl-doc.
    Preparing to unpack .../libssl-doc_1.0.2g-1ubuntu4.10_all.deb ...
    Unpacking libssl-doc (1.0.2g-1ubuntu4.10) ...
    Selecting previously unselected package python-all.
    Preparing to unpack .../python-all_2.7.11-1_amd64.deb ...
    Unpacking python-all (2.7.11-1) ...
    Selecting previously unselected package python-all-dev.
    Preparing to unpack .../python-all-dev_2.7.11-1_amd64.deb ...
    Unpacking python-all-dev (2.7.11-1) ...
    Selecting previously unselected package python-pip-whl.
    Preparing to unpack .../python-pip-whl_8.1.1-2ubuntu0.4_all.deb ...
    Unpacking python-pip-whl (8.1.1-2ubuntu0.4) ...
    Selecting previously unselected package python-pip.
    Preparing to unpack .../python-pip_8.1.1-2ubuntu0.4_all.deb ...
    Unpacking python-pip (8.1.1-2ubuntu0.4) ...
    Selecting previously unselected package python-pkg-resources.
    Preparing to unpack .../python-pkg-resources_20.7.0-1_all.deb ...
    Unpacking python-pkg-resources (20.7.0-1) ...
    Selecting previously unselected package python-setuptools.
    Preparing to unpack .../python-setuptools_20.7.0-1_all.deb ...
    Unpacking python-setuptools (20.7.0-1) ...
    Selecting previously unselected package python-wheel.
    Preparing to unpack .../python-wheel_0.29.0-1_all.deb ...
    Unpacking python-wheel (0.29.0-1) ...
    Selecting previously unselected package libffi-dev:amd64.
    Preparing to unpack .../libffi-dev_3.2.1-4_amd64.deb ...
    Unpacking libffi-dev:amd64 (3.2.1-4) ...
    Processing triggers for libc-bin (2.23-0ubuntu9) ...
    Processing triggers for man-db (2.7.5-1) ...
    Processing triggers for install-info (6.1.0.dfsg.1-5) ...
    Setting up libmpc3:amd64 (1.0.3-1) ...
    Setting up libssl1.0.0:amd64 (1.0.2g-1ubuntu4.10) ...
    Setting up binutils (2.26.1-1ubuntu1~16.04.6) ...
    Setting up libisl15:amd64 (0.16.1-1) ...
    Setting up cpp-5 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up cpp (4:5.3.1-1ubuntu1) ...
    Setting up libcc1-0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libgomp1:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libitm1:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libatomic1:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libasan2:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up liblsan0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libtsan0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libubsan0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libcilkrts5:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libmpx0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libquadmath0:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up libgcc-5-dev:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up gcc-5 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up gcc (4:5.3.1-1ubuntu1) ...
    Setting up libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up g++-5 (5.4.0-6ubuntu1~16.04.5) ...
    Setting up g++ (4:5.3.1-1ubuntu1) ...
    update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
    Setting up make (4.1-6) ...
    Setting up libdpkg-perl (1.18.4ubuntu1.3) ...
    Setting up dpkg-dev (1.18.4ubuntu1.3) ...
    Setting up build-essential (12.1ubuntu2) ...
    Setting up libfakeroot:amd64 (1.20.2-1ubuntu1) ...
    Setting up fakeroot (1.20.2-1ubuntu1) ...
    update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
    Setting up libalgorithm-diff-perl (1.19.03-1) ...
    Setting up libalgorithm-diff-xs-perl (0.04-4build1) ...
    Setting up libalgorithm-merge-perl (0.08-3) ...
    Setting up libfile-fcntllock-perl (0.22-3) ...
    Setting up libpython-all-dev:amd64 (2.7.11-1) ...
    Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.1) ...
    Setting up libssl-dev:amd64 (1.0.2g-1ubuntu4.10) ...
    Setting up libssl-doc (1.0.2g-1ubuntu4.10) ...
    Setting up python-all (2.7.11-1) ...
    Setting up python-all-dev (2.7.11-1) ...
    Setting up python-pip-whl (8.1.1-2ubuntu0.4) ...
    Setting up python-pip (8.1.1-2ubuntu0.4) ...
    Setting up python-pkg-resources (20.7.0-1) ...
    Setting up python-setuptools (20.7.0-1) ...
    Setting up python-wheel (0.29.0-1) ...
    Setting up libffi-dev:amd64 (3.2.1-4) ...
    Processing triggers for libc-bin (2.23-0ubuntu9) ...

El último paso es instalar Ansible:

    ncalero@H6RMYZ1:~$ pip install ansible --user
    Collecting ansible
      Downloading ansible-2.4.2.0.tar.gz (6.5MB)
        100% |################################| 6.5MB 156kB/s
    Collecting jinja2 (from ansible)
      Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
        100% |################################| 133kB 1.7MB/s
    Collecting PyYAML (from ansible)
      Downloading PyYAML-3.12.tar.gz (253kB)
        100% |################################| 256kB 2.3MB/s
    Collecting paramiko (from ansible)
      Downloading paramiko-2.4.0-py2.py3-none-any.whl (192kB)
        100% |################################| 194kB 2.6MB/s
    Collecting cryptography (from ansible)
      Downloading cryptography-2.1.4-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
        100% |################################| 2.2MB 335kB/s
    Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python2.7/dist-packages (from ansible)
    Collecting MarkupSafe>=0.23 (from jinja2->ansible)
      Downloading MarkupSafe-1.0.tar.gz
    Collecting pyasn1>=0.1.7 (from paramiko->ansible)
      Downloading pyasn1-0.4.2-py2.py3-none-any.whl (71kB)
        100% |################################| 71kB 1.6MB/s
    Collecting bcrypt>=3.1.3 (from paramiko->ansible)
      Downloading bcrypt-3.1.4-cp27-cp27mu-manylinux1_x86_64.whl (57kB)
        100% |################################| 61kB 2.4MB/s
    Collecting pynacl>=1.0.1 (from paramiko->ansible)
      Downloading PyNaCl-1.2.1-cp27-cp27mu-manylinux1_x86_64.whl (696kB)
        100% |################################| 706kB 920kB/s
    Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography->ansible)
      Downloading cffi-1.11.4-cp27-cp27mu-manylinux1_x86_64.whl (406kB)
        100% |################################| 409kB 1.3MB/s
    Collecting enum34; python_version < "3" (from cryptography->ansible)
      Downloading enum34-1.1.6-py2-none-any.whl
    Collecting asn1crypto>=0.21.0 (from cryptography->ansible)
      Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
        100% |################################| 102kB 2.2MB/s
    Collecting idna>=2.1 (from cryptography->ansible)
      Downloading idna-2.6-py2.py3-none-any.whl (56kB)
        100% |################################| 61kB 2.1MB/s
    Collecting six>=1.4.1 (from cryptography->ansible)
      Downloading six-1.11.0-py2.py3-none-any.whl
    Collecting ipaddress; python_version < "3" (from cryptography->ansible)
      Downloading ipaddress-1.0.19.tar.gz
    Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography->ansible)
      Downloading pycparser-2.18.tar.gz (245kB)
        100% |################################| 256kB 1.7MB/s
    Building wheels for collected packages: ansible, PyYAML, MarkupSafe, ipaddress, pycparser
      Running setup.py bdist_wheel for ansible ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/82/72/89/bcdf63814af976426a34174577b5775d8604b268b1b21fdc1a
      Running setup.py bdist_wheel for PyYAML ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/2c/f7/79/13f3a12cd723892437c0cfbde1230ab4d82947ff7b3839a4fc
      Running setup.py bdist_wheel for MarkupSafe ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
      Running setup.py bdist_wheel for ipaddress ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/d7/6b/69/666188e8101897abb2e115d408d139a372bdf6bfa7abb5aef5
      Running setup.py bdist_wheel for pycparser ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/95/14/9a/5e7b9024459d2a6600aaa64e0ba485325aff7a9ac7489db1b6
    Successfully built ansible PyYAML MarkupSafe ipaddress pycparser
    Installing collected packages: MarkupSafe, jinja2, PyYAML, pyasn1, six, pycparser, cffi, bcrypt, enum34, asn1crypto, idna, ipaddress, cryptography, pynacl, paramiko, ansible
    Successfully installed MarkupSafe PyYAML ansible asn1crypto bcrypt cffi cryptography enum34 idna ipaddress jinja2 paramiko pyasn1 pycparser pynacl six
    python: ../sysdeps/posix/getaddrinfo.c:2603: getaddrinfo: Assertion `IN6_IS_ADDR_V4MAPPED (sin6->sin6_addr.s6_addr32)' failed.
    Aborted (core dumped)

Este error es conocido y descrito acá.
Se resuelve deshabilitando IPv6 en apt-get como root:

    root@H6RMYZ1:~# vi /etc/apt/apt.conf.d/99force-ipv4
    root@H6RMYZ1:~# cat /etc/apt/apt.conf.d/99force-ipv4
    Acquire::ForceIPv4 "true";
    root@H6RMYZ1:~# exit
    ncalero@H6RMYZ1:~$ pip install ansible --user
    Collecting ansible
      Downloading ansible-2.4.2.0.tar.gz (6.5MB)
        100% |################################| 6.5MB 133kB/s
    Collecting jinja2 (from ansible)
      Downloading Jinja2-2.10-py2.py3-none-any.whl (126kB)
        100% |################################| 133kB 1.2MB/s
    Collecting PyYAML (from ansible)
      Downloading PyYAML-3.12.tar.gz (253kB)
        100% |################################| 256kB 3.9MB/s
    Collecting paramiko (from ansible)
      Downloading paramiko-2.4.0-py2.py3-none-any.whl (192kB)
        100% |################################| 194kB 817kB/s
    Collecting cryptography (from ansible)
      Downloading cryptography-2.1.4-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
        100% |################################| 2.2MB 493kB/s
    Collecting setuptools (from ansible)
      Downloading setuptools-38.4.0-py2.py3-none-any.whl (489kB)
        100% |################################| 491kB 2.7MB/s
    Collecting MarkupSafe>=0.23 (from jinja2->ansible)
      Downloading MarkupSafe-1.0.tar.gz
    Collecting pyasn1>=0.1.7 (from paramiko->ansible)
      Downloading pyasn1-0.4.2-py2.py3-none-any.whl (71kB)
        100% |################################| 71kB 1.1MB/s
    Collecting bcrypt>=3.1.3 (from paramiko->ansible)
      Downloading bcrypt-3.1.4-cp27-cp27mu-manylinux1_x86_64.whl (57kB)
        100% |################################| 61kB 1.3MB/s
    Collecting pynacl>=1.0.1 (from paramiko->ansible)
      Downloading PyNaCl-1.2.1-cp27-cp27mu-manylinux1_x86_64.whl (696kB)
        100% |################################| 706kB 1.6MB/s
    Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography->ansible)
      Downloading cffi-1.11.4-cp27-cp27mu-manylinux1_x86_64.whl (406kB)
        100% |################################| 409kB 3.1MB/s
    Collecting enum34; python_version < "3" (from cryptography->ansible)
      Downloading enum34-1.1.6-py2-none-any.whl
    Collecting asn1crypto>=0.21.0 (from cryptography->ansible)
      Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
        100% |################################| 102kB 3.2MB/s
    Collecting idna>=2.1 (from cryptography->ansible)
      Downloading idna-2.6-py2.py3-none-any.whl (56kB)
        100% |################################| 61kB 1.1MB/s
    Collecting six>=1.4.1 (from cryptography->ansible)
      Downloading six-1.11.0-py2.py3-none-any.whl
    Collecting ipaddress; python_version < "3" (from cryptography->ansible)
      Downloading ipaddress-1.0.19.tar.gz
    Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography->ansible)
      Downloading pycparser-2.18.tar.gz (245kB)
        100% |################################| 256kB 3.6MB/s
    Building wheels for collected packages: ansible, PyYAML, MarkupSafe, ipaddress, pycparser
      Running setup.py bdist_wheel for ansible ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/82/72/89/bcdf63814af976426a34174577b5775d8604b268b1b21fdc1a
      Running setup.py bdist_wheel for PyYAML ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/2c/f7/79/13f3a12cd723892437c0cfbde1230ab4d82947ff7b3839a4fc
      Running setup.py bdist_wheel for MarkupSafe ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
      Running setup.py bdist_wheel for ipaddress ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/d7/6b/69/666188e8101897abb2e115d408d139a372bdf6bfa7abb5aef5
      Running setup.py bdist_wheel for pycparser ... done
      Stored in directory: /home/ncalero/.cache/pip/wheels/95/14/9a/5e7b9024459d2a6600aaa64e0ba485325aff7a9ac7489db1b6
    Successfully built ansible PyYAML MarkupSafe ipaddress pycparser
    Installing collected packages: MarkupSafe, jinja2, PyYAML, pyasn1, six, pycparser, cffi, bcrypt, enum34, asn1crypto, idna, ipaddress, cryptography, pynacl, paramiko, setuptools, ansible
    Successfully installed MarkupSafe PyYAML ansible asn1crypto bcrypt cffi cryptography enum34 idna ipaddress jinja2 paramiko pyasn1 pycparser pynacl setuptools-20.7.0 six
    You are using pip version 8.1.1, however version 9.0.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.

Esta vez se instaló sin problemas.

Para completar la configuración de Ansible sólo falta ajustar el path por defecto de nuestro usuario, para que incluya el directorio donde lo instalamos:

    ncalero@H6RMYZ1:~$ ansible --version
    ansible 2.4.2.0
      config file = None
      configured module search path = [u'/home/ncalero/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
      ansible python module location = /home/ncalero/.local/lib/python2.7/site-packages/ansible
      executable location = /home/ncalero/.local/bin/ansible
      python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
    ncalero@H6RMYZ1:~$ which ansible
    /home/ncalero/.local/bin/ansible
    ncalero@H6RMYZ1:~$ echo 'PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc


Instalar Vagrant


Vagrant soporta usar WLS, también en estado de prueba (alpha).
Aquí se explica cómo habilitarlo https://www.vagrantup.com/docs/other/wsl.html

Vagrant no viene instalado por defecto:

    ncalero@H6RMYZ1:~$ vagrant up
    The program 'vagrant' is currently not installed. You can install it by typing:
    sudo apt install vagrant

Bajé la última versión disponible tal como se describe, que en mi caso fue el archivo vagrant_2.0.1_x86_64.deb, al direcotrio d:\vagrant.d y lo instalé desde la consola Ubuntu:

    ncalero@H6RMYZ1:~$ cd /mnt/d/vagrant.d/
    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ ls
    boxes  data  gems  insecure_private_key  rgloader  setup_version  tmp  vagrant_2.0.1_x86_64.deb
    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ sudo dpkg -i vagrant_2.0.1_x86_64.deb
    Selecting previously unselected package vagrant.
    (Reading database ... 34983 files and directories currently installed.)
    Preparing to unpack vagrant_2.0.1_x86_64.deb ...
    Unpacking vagrant (1:2.0.1) ...
    Setting up vagrant (1:2.0.1) ...
    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ which vagrant
    /usr/bin/vagrant
   

Para VirtualBox podríamos pensar en seguir el mismo camino, pero, esto es importante: no es necesario.
Vagrant va a usar lo que tenemos instalado en Windows, tal como lo aclara la documentación:

when using the VirtualBox provider Vagrant will interact with VirtualBox installed on the Windows system, not within the WSL. It is important to ensure that any required Windows executable is available within your PATH to allow Vagrant to access them.


Ahora sí, todo pronto para continuar.
Sólo tenemos que ajustar variables de ambiente antes de usarlo:

    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ export VAGRANT_WSL_WINDOWS_ACCESS_USER="calero"
    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ export PATH=/home/ncalero/bin:/home/ncalero/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Users/calero/AppData/Local/Microsoft/WindowsApps:/snap/bin:/mnt/c/Program\ Files/Oracle/VirtualBox
    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/d/GitHub/vargant-builder"

Usando vagrant-builder


Lo primero es clonar el repositorio que vamos a usar:

    ncalero@H6RMYZ1:/mnt/d/vagrant.d$ cd /mnt/d/GitHub
    ncalero@H6RMYZ1:/mnt/d/GitHub$ git clone --recursive  https://gitlab.com/FritsHoogland/vagrant-builder.git
    Cloning into 'vagrant-builder'...
    remote: Counting objects: 432, done.
    remote: Compressing objects: 100% (181/181), done.
    remote: Total 432 (delta 228), reused 392 (delta 196)
    Receiving objects: 100% (432/432), 80.85 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (228/228), done.
    Checking connectivity... done.
    ncalero@H6RMYZ1:/mnt/d/GitHub$ ls
    vagrant-builder


Para usar este repositorio conviene revisar este blog post donde se explica cómo configurarlo.

Bajé de OTN los binarios que necesitamos para instalar Oracle y los dejé en el directorio D:\GitHub\vagrant-builder\ansible\files, así me evito problemas de conectividad durante la ejecución de vagrant (si no están se conecta y los baja):

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder/ansible/files$ ls -lrt
    total 3664896
    -rwxrwxrwx 1 root root 1395582860 Jan 20 19:07 p13390677_112040_Linux-x86-64_1of7.zip
    -rwxrwxrwx 1 root root 1151304589 Jan 20 19:07 p13390677_112040_Linux-x86-64_2of7.zip
    -rwxrwxrwx 1 root root 1205251894 Jan 20 19:08 p13390677_112040_Linux-x86-64_3of7.zip
    -rwxrwxrwx 1 root root       1069 Jan 21 13:38 ocm.rsp
    -rwxrwxrwx 1 root root       6633 Jan 21 13:38 getMOSPatch.sh

Modificamos el archivo Vagrantfile para habilitar solo las versiones que queremos usar:

    linux = "bento/oracle-6.9"
    vm_cpus = "2"
    vm_memory = "4096"
    vm_hostname = "oracle-OEL69"
    kernel = "kernel-2.6.32-696.el6"
    asm_version="11.2.0.4.0"
    database_version="11.2.0.4.0"


Ahora ejecutamos vagrant para que haga todo el trabajo:

    ncalero@H6RMYZ1:/mnt/d/GitHub$ cd vagrant-builder/
    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Box 'bento/oracle-6.9' could not be found. Attempting to find and install...
        default: Box Provider: virtualbox
        default: Box Version: >= 0
    ==> default: Loading metadata for box 'bento/oracle-6.9'
        default: URL: https://vagrantcloud.com/bento/oracle-6.9
    ==> default: Adding box 'bento/oracle-6.9' (v201801.02.0) for provider: virtualbox
        default: Downloading: https://vagrantcloud.com/bento/boxes/oracle-6.9/versions/201801.02.0/providers/virtualbox.box
    ==> default: Successfully added box 'bento/oracle-6.9' (v201801.02.0) for 'virtualbox'!
    ==> default: Importing base box 'bento/oracle-6.9'...
    ==> default: Matching MAC address for NAT networking...
    ==> default: Checking if box 'bento/oracle-6.9' is up to date...
    ==> default: Setting the name of the VM: oracle-OEL69
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
        default: Adapter 2: hostonly
    ==> default: Forwarding ports...
        default: 22 (guest) => 2222 (host) (adapter 1)
    ==> default: Running 'pre-boot' VM customizations...
    ==> default: Booting VM...
    ==> default: Waiting for machine to boot. This may take a few minutes...
        default: SSH address: 127.0.0.1:2222
        default: SSH username: vagrant
        default: SSH auth method: private key
        default: Warning: Remote connection disconnect. Retrying...
        default: Warning: Remote connection disconnect. Retrying...
        default: Warning: Remote connection disconnect. Retrying...
        default: Warning: Remote connection disconnect. Retrying...
        default: Warning: Remote connection disconnect. Retrying...
    ==> default: Machine booted and ready!
    ==> default: Checking for guest additions in VM...
    ==> default: Setting hostname...
    ==> default: Configuring and enabling network interfaces...
        default: SSH address: 127.0.0.1:2222
        default: SSH username: vagrant
        default: SSH auth method: private key
    ==> default: Running provisioner: ansible...
    Vagrant has automatically selected the compatibility mode '2.0'
    according to the Ansible version installed (2.4.2.0).

    Alternatively, the compatibility mode can be specified in your Vagrantfile:
    https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

        default: Running ansible-playbook...
    ..
   
Como se ve en el log anterior, se descargó la VM para el OS que indicamos (OEL 6.9, bento/oracle-6.9).
Es un archivo de 646Mb, tenerlo en cuenta en función de la conexión a internet que usemos.

Despues de muchos pasos y un log bastante largo, me retornó este error:

    ...
        "msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!"
    }
            to retry, use: --limit @/mnt/d/GitHub/vagrant-builder/ansible/setup.retry

    PLAY RECAP *********************************************************************
    default                    : ok=11   changed=1    unreachable=0    failed=1

    Ansible failed to complete successfully. Any error output should be
    visible above. Please fix these errors and try again.


El mensaje es claro.
En realidad, SElinux debería deshabilitarse para nuestras VMs de prueba.

Para validar como está configurada, necesitamos conectarnos a la VM.
Podemos hacerlo por Virtualbox o usando ssh en nuestra terminal.
La forma simple de usar ssh desde vagrant no está configurada para nuestra nueva VM:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant ssh oracle-OEL69
    The machine with the name 'oracle-OEL69' was not found configured for
    this Vagrant environment.

En el log de la ejecución anterior podemos ver los comandos ssh que se usaron para ejecutar los pasos de vagrant. Copiando el comando ssh de ahí me pude conectar. Éste es el comando:

    ssh -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=2222 -o 'IdentityFile="/mnt/d/GitHub/vargant-builder/.vagrant.d/insecure_private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o ControlPath=/home/ncalero/.ansible/cp/055b8f4af0 127.0.0.1

Una vez dentro de la VM podemos ver que selinux no está deshabiltado:

    [root@oracle-OEL69 ~]# cat /etc/selinux/config

    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    SELINUX=permissive
    # SELINUXTYPE= can take one of these two values:
    #     targeted - Targeted processes are protected,
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted


    [root@oracle-OEL69 ~]#

La solución simple para no cambiar la configuración y reiniciar la VM, es instalar la bilioteca que fue reportada en el error:

    [root@oracle-OEL69 ~]# yum install libselinux-python
    Loaded plugins: ulninfo
    Setting up Install Process
    public_ol6_UEKR4                                                                                 | 1.2 kB     00:00
    public_ol6_UEKR4/primary                                                                         |  27 MB     00:06
    public_ol6_UEKR4: [##################################################                                         ] 308/560debug2: channel 2: window 999359 sent adjust 49217
    public_ol6_UEKR4                                                                                                560/560
    public_ol6_latest                                                                                | 1.4 kB     00:00
    public_ol6_latest/primary                                                                        |  67 MB     00:16
    public_ol6_latest: [                                                                                        ] 105/39733debug2: channel 2: window 999317 sent adjust 49259
    ...
    public_ol6_latest: [##################################################################################### ] 39493/39733debug2: channel 2: window 999376 sent adjust 49200
    public_ol6_latest                                                                                           39733/39733
    Resolving Dependencies
    --> Running transaction check
    ---> Package libselinux-python.x86_64 0:2.0.94-7.el6 will be installed
    --> Finished Dependency Resolution


    Dependencies Resolved

    ========================================================================================================================
     Package                         Arch                 Version                     Repository                       Size
    ========================================================================================================================
    Installing:
     libselinux-python               x86_64               2.0.94-7.el6                public_ol6_latest               202 k

    Transaction Summary
    ========================================================================================================================
    Install       1 Package(s)

    Total download size: 202 k
    Installed size: 657 k
    Is this ok [y/N]: y
    Downloading Packages:
    libselinux-python-2.0.94-7.el6.x86_64.rpm                                                        | 202 kB     00:00
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : libselinux-python-2.0.94-7.el6.x86_64                                                                1/1
      Verifying  : libselinux-python-2.0.94-7.el6.x86_64                                                                1/1

    Installed:
      libselinux-python.x86_64 0:2.0.94-7.el6

    Complete!


Para evitar errores si estamos haciendo esta instalación por primera vez, tenemos que configurar las claves ssh de nuestro usuario antes de continuar:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ ssh-keygen -q -N "" -f id_rsa
    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ ls -lrt ~/.ssh/
    total 0
    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/ncalero/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/ncalero/.ssh/id_rsa.
    Your public key has been saved in /home/ncalero/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:KR9wXcoPa1yZGG1Xze/iElHjErQgEeTM0C2pk0+BYB0 ncalero@H6RMYZ1
    The key's randomart image is:
    +---[RSA 2048]----+
    |    ooE===ooo  oo|
    |   .  o==+.*+++ o|
    |      .o=o*.== ..|
    |      +o.o =o . .|
    |      .+S + .o . |
    |       o.o  . . .|
    |        .    o . |
    |            . .  |
    |             .   |
    +----[SHA256]-----+
    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ ls -lrt ~/.ssh/
    total 4
    -rw------- 1 ncalero ncalero 1675 Jan 21 18:53 id_rsa
    -rw-r--r-- 1 ncalero ncalero  397 Jan 21 18:53 id_rsa.pub


Ahora podemos intentar ejecutar los pasos de provision nuevamente:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ vagrant provision
    ==> default: Running provisioner: ansible...
    Vagrant has automatically selected the compatibility mode '2.0'
    according to the Ansible version installed (2.4.2.0).

    Alternatively, the compatibility mode can be specified in your Vagrantfile:
    https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

        default: Running ansible-playbook...

    PLAY [all] *********************************************************************

    TASK [install simplejson if needed] ********************************************
    changed: [default]

    PLAY [all] *********************************************************************

    TASK [Gathering Facts] *********************************************************
    ok: [default]

    ...

    TASK [install_grid_sw : copy files available local in files directory] *********
    failed: [default] (item=p13390677_112040_Linux-x86-64_3of7.zip) => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/bin/ssh -S none -i /mnt/d/GitHub/vargant-builder/.vagrant.d/insecure_private_key -o Port=2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --rsync-path=sudo rsync --out-format=<>%i %n%L /mnt/d/GitHub/vagrant-builder/ansible/files/p13390677_112040_Linux-x86-64_3of7.zip vagrant@127.0.0.1:/u01/install", "item": {"changed": false, "failed": false, "invocation": {"module_args": {"checksum_algorithm": "sha1", "follow": false, "get_attributes": true, "get_checksum": false, "get_md5": false, "get_mime": true, "path": "files/p13390677_112040_Linux-x86-64_3of7.zip"}}, "item": {"file": "p13390677_112040_Linux-x86-64_3of7.zip", "number": "3", "unique_file": "grid"}, "stat": {"atime": 1516486134.0, "attr_flags": "", "attributes": [], "block_size": 512, "blocks": 2354176, "charset": "binary", "ctime": 1516486134.0, "dev": 13, "device_type": 0, "executable": true, "exists": true, "gid": 0, "gr_name": "root", "inode": 568223859040, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "mimetype": "application/zip", "mode": "0777", "mtime": 1516486134.0, "nlink": 1, "path": "files/p13390677_112040_Linux-x86-64_3of7.zip", "pw_name": "root", "readable": true, "rgrp": true, "roth": true, "rusr": true, "size": 1205251894, "uid": 0, "version": null, "wgrp": true, "woth": true, "writeable": true, "wusr": true, "xgrp": true, "xoth": true, "xusr": true}}, "msg": "Warning: Permanently added '[127.0.0.1]:2222' (RSA) to the list of known hosts.\r\nsudo: rsync: command not found\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.1]\n", "rc": 12}
            to retry, use: --limit @/mnt/d/GitHub/vagrant-builder/ansible/setup.retry

    PLAY RECAP *********************************************************************
    default                    : ok=60   changed=31   unreachable=0    failed=1

Después de validar que rsync está instalado en ambos lados (local y la VM), la forma simple de evitar el error (que podría estar vinculado al uso de recursos, es Windows!), es usar copy en vez de rsync.
Claro que eso implica que cada nueva ejecución estaría repitiendo algo innecesario, y lo mejor sería tener un directorio compartido para ahorrar espacio en la VM. 
Pero para seguir una solución simple, cambié el código del playbook main.yml (vagrant-builder\ansible\roles\install_grid_sw\tasks\main.yml) para que use el comando copy en vez de rsync (línea 42):

    - name: copy files available local in files directory
      # synchronize: src=files/{{ item.item.file }} dest={{ stage_directory }}
      copy: src={{ item.item.file }} dest={{ stage_directory }} owner=oracle group=oinstall mode=0700



Al intentar de nuevo 'vagrant provision', este paso se ejecuta bien, pero hay otro fallo más adelante:

    ...
    TASK [install_grid_sw : copy files available local in files directory] *********
    changed: [default] => (item=p13390677_112040_Linux-x86-64_3of7.zip)

    TASK [install_grid_sw : set ownership of transferred files] ********************
    ok: [default] => (item=p13390677_112040_Linux-x86-64_3of7.zip)
    ...
    TASK [install_opatch : download opatch version 11.2] ***************************
    fatal: [default]: FAILED! => {"changed": true, "cmd": "./getMOSPatch.sh patch=6880880", "delta": "0:00:00.006562", "end": "2018-01-21 22:48:43.904304", "msg": "non-zero return code", "rc": 2, "start": "2018-01-21 22:48:43.897742", "stderr": "./getMOSPatch.sh: line 9: \r: command not found\n./getMOSPatch.sh: line 11: set: -\r: invalid option\nset: usage: set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]", "stderr_lines": ["./getMOSPatch.sh: line 9: ", ": command not found", "./getMOSPatch.sh: line 11: set: -", ": invalid option", "set: usage: set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]"], "stdout": "", "stdout_lines": []}
            to retry, use: --limit @/mnt/d/GitHub/vagrant-builder/ansible/setup.retry

    PLAY RECAP *********************************************************************
    default                    : ok=84   changed=39   unreachable=0    failed=1


El archivo que da error (getMOSPatch.sh) viene includo en el repositorio:

    ncalero@H6RMYZ1:/mnt/d/GitHub/vagrant-builder$ find . | grep getMOSPatch.sh
    ./ansible/files/getMOSPatch.sh

Validando la versión copiada a la VM, vemos que da errores al ejecutarlo manualmente:

    [vagrant@oracle-OEL69 ~]$ cd /u01/install/
    [vagrant@oracle-OEL69 install]$ ls -lrt
    total 8
    -rwx------. 1 oracle oinstall 6633 Jan 21 22:48 getMOSPatch.sh
    [vagrant@oracle-OEL69 install]$ su - oracle
    Password:
    [oracle@oracle-OEL69 ~]$ chmod +x /u01/install/getMOSPatch.sh
    [oracle@oracle-OEL69 ~]$ set mosUser="myuser@mydomain.com"
    [oracle@oracle-OEL69 ~]$ set mosPass="xxx"
    [oracle@oracle-OEL69 ~]$ cd /u01/install/
    [oracle@oracle-OEL69 install]$ ./getMOSPatch.sh patch=6880880
    : command not foundine 9:
    : invalid option: line 11: set: -
    set: usage: set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
    : command not foundine 12:
    : command not foundine 21:
    '/getMOSPatch.sh: line 71: syntax error near unexpected token `do
    '/getMOSPatch.sh: line 71: `  do
    [oracle@oracle-OEL69 install]$
    [oracle@oracle-OEL69 install]$ head getMOSPatch.sh
    #!/bin/bash
    # Maris Elsins / Pythian / 2013
    # Source: https://github.com/MarisElsins/TOOLS/blob/master/Shell/getMOSPatch.sh
    # Inspired by John Piwowar's work: http://only4left.jpiwowar.com/2009/02/retrieving-oracle-patches-with-wget/
    # Usage:
    # getMOSPatch.sh reset=yes  # Use to refresh the platform and language settings
    # getMOSPatch.sh patch=patchnum_1[,patchnum_n]* [download=all] [regexp=...]# Use to download one or more patches. If "download=all" is set all patches will be downloaded without user interaction, you can also define regular expressen by passing regexp to filter the patch filenames.
    # v1.0 Initial version
    # v1.1 Added support for multipart patches, previously these were simply ignored.

Para descartar que el contenido del script no sea el correcto, bajé la versión actual en la VM:
    [oracle@oracle-OEL69 install]$ wget https://raw.githubusercontent.com/MarisElsins/TOOLS/master/Shell/getMOSPatch.sh
    --2018-01-22 00:04:59--  https://raw.githubusercontent.com/MarisElsins/TOOLS/master/Shell/getMOSPatch.sh
    Resolving raw.githubusercontent.com... 151.101.92.133
    Connecting to raw.githubusercontent.com|151.101.92.133|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 6818 (6.7K) [text/plain]
    Saving to: “getMOSPatch.sh.1”

        100%[==============================================================================>] 6,818       --.-K/s   in 0.002s

    2018-01-22 00:04:59 (2.98 MB/s) - “getMOSPatch.sh.1” saved [6818/6818]
   
Quedó grabado con otro nombre, así que ajustando eso y permisos, lo corrí manualmente para ver si puedo reproducir el mismo error:

    [oracle@oracle-OEL69 install]$ mv getMOSPatch.sh getMOSPatch.sh.win
    [oracle@oracle-OEL69 install]$ mv getMOSPatch.sh.1 getMOSPatch.sh
    [oracle@oracle-OEL69 install]$ ls -lrt
    total 104
    -rw-r--r--. 1 oracle oinstall  6818 Jan 22 00:04 getMOSPatch.sh
    -rwx--x--x. 1 oracle oinstall  6633 Jan 22 00:05 getMOSPatch.sh.win
    [oracle@oracle-OEL69 install]$ chmod +x getMOSPatch.sh
    [oracle@oracle-OEL69 install]$
    [oracle@oracle-OEL69 install]$ export mosPass='xxx'
    [oracle@oracle-OEL69 install]$ export mosUser="myuser@mydomain.com"
    [oracle@oracle-OEL69 install]$ ./getMOSPatch.sh patch=6880880

    This version of getMOSPatch is obsolete
    Download getMOSPatch V2 from: https://github.com/MarisElsins/getMOSPatch/raw/master/getMOSPatch.jar
    Check the README for the new version here: https://github.com/MarisElsins/getMOSPatch/blob/master/README.md
    Read my blog post about it here: http://bit.ly/getMOSPatchV2


    Getting list of files for patch 6880880 for "Linux x86-64"
    1 - p6880880_121010_Linux-x86-64.zip
    2 - p6880880_122010_Linux-x86-64.zip
    3 - p6880880_139000_Generic.zip
    4 - p6880880_112000_Linux-x86-64.zip
    5 - p6880880_132000_Generic.zip
    6 - p6880880_111000_Linux-x86-64.zip
    7 - p6880880_131000_Generic.zip
    8 - p6880880_101000_Linux-x86-64.zip
    9 - p6880880_102000_Linux-x86-64.zip
    Comma-delimited list of files to download: 4
    Files to download:
      p6880880_112000_Linux-x86-64.zip

    Downloading the patches:
    Downloading file p6880880_112000_Linux-x86-64.zip ...
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  101M  100  101M    0     0  2123k      0  0:00:48  0:00:48 --:--:-- 1897k
    p6880880_112000_Linux-x86-64.zip completed with status: 0
    [oracle@oracle-OEL69 install]$
    [oracle@oracle-OEL69 install]$ ls -lrt
    total 103680
    -rwxr-xr-x. 1 oracle oinstall      6818 Jan 22 00:04 getMOSPatch.sh
    -rwx--x--x. 1 oracle oinstall      6633 Jan 22 00:05 getMOSPatch.sh.win
    -rw-r--r--. 1 oracle oinstall 106060978 Jan 22 00:10 p6880880_112000_Linux-x86-64.zip
    [oracle@oracle-OEL69 install]$


Esta vez funcionó bien, lo que confirma que había algún problema con la versión original del script o con la copia de ubuntu en windows a la VM.
Para confirmar cual de las dos fue la que causó el error, habría que poner la versión nueva del script en ubuntu, borrar la VM y repetir los pasos hechos hasta acá.
Les dejo eso como ejercicio.

Para ahorrame ejecutar la instalación desde el principio, lo que implica repetir los ajustes manuales ya hechos, edito el playbook y comento los pasos que ejecuté manualmente hasta ahora, así validamos si con este nuevo ajuste se puede completar la configuración de Oracle.

Estas son las líneas comentadas:

    vagrant-builder/ansible/install_opatch/main.yml:
        #  - name: copy getMOSPatch.sh script
        ...
        #  - name: set getMOSPatch.sh config
        ...
        #  - name: download opatch version 11.2

 

Ahora al ejecutar 'vagrant provision' de nuevo, termina sin errores y completa la instalación de Oracle en la VM usando ASM.

No tengo el log completo de esta ejecución porque lo dejé corriendo y al revisarlo una hora después tenía una BSOD :)
Pero despues de reiniciar y levantar manualmente las VM, todo estaba ahí corriendo:

    [vagrant@oracle-OEL69 ~]$ df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           50G  3.6G   43G   8% /
    tmpfs                 1.5G   91M  1.4G   7% /dev/shm
    /dev/sda1             477M  150M  302M  34% /boot
    /dev/mapper/VolGroup-lv_home
                           12G   29M   11G   1% /home
    /dev/mapper/vg_oracle-lv_oracle
                           35G  8.5G   25G  26% /u01
    [vagrant@oracle-OEL69 ~]$ cat /etc/issue
    Oracle Linux Server release 6.9
    Kernel \r on an \m

    [vagrant@oracle-OEL69 ~]$ ps -eaf | grep pmon
    oracle    2005     1  0 01:14 ?        00:00:00 asm_pmon_+ASM
    oracle    2100     1  0 01:14 ?        00:00:00 ora_pmon_orcl
    vagrant   2446  2423  0 01:33 pts/0    00:00:00 grep pmon
    [vagrant@oracle-OEL69 ~]$ su - oracle
    Password:
    [oracle@oracle-OEL69 ~]$ . oraenv
    ORACLE_SID = [oracle] ? orcl
    The Oracle base has been set to /u01/app/oracle
    [oracle@oracle-OEL69 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 11.2.0.4.0 Production on Mon Jan 22 01:34:08 2018

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


    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing options

    SQL> set lines 180 pages 180
    SQL> archive log list;
    Database log mode              No Archive Mode
    Automatic archival             Disabled
    Archive destination            /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch
    Oldest online log sequence     10
    Current log sequence           13
    SQL> select file_name from dba_data_files;

    FILE_NAME
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    +DATA/orcl/datafile/system.261.966039381
    +DATA/orcl/datafile/sysaux.262.966039387
    +DATA/orcl/datafile/undotbs1.263.966039393

    SQL> select open_mode from v$database;

    OPEN_MODE
    --------------------
    READ WRITE

    SQL> select count(1) from v$recover_file;

      COUNT(1)
    ----------
             0

    SQL> select * From v$asm_diskgroup;

    GROUP_NUMBER NAME                           SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE       TYPE     TOTAL_MB    FREE_MB HOT_USED_MB COLD_USED_MB REQUIRED_MIRROR_FREE_MB
    ------------ ------------------------------ ----------- ---------- -------------------- ----------- ------ ---------- ---------- ----------- ------------ -----------------------
    USABLE_FILE_MB OFFLINE_DISKS COMPATIBILITY                                                DATABASE_COMPATIBILITY                                    V
    -------------- ------------- ------------------------------------------------------------ ------------------------------------------------------------ -
               1 DATA                                   512       4096              1048576 CONNECTED   EXTERN      40960      39767        0         1193                       0
             39767             0 11.2.0.0.0                                                   10.1.0.0.0                                                N


    SQL> exit

    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Data Mining
    and Real Application Testing options


Espero que les sirva de referencia si quieren intentar lo mismo.

Un saludo.

lunes, 12 de febrero de 2018

Configurar Oracle Standby 12c usando RMAN duplicate y Data Guard broker

Crear una base de datos Standby en Oracle es algo bien conocido estos días, y hay muchas referencias para hacerlo, empezando por la documentación oficial.

Me interesa mostrar en este post todos los ajustes necesarios si creamos las VM siguiendo mi post anterior, usando Vagrant, Ansible y VirtualBox en Windows 10.

Lo que sigue son los pasos conocidos para configurar una base standby usando ASM a partir de una single instance, con un par de ajustes propios de este ambiente. Con un poco de tiempo extra, todo esto puede agregarse a un playbook e incluirlo en los pasos que ejecuta Ansible.

Hay que tener presente que Dataguard es una opción de Oracle Enterprise Edition, y no es posible usarlo en edición Standard (SE).

Repasando la configuración que tenemos:
  • hosts: ora12c-si-asm-oel681/2
  • IPs:   172.16.56.30 y 172.16.56.31
  • ORACLE_SID: orclcdb
  • usan ASM y PDBs
  • no tienen configurado archivelog
  • los usuarios tienen contraseñas por defecto del playbook ansible
   
Esto se puede ver con una rápida validación después de creadas las VM en el post anterior:

    D:\GitHub\vagrant-vbox-si-asm>vagrant ssh ora12c-si-asm-oel681
    Last login: Wed Jan 24 21:22:11 2018 from 10.0.2.2

    ----------------------------------------
    Welcome to ora12c-si-asm-oel681
    OracleLinux 6.8 x86_64

    FQDN: ora12c-si-asm-oel681.internal.lab
    IP:   10.0.2.15

    Processor: Intel(R) Core(TM) i7-4600M CPU @ 2.90GHz
    #CPU's:    1
    Memory:    3254 MB
    Kernel:    4.1.12-37.4.1.el6uek.x86_64

    ----------------------------------------
    [vagrant@ora12c-si-asm-oel681 ~]$ sudo su - oracle
    [oracle@ora12c-si-asm-oel681 ~]$ df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda2              47G  2.4G   43G   6% /
    tmpfs                 1.6G  1.1G  580M  65% /dev/shm
    /dev/mapper/vgora-lvora
                           74G   18G   53G  26% /u01
    /dev/sr0               56M   56M     0 100% /mnt
    [oracle@ora12c-si-asm-oel681 ~]$ ps -eaf | grep pmon
    oracle   15488     1  0 15:46 ?        00:00:05 ora_pmon_orclcdb
    oracle   24473     1  0 14:03 ?        00:00:05 asm_pmon_+ASM
    oracle   31671 31653  0 22:57 pts/0    00:00:00 grep pmon
    [oracle@ora12c-si-asm-oel681 ~]$ tail /etc/oratab
    # The first and second fields are the system identifier and home
    # directory of the database respectively.  The third field indicates
    # to the dbstart utility that the database should , "Y", or should not,
    # "N", be brought up at system boot time.
    #
    # Multiple entries with the same $ORACLE_SID are not allowed.
    #
    #
    +ASM:/u01/app/oracle/12.1.0.2/grid:N            # line added by Agent
    orclcdb:/u01/app/oracle/12.1.0.2/db1:N          # line added by Agent
    [oracle@ora12c-si-asm-oel681 ~]$ . oraenv
    ORACLE_SID = [orcldb] ? orclcdb
    The Oracle base has been set to /u01/app/oracle
    [oracle@ora12c-si-asm-oel681 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.2.0 Production on Wed Jan 24 22:58:15 2018

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


    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options

    22:58:23 SYS @ orclcdb:>set lines 180 pages 180
    22:58:25 SYS @ orclcdb:>archive log list;
    Database log mode              No Archive Mode
    Automatic archival             Disabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     6
    Current log sequence           8
    22:58:25 SYS @ orclcdb:>show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  NO
             3 ORCL                           READ WRITE NO
    22:58:27 SYS @ orclcdb:>alter session set container=orcl;

    Session altered.

    22:58:40 SYS @ orclcdb:>select file_name from dba_data_files;

    FILE_NAME
    ------------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------
    +DATA/ORCLCDB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/system.269.966268047
    +DATA/ORCLCDB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/sysaux.270.966268047
    +DATA/ORCLCDB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/users.272.966268171

    22:59:28 SYS @ orclcdb:>exit
    Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options
    [oracle@ora12c-si-asm-oel681 ~]$ ifconfig | grep "inet "
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet addr:192.168.9.70  Bcast:192.168.9.255  Mask:255.255.255.0
          inet addr:172.16.56.30  Bcast:172.16.56.255  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0
   
    [oracle@ora12c-si-asm-oel681 ~]$ ssh 172.16.56.31
    oracle@172.16.56.31's password:

    ----------------------------------------
    Welcome to ora12c-si-asm-oel682
    OracleLinux 6.8 x86_64

    FQDN: ora12c-si-asm-oel682.internal.lab
    IP:   10.0.2.15

    Processor: Intel(R) Core(TM) i7-4600M CPU @ 2.90GHz
    #CPU's:    1
    Memory:    3254 MB
    Kernel:    4.1.12-37.4.1.el6uek.x86_64

    ----------------------------------------
    [oracle@ora12c-si-asm-oel682 ~]$
    [oracle@ora12c-si-asm-oel682 ~]$ ps -eaf | grep pmon
    oracle    7285     1  0 15:29 ?        00:00:05 ora_pmon_orclcdb
    oracle   19530 19514  0 23:11 pts/0    00:00:00 grep pmon
    oracle   21172     1  0 14:03 ?        00:00:05 asm_pmon_+ASM

Me interesa configurar una de ellas como standby, digamos en ora12c-si-asm-oel682.

Este es un resumen de los pasos que vamos a seguir, usando RMAN duplicate para la copia inicial de la base, y Dataguard Broker para configurar la replicación hacia la base standby.

Agrego un paso extra (6) para evitar un error al usar RMAN en el siguiente.
Esto es particular de este ambiente de pruebas, no es algo necesario siempre.

    1) ajustar la base primaria:
        a) habilitar force_logging
        b) habilitar archivado
        c) agregar standby redo logs
        d) habilitar DataGuard Broker
    2) agregar entradas en tnsnames.ora de ambos servidores
    3) agregar una entrada al listener.ora en el servidor standby
    4) parar la base corriendo en la standby
    5) iniciar la base standby con un archivo de arranque ajustado (init.ora)
    6) crear alias en ASM para el spfile en la primaria
    7) crear la base standby usando RMAN duplicate from active
    8) habilitar standby usando DataGuard Broker

Y estos son los detalles de aplicar estos pasos.
Al final incluyo como referencia los dos problemas que encontré y son evitados al seguir los pasos anteriores.

1) Ajustes en la base primaria


   force_logging y archivado son necesario en la base primaria para configurar una standby.
   Agregar standby redo logs es algo recomendado para estar preparados para un cambio de rol, pero no es obligatorio.
   Yo lo agrego para que no se muestren alertas al final al usar Dataguard Broker
  
    [oracle@ora12c-si-asm-oel681 ~]$ sqlplus / as sysdba
    SQL*Plus: Release 12.1.0.2.0 Production on Wed Jan 24 23:12:13 2018

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


    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options

    23:12:13 SYS @ orclcdb:>alter database force logging;
    Database altered.

    23:12:25 SYS @ orclcdb:>archive log list;
    Database log mode              No Archive Mode
    Automatic archival             Disabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     6
    Current log sequence           8

    23:13:08 SYS @ orclcdb:>alter system set dg_broker_start=true;

    System altered.

    23:13:20 SYS @ orclcdb:>set lines 180 pages 180
    23:13:24 SYS @ orclcdb:>select group#, thread#, bytes/1024/1024 from v$log order by 1;

        GROUP#    THREAD# BYTES/1024/1024
    ---------- ---------- ---------------
             1          1             100
             2          1             100
             3          1             100
             4          1             100


    23:14:50 SYS @ orclcdb:>alter database add standby logfile ('+DATA','+FRA') size 100M;

    Database altered.

    23:14:55 SYS @ orclcdb:>alter database add standby logfile ('+DATA','+FRA') size 100M;

    Database altered.

    23:14:57 SYS @ orclcdb:>alter database add standby logfile ('+DATA','+FRA') size 100M;

    Database altered.
   
    23:14:59 SYS @ orclcdb:>alter database add standby logfile ('+DATA','+FRA') size 100M;

    Database altered.
   
    23:15:08 SYS @ orclcdb:>col member for a50
    23:15:12 SYS @ orclcdb:>select * from v$logfile order by type, group#;

        GROUP# STATUS  TYPE    MEMBER                                             IS_     CON_ID
    ---------- ------- ------- -------------------------------------------------- --- ----------
             1         ONLINE  +DATA/ORCLCDB/ONLINELOG/group_1.261.966265055      NO           0
             1         ONLINE  +FRA/ORCLCDB/ONLINELOG/group_1.257.966265067       YES          0
             2         ONLINE  +DATA/ORCLCDB/ONLINELOG/group_2.262.966303565      NO           0
             2         ONLINE  +FRA/ORCLCDB/ONLINELOG/group_2.258.966303569       NO           0
             7         ONLINE  +DATA/ORCLCDB/ONLINELOG/group_7.276.966303573      NO           0
             7         ONLINE  +FRA/ORCLCDB/ONLINELOG/group_7.265.966303577       NO           0
             8         ONLINE  +FRA/ORCLCDB/ONLINELOG/group_8.266.966303587       NO           0
             8         ONLINE  +DATA/ORCLCDB/ONLINELOG/group_8.277.966303583      NO           0
             3         STANDBY +DATA/ORCLCDB/ONLINELOG/group_3.263.966307683      NO           0
             3         STANDBY +FRA/ORCLCDB/ONLINELOG/group_3.268.966307685       NO           0
             4         STANDBY +FRA/ORCLCDB/ONLINELOG/group_4.262.966303491       NO           0
             4         STANDBY +DATA/ORCLCDB/ONLINELOG/group_4.273.966303489      NO           0
             5         STANDBY +DATA/ORCLCDB/ONLINELOG/group_5.275.966303495      NO           0
             5         STANDBY +FRA/ORCLCDB/ONLINELOG/group_5.264.966303499       NO           0
             6         STANDBY +DATA/ORCLCDB/ONLINELOG/group_6.274.966303325      NO           0
             6         STANDBY +FRA/ORCLCDB/ONLINELOG/group_6.263.966303329       NO           0

    16 rows selected.

    23:15:28 SYS @ orclcdb:>shutdown immediate;
    Database closed.
    Database dismounted.
    ORACLE instance shut down.

    23:15:57 SYS @ orclcdb:>startup mount;
    ORACLE instance started.

    Total System Global Area 1073741824 bytes
    Fixed Size                  2932632 bytes
    Variable Size             666894440 bytes
    Database Buffers          398458880 bytes
    Redo Buffers                5455872 bytes
    Database mounted.

    23:16:19 SYS @ orclcdb:>alter database archivelog;

    Database altered.

    23:16:21 SYS @ orclcdb:>startup force;
    ORACLE instance started.

    Total System Global Area 1073741824 bytes
    Fixed Size                  2932632 bytes
    Variable Size             666894440 bytes
    Database Buffers          398458880 bytes
    Redo Buffers                5455872 bytes
    Database mounted.
    Database opened.
    23:17:03 SYS @ orclcdb:>archive log list;
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     6
    Next log sequence to archive   8
    Current log sequence           8
    23:17:05 SYS @ orclcdb:>exit
    Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options

Notar que es una práctica recomendada crear standby redo logs con un grupo más de los usados en la primaria.
En este ejemplo no es realmente necesario ya que no se va a poner nunca en producción, pero hay que tenerlo presente si van a seguir un procedimiento similar en producción.


2) agregar entradas en tnsnames.ora de ambos servidores


En 12c todo debería funcionar con Easy Connect, pero en mis pruebas no siempre anduvo bien, así que por simplicidad configuramos las entradas en los archivos tnsnames.ora

En primaria:

    [oracle@ora12c-si-asm-oel681 ~]$ vi /u01/app/oracle/12.1.0.2/db1/network/admin/tnsnames.ora
    [oracle@ora12c-si-asm-oel681 ~]$ cat /u01/app/oracle/12.1.0.2/db1/network/admin/tnsnames.ora
    # tnsnames.ora Network Configuration File: /u01/app/oracle/12.1.0.2/db1/network/admin/tnsnames.ora
    # Generated by Oracle configuration tools.

    primary,ORCLCDB =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel681.internal.lab)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orclcdb)
        )
      )

    standby,orclstb =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel682)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orclstb)
        )
      )

En standby:

    [oracle@ora12c-si-asm-oel682 admin]$ vi /u01/app/oracle/12.1.0.2/db1/network/admin/tnsnames.ora
    [oracle@ora12c-si-asm-oel682 admin]$ cat
/u01/app/oracle/12.1.0.2/db1/network/admin/tnsnames.ora
    # tnsnames.ora Network Configuration File: /u01/app/oracle/12.1.0.2/db1/network/admin/tnsnames.ora
    # Generated by Oracle configuration tools.

    LISTENER_orclcdb =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel682)(PORT = 1521))

    primary,ORCLCDB =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel681.internal.lab)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orclcdb)
        )
      )

    standby,orclstb =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel682)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orclstb)
        )
      )

3) agregar una entrada al listener.ora en el servidor standby


    [oracle@ora12c-si-asm-oel682 oracle]$ vi /u01/app/oracle/12.1.0.2/grid/network/admin/listener.ora
    [oracle@ora12c-si-asm-oel682 oracle]$ cat /u01/app/oracle/12.1.0.2/grid/network/admin/listener.ora
    # listener.ora Network Configuration File: /u01/app/oracle/12.1.0.2/grid/network/admin/listener.ora
    # Generated by Oracle configuration tools.

    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel682.internal.lab)(PORT = 1521))
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        )
      )

    # ncalero: static entry for standby:
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = orclstb)
          (ORACLE_HOME = /u01/app/oracle/12.1.0.2/db1)
          (SID_NAME = orclcdb)
        )
     )

    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent
    VALID_NODE_CHECKING_REGISTRATION_LISTENER=SUBNET                # line added by Agent

    [oracle@ora12c-si-asm-oel682 oracle]$ /u01/app/oracle/12.1.0.2/grid/bin/lsnrctl reload listener

    LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 24-JAN-2018 23:29:27

    Copyright (c) 1991, 2014, Oracle.  All rights reserved.

    Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
    The command completed successfully
    [oracle@ora12c-si-asm-oel682 oracle]$
    [oracle@ora12c-si-asm-oel682 oracle]$ tail /etc/oratab
    # directory of the database respectively.  The third field indicates
    # to the dbstart utility that the database should , "Y", or should not,
    # "N", be brought up at system boot time.
    #
    # Multiple entries with the same $ORACLE_SID are not allowed.
    #
    #
    +ASM:/u01/app/oracle/12.1.0.2/grid:N            # line added by Agent
    orclcdb:/u01/app/oracle/12.1.0.2/db1:N          # line added by Agent

4) parar la base corriendo en la standby


Esta VM tiene una base igual que la primaria y no la necesitamos.
Podemos borrarla y de paso liberar espacio de ASM, o solo detenerla y continuar con este ejemplo, ya que el espacio en disco alcanza.

    [oracle@ora12c-si-asm-oel682 dbs]$ . oraenv
    ORACLE_SID = [orclcdb] ?
    [oracle@ora12c-si-asm-oel682 dbs]$ srvctl status database -d orclcdb
    Database is running.
    [oracle@ora12c-si-asm-oel682 dbs]$ srvctl stop database -d orclcdb
    [oracle@ora12c-si-asm-oel682 dbs]$

Solo para evitar problemas con la configuración en el futuro, borro la base configurada en clusterware, ya que la configuración cambió:

    [oracle@ora12c-si-asm-oel682 dbs]$ srvctl remove database -d orclcdb
    Remove the database orclcdb? (y/[n]) y
    [oracle@ora12c-si-asm-oel682 dbs]$
   

5) iniciar la base standby con un archivo de arranque ajustado (init.ora)


Vamos a quitar el spfile que usaba la base anterior, y crear un archivo de parámetros mínimo para la nueva standby para poder levantarla en modo nomount.
Luego cuando ejecutamos el comando RMAN duplicate vamos a poner todos los parámetros necesarios para la standby.

    [oracle@ora12c-si-asm-oel682 dbs]$ . oraenv
    ORACLE_SID = [orclcdb] ?
    The Oracle base remains unchanged with value /u01/app/oracle
    [oracle@ora12c-si-asm-oel682 oracle]$ cd $ORACLE_HOME
    [oracle@ora12c-si-asm-oel682 db1]$ pwd
    /u01/app/oracle/12.1.0.2/db1
    [oracle@ora12c-si-asm-oel682 db1]$ cd dbs
    [oracle@ora12c-si-asm-oel682 dbs]$ mv spfileorclcdb.ora spfileorclcdb-bad.ora
    [oracle@ora12c-si-asm-oel682 dbs]$ echo '*.db_name=orclcdb' > initorclcdb.ora
    [oracle@ora12c-si-asm-oel682 dbs]$ cat initorclcdb.ora
    *.db_name=orclcdb
    [oracle@ora12c-si-asm-oel682 dbs]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.2.0 Production on Wed Jan 24 23:47:34 2018

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

    Connected to an idle instance.

    23:47:35 SYS @ orclcdb:>startup nomount;
    ORACLE instance started.

    Total System Global Area  218103808 bytes
    Fixed Size                  2922712 bytes
    Variable Size             159385384 bytes
    Database Buffers           50331648 bytes
    Redo Buffers                5464064 bytes
    23:47:41 SYS @ orclcdb:>exit
    Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
    [oracle@ora12c-si-asm-oel682 dbs]$
    [oracle@ora12c-si-asm-oel682 dbs]$ ps -eaf | grep pmon
    oracle   21258     1  0 13:43 ?        00:00:01 asm_pmon_+ASM
    oracle   25855     1  0 23:47 ?        00:00:00 ora_pmon_orclcdb
    oracle   25907 23932  0 23:48 pts/1    00:00:00 grep pmon
    [oracle@ora12c-si-asm-oel682 dbs]$      


6) crear alias en ASM para el spfile en la primaria


    [oracle@ora12c-si-asm-oel681 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.2.0 Production on Thu Jan 25 00:43:22 2018

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


    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options

    00:43:22 SYS @ orclcdb:>show parameter spfile

    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    spfile                               string      +DATA/ORCLCDB/PARAMETERFILE/sp
                                                     file.268.966266805
    00:43:24 SYS @ orclcdb:> exit


    [oracle@ora12c-si-asm-oel681 ~]$ cd $ORACLE_HOME/dbs
    [oracle@ora12c-si-asm-oel681 dbs]$ ls -lrt
    total 24
    -rw-r--r--. 1 oracle oinstall 2992 Feb  3  2012 init.ora
    -rw-r-----. 1 oracle dba        24 Jan 24 14:49 lkORCLCDB
    -rw-r-----. 1 oracle oinstall 7680 Jan 24 15:26 orapworclcdb
    -rw-r-----. 1 oracle oinstall   41 Jan 24 15:45 initorclcdb.ora
    -rw-rw----. 1 oracle dba      1544 Jan 25 00:49 hc_orclcdb.dat
    [oracle@ora12c-si-asm-oel681 dbs]$ cat initorclcdb.ora
    SPFILE='+DATA/orclcdb/spfileorclcdb.ora'
    [oracle@ora12c-si-asm-oel681 dbs]$ . oraenv
    ORACLE_SID = [orclcdb] ? +ASM
    The Oracle base remains unchanged with value /u01/app/oracle
    [oracle@ora12c-si-asm-oel681 dbs]$ asmcmd
    ASMCMD> cd data/orclcdb
    ASMCMD> ls spfileorclcdb.ora
    ASMCMD-8002: entry 'spfileorclcdb.ora' does not exist in directory '+data/orclcdb/'
    ASMCMD> cd parameterfile
    ASMCMD> ls
    spfile.268.966266805
    ASMCMD> cd ..
    ASMCMD> mkalias parameterfile/spfile.268.966266805 spfileorclcdb.ora
    ASMCMD> ls
    63871D5DE1F02321E0534609A8C0357B/
    6387BBFEF9833D92E0534609A8C0BF8E/
    CONTROLFILE/
    DATAFILE/
    FD9AC20F64D244D7E043B6A9E80A2F2F/
    ONLINELOG/
    PARAMETERFILE/
    TEMPFILE/
    spfileorclcdb.ora
    ASMCMD> exit

7) crear la base standby usando RMAN duplicate from active


Antes de lanzar RMAN, validamos conectivitidad SQL*Net a ambas bases desde la primaria:
   
    [oracle@ora12c-si-asm-oel681 ~]$ . oraenv
    ORACLE_SID = [+ASM] ? orclcdb
    The Oracle base remains unchanged with value /u01/app/oracle

    [oracle@ora12c-si-asm-oel681 ~]$ tnsping orclcdb

    TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 25-JAN-2018 01:26:03

    Copyright (c) 1997, 2014, Oracle.  All rights reserved.

    Used parameter files:


    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel681.internal.lab)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orclcdb)))
    OK (20 msec)
    [oracle@ora12c-si-asm-oel681 ~]$ tnsping orclstb

    TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 25-JAN-2018 01:26:06

    Copyright (c) 1997, 2014, Oracle.  All rights reserved.

    Used parameter files:


    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora12c-si-asm-oel682)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orclstb)))
    OK (10 msec)

    [oracle@ora12c-si-asm-oel681 ~]$ sqlplus sys/Oracle123@orclstb as sysdba

    SQL*Plus: Release 12.1.0.2.0 Production on Wed Jan 25 01:26:17 2018

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


    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

    01:26:17 SYS @ orclstb:>exit
    Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

   
Ahora sí, lanzamos el backup:

    RMAN> run
    2> {
    3> allocate channel c1 type disk;
    4> allocate channel c2 type disk;
    5> allocate auxiliary channel aux type disk;
    6> duplicate target database for standby from active database nofilenamecheck spfile
    7>    set log_archive_max_processes='8'
    8>    set memory_target='0'
    9>    set sga_target='768M'
    10>   set pga_aggregate_target='256M'
    11>   set db_unique_name='orclstb'
    12>   set db_create_file_dest='+DATA'
    13>   set DB_CREATE_ONLINE_LOG_DEST_1='+DATA'
    14>   set DB_RECOVERY_FILE_DEST='+FRA'
    15>   set DB_RECOVERY_FILE_DEST_SIZE='10G'
    16>   set standby_file_management='AUTO';
    17>  }


    using target database control file instead of recovery catalog
    allocated channel: c1
    channel c1: SID=76 device type=DISK

    allocated channel: c2
    channel c2: SID=57 device type=DISK

    allocated channel: aux
    channel aux: SID=1 device type=DISK

    Starting Duplicate Db at 25-JAN-18

    contents of Memory Script:
    {
       backup as copy reuse
       targetfile  '/u01/app/oracle/12.1.0.2/db1/dbs/orapworclcdb' auxiliary format
     '/u01/app/oracle/12.1.0.2/db1/dbs/orapworclcdb'   targetfile
     '+DATA/orclcdb/spfileorclcdb.ora' auxiliary format
     '/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora'   ;
       sql clone "alter system set spfile= ''/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora''";
    }
    executing Memory Script

    Starting backup at 25-JAN-18
    Finished backup at 25-JAN-18

    sql statement: alter system set spfile= ''/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora''

    contents of Memory Script:
    {
       sql clone "alter system set  log_archive_max_processes =
     8 comment=
     '''' scope=spfile";
       sql clone "alter system set  memory_target =
     0 comment=
     '''' scope=spfile";
       sql clone "alter system set  sga_target =
     768M comment=
     '''' scope=spfile";
       sql clone "alter system set  pga_aggregate_target =
     256M comment=
     '''' scope=spfile";
       sql clone "alter system set  db_unique_name =
     ''orclstb'' comment=
     '''' scope=spfile";
       sql clone "alter system set  db_create_file_dest =
     ''+DATA'' comment=
     '''' scope=spfile";
       sql clone "alter system set  DB_CREATE_ONLINE_LOG_DEST_1 =
     ''+DATA'' comment=
     '''' scope=spfile";
       sql clone "alter system set  db_recovery_file_dest =
     ''+FRA'' comment=
     '''' scope=spfile";
       sql clone "alter system set  DB_RECOVERY_FILE_DEST_SIZE =
     10G comment=
     '''' scope=spfile";
       sql clone "alter system set  standby_file_management =
     ''AUTO'' comment=
     '''' scope=spfile";
       shutdown clone immediate;
       startup clone nomount;
    }
    executing Memory Script

    sql statement: alter system set  log_archive_max_processes =  8 comment= '''' scope=spfile

    sql statement: alter system set  memory_target =  0 comment= '''' scope=spfile

    sql statement: alter system set  sga_target =  768M comment= '''' scope=spfile

    sql statement: alter system set  pga_aggregate_target =  256M comment= '''' scope=spfile

    sql statement: alter system set  db_unique_name =  ''orclstb'' comment= '''' scope=spfile

    sql statement: alter system set  db_create_file_dest =  ''+DATA'' comment= '''' scope=spfile

    sql statement: alter system set  DB_CREATE_ONLINE_LOG_DEST_1 =  ''+DATA'' comment= '''' scope=spfile

    sql statement: alter system set  db_recovery_file_dest =  ''+FRA'' comment= '''' scope=spfile

    sql statement: alter system set  DB_RECOVERY_FILE_DEST_SIZE =  10G comment= '''' scope=spfile

    sql statement: alter system set  standby_file_management =  ''AUTO'' comment= '''' scope=spfile

    Oracle instance shut down

    connected to auxiliary database (not started)
    Oracle instance started

    Total System Global Area     805306368 bytes

    Fixed Size                     2929552 bytes
    Variable Size                318770288 bytes
    Database Buffers             478150656 bytes
    Redo Buffers                   5455872 bytes
    allocated channel: aux
    channel aux: SID=28 device type=DISK

    contents of Memory Script:
    {
       sql clone "alter system set  control_files =
      ''+DATA/ORCLSTB/CONTROLFILE/current.289.967913439'', ''+FRA/ORCLSTB/CONTROLFILE/current.261.967913439'' comment=
     ''Set by RMAN'' scope=spfile";
       backup as copy current controlfile for standby auxiliary format  '+DATA/ORCLSTB/CONTROLFILE/current.288.967913439';
       restore clone primary controlfile to  '+FRA/ORCLSTB/CONTROLFILE/current.275.967913439' from
     '+DATA/ORCLSTB/CONTROLFILE/current.288.967913439';
       sql clone "alter system set  control_files =
      ''+DATA/ORCLSTB/CONTROLFILE/current.288.967913439'', ''+FRA/ORCLSTB/CONTROLFILE/current.275.967913439'' comment=
     ''Set by RMAN'' scope=spfile";
       shutdown clone immediate;
       startup clone nomount;
    }
    executing Memory Script

    sql statement: alter system set  control_files =   ''+DATA/ORCLSTB/CONTROLFILE/current.289.967913439'', ''+FRA/ORCLSTB/CONTROLFILE/current.261.967913439'' comment= ''Set by RMAN'' scope=spfile

    Starting backup at 25-JAN-18
    channel c1: starting datafile copy
    copying standby control file
    output file name=/u01/app/oracle/12.1.0.2/db1/dbs/snapcf_orclcdb.f tag=TAG20180125T034620
    channel c1: datafile copy complete, elapsed time: 00:00:07
    Finished backup at 25-JAN-18

    Starting restore at 25-JAN-18

    channel aux: copied control file copy
    Finished restore at 25-JAN-18

    sql statement: alter system set  control_files =   ''+DATA/ORCLSTB/CONTROLFILE/current.288.967913439'', ''+FRA/ORCLSTB/CONTROLFILE/current.275.967913439'' comment= ''Set by RMAN'' scope=spfile

    Oracle instance shut down

    connected to auxiliary database (not started)
    Oracle instance started

    Total System Global Area     805306368 bytes

    Fixed Size                     2929552 bytes
    Variable Size                318770288 bytes
    Database Buffers             478150656 bytes
    Redo Buffers                   5455872 bytes
    allocated channel: aux
    channel aux: SID=28 device type=DISK

    contents of Memory Script:
    {
       sql clone 'alter database mount standby database';
    }
    executing Memory Script

    sql statement: alter database mount standby database

    contents of Memory Script:
    {
       set newname for clone tempfile  1 to new;
       set newname for clone tempfile  2 to new;
       set newname for clone tempfile  3 to new;
       switch clone tempfile all;
       set newname for clone datafile  1 to new;
       set newname for clone datafile  3 to new;
       set newname for clone datafile  4 to new;
       set newname for clone datafile  5 to new;
       set newname for clone datafile  6 to new;
       set newname for clone datafile  7 to new;
       set newname for clone datafile  8 to new;
       set newname for clone datafile  9 to new;
       set newname for clone datafile  10 to new;
       backup as copy reuse
       datafile  1 auxiliary format new
       datafile  3 auxiliary format new
       datafile  4 auxiliary format new
       datafile  5 auxiliary format new
       datafile  6 auxiliary format new
       datafile  7 auxiliary format new
       datafile  8 auxiliary format new
       datafile  9 auxiliary format new
       datafile  10 auxiliary format new
       ;
       sql 'alter system archive log current';
    }
    executing Memory Script

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    renamed tempfile 1 to +DATA in control file
    renamed tempfile 2 to +DATA in control file
    renamed tempfile 3 to +DATA in control file

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    Starting backup at 25-JAN-18
    channel c1: starting datafile copy
    input datafile file number=00001 name=+DATA/ORCLCDB/DATAFILE/system.257.966264763
    channel c2: starting datafile copy
    input datafile file number=00003 name=+DATA/ORCLCDB/DATAFILE/sysaux.256.966264621
    output file name=+DATA/ORCLSTB/DATAFILE/sysaux.286.967913491 tag=TAG20180125T034709
    channel c2: datafile copy complete, elapsed time: 00:01:46
    channel c2: starting datafile copy
    input datafile file number=00009 name=+DATA/ORCLCDB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/sysaux.270.966268047
    output file name=+DATA/ORCLSTB/DATAFILE/system.287.967913491 tag=TAG20180125T034709
    channel c1: datafile copy complete, elapsed time: 00:01:50
    channel c1: starting datafile copy
    input datafile file number=00007 name=+DATA/ORCLCDB/FD9AC20F64D244D7E043B6A9E80A2F2F/DATAFILE/sysaux.265.966265243
    output file name=+DATA/ORCLSTB/63871D5DE1F02321E0534609A8C0357B/DATAFILE/sysaux.284.967913601 tag=TAG20180125T034709
    channel c1: datafile copy complete, elapsed time: 00:01:26
    channel c1: starting datafile copy
    input datafile file number=00005 name=+DATA/ORCLCDB/FD9AC20F64D244D7E043B6A9E80A2F2F/DATAFILE/system.266.966265245
    output file name=+DATA/ORCLSTB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/sysaux.285.967913599 tag=TAG20180125T034709
    channel c2: datafile copy complete, elapsed time: 00:01:28
    channel c2: starting datafile copy
    input datafile file number=00008 name=+DATA/ORCLCDB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/system.269.966268047
    output file name=+DATA/ORCLSTB/63871D5DE1F02321E0534609A8C0357B/DATAFILE/system.279.967913687 tag=TAG20180125T034709
    channel c1: datafile copy complete, elapsed time: 00:00:45
    channel c1: starting datafile copy
    input datafile file number=00004 name=+DATA/ORCLCDB/DATAFILE/undotbs1.259.966264923
    output file name=+DATA/ORCLSTB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/system.278.967913687 tag=TAG20180125T034709
    channel c2: datafile copy complete, elapsed time: 00:00:46
    channel c2: starting datafile copy
    input datafile file number=00006 name=+DATA/ORCLCDB/DATAFILE/users.258.966264919
    output file name=+DATA/ORCLSTB/DATAFILE/users.277.967913735 tag=TAG20180125T034709
    channel c2: datafile copy complete, elapsed time: 00:00:07
    channel c2: starting datafile copy
    input datafile file number=00010 name=+DATA/ORCLCDB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/users.272.966268171
    output file name=+DATA/ORCLSTB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/users.282.967913743 tag=TAG20180125T034709
    channel c2: datafile copy complete, elapsed time: 00:00:03
    output file name=+DATA/ORCLSTB/DATAFILE/undotbs1.280.967913733 tag=TAG20180125T034709
    channel c1: datafile copy complete, elapsed time: 00:00:16
    Finished backup at 25-JAN-18

    sql statement: alter system archive log current

    contents of Memory Script:
    {
       switch clone datafile all;
    }
    executing Memory Script

    datafile 1 switched to datafile copy
    input datafile copy RECID=3 STAMP=967913751 file name=+DATA/ORCLSTB/DATAFILE/system.287.967913491
    datafile 3 switched to datafile copy
    input datafile copy RECID=4 STAMP=967913751 file name=+DATA/ORCLSTB/DATAFILE/sysaux.286.967913491
    datafile 4 switched to datafile copy
    input datafile copy RECID=5 STAMP=967913752 file name=+DATA/ORCLSTB/DATAFILE/undotbs1.280.967913733
    datafile 5 switched to datafile copy
    input datafile copy RECID=6 STAMP=967913752 file name=+DATA/ORCLSTB/63871D5DE1F02321E0534609A8C0357B/DATAFILE/system.279.967913687
    datafile 6 switched to datafile copy
    input datafile copy RECID=7 STAMP=967913752 file name=+DATA/ORCLSTB/DATAFILE/users.277.967913735
    datafile 7 switched to datafile copy
    input datafile copy RECID=8 STAMP=967913753 file name=+DATA/ORCLSTB/63871D5DE1F02321E0534609A8C0357B/DATAFILE/sysaux.284.967913601
    datafile 8 switched to datafile copy
    input datafile copy RECID=9 STAMP=967913753 file name=+DATA/ORCLSTB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/system.278.967913687
    datafile 9 switched to datafile copy
    input datafile copy RECID=10 STAMP=967913754 file name=+DATA/ORCLSTB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/sysaux.285.967913599
    datafile 10 switched to datafile copy
    input datafile copy RECID=11 STAMP=967913754 file name=+DATA/ORCLSTB/6387BBFEF9833D92E0534609A8C0BF8E/DATAFILE/users.282.967913743
    Finished Duplicate Db at 25-JAN-18
    released channel: c1
    released channel: c2
    released channel: aux

    RMAN> exit


    Recovery Manager complete.

   
Podemos ver el espacio usado en ASM del servidor standby por la nueva base:

    [oracle@ora12c-si-asm-oel682 ~]$ . oraenv
    ORACLE_SID = [orclcdb] ? +ASM
    The Oracle base remains unchanged with value /u01/app/oracle
    [oracle@ora12c-si-asm-oel682 ~]$ asmcmd
    ASMCMD> lsdg
    State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
    MOUNTED  EXTERN  N         512   4096  4194304     10236    10140                0           10140              0             N  CRS/
    MOUNTED  EXTERN  N         512   4096  4194304     20472    16472                0           16472              0             N  DATA/
    MOUNTED  EXTERN  N         512   4096  4194304     30708    29536                0           29536              0             N  FRA/
   
ASMCMD>

8) Configurar standby usando DataGuard Broker


    [oracle@ora12c-si-asm-oel681 admin]$ dgmgrl /
    DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production

    Copyright (c) 2000, 2013, Oracle. All rights reserved.

    Welcome to DGMGRL, type "help" for information.
    Connected as SYSDG.
    DGMGRL> create configuration orcl_dg as primary database is orclcdb connect identifier is orclcdb;
    Configuration "orcl_dg" created with primary database "orclcdb"
    DGMGRL> add database orclstb as connect identifier is orclstb maintained as physical;
    Database "orclstb" added
    DGMGRL> enable configuration
    Enabled.
    DGMGRL> show configuration

    Configuration - orcl_dg

      Protection Mode: MaxPerformance
      Members:
      orclcdb - Primary database
        orclstb - Physical standby database

    Fast-Start Failover: DISABLED

    Configuration Status:
    SUCCESS   (status updated 50 seconds ago)

    DGMGRL> show database orclstb

    Database - orclstb

      Role:               PHYSICAL STANDBY
      Intended State:     APPLY-ON
      Transport Lag:      0 seconds (computed 46 seconds ago)
      Apply Lag:          0 seconds (computed 46 seconds ago)
      Average Apply Rate: 456.00 KByte/s
      Real Time Query:    OFF
      Instance(s):
        orclcdb

      Database Warning(s):
        ORA-16857: standby disconnected from redo source for longer than specified threshold

    Database Status:
    WARNING

    DGMGRL> show database orclstb

    Database - orclstb

      Role:               PHYSICAL STANDBY
      Intended State:     APPLY-ON
      Transport Lag:      1 minute 22 seconds (computed 9 seconds ago)
      Apply Lag:          1 minute 22 seconds (computed 9 seconds ago)
      Average Apply Rate: 456.00 KByte/s
      Real Time Query:    OFF
      Instance(s):
        orclcdb

    Database Status:
    SUCCESS

    DGMGRL> exit


Como vemos le toma unos segundos activar la configuración hasta que no se reportan más errores.

Validaciones


En la base primaria podemos ver que el envío de logs está funcionando:

    [oracle@ora12c-si-asm-oel681 admin]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.2.0 Production on Thu Jan 25 04:05:41 2018

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


    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options

    04:05:41 SYS @ orclcdb:>set lines 180 pages 180
    04:07:09 SYS @ orclcdb:>col dest_name for a20
    04:07:11 SYS @ orclcdb:>select dest_id, dest_name, status, db_unique_name, database_mode,recovery_mode, archived_seq#,error, gap_status
    04:07:11   2  from V$ARCHIVE_DEST_STATUS
    04:07:11   3  where status !='INACTIVE';

       DEST_ID DEST_NAME            STATUS    DB_UNIQUE_NAME                 DATABASE_MODE   RECOVERY_MODE           ARCHIVED_SEQ#
    ---------- -------------------- --------- ------------------------------ --------------- ----------------------- -------------
    ERROR                                                             GAP_STATUS
    ----------------------------------------------------------------- ------------------------
             1 LOG_ARCHIVE_DEST_1   VALID     NONE                           OPEN            IDLE                               17


             2 LOG_ARCHIVE_DEST_2   VALID     orclstb                        MOUNTED-STANDBY MANAGED REAL TIME APPLY            17
                                                                      NO GAP


    04:07:12 SYS @ orclcdb:>archive log list;
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            USE_DB_RECOVERY_FILE_DEST
    Oldest online log sequence     15
    Next log sequence to archive   18
    Current log sequence           18
    04:07:21 SYS @ orclcdb:>exit
    Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options
    [oracle@ora12c-si-asm-oel681 admin]$
   
Y en la standby podemos ver que se reciben y aplican:

    [oracle@ora12c-si-asm-oel681 admin]$ ssh ora12c-si-asm-oel682
    oracle@ora12c-si-asm-oel682's password:
    Last login: Mon Feb 12 17:04:14 2018 from ora12c-si-asm-oel681.internal.lab

    ----------------------------------------
    Welcome to ora12c-si-asm-oel682
    OracleLinux 6.8 x86_64

    FQDN: ora12c-si-asm-oel682.internal.lab
    IP:   10.0.2.15

    Processor: Intel(R) Core(TM) i7-4600M CPU @ 2.90GHz
    #CPU's:    1
    Memory:    3254 MB
    Kernel:    4.1.12-37.4.1.el6uek.x86_64

    ----------------------------------------
    [oracle@ora12c-si-asm-oel682 ~]$ . oraenv
    ORACLE_SID = [oracle] ? orclcdb
    The Oracle base has been set to /u01/app/oracle
    [oracle@ora12c-si-asm-oel682 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.2.0 Production on Mon Feb 12 17:11:54 2018

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


    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options

    17:11:17 SYS @ orclcdb:>set lines 180 pages 180
    17:11:54 SYS @ orclcdb:>SELECT name,open_mode, DATABASE_ROLE, PROTECTION_MODE, PROTECTION_LEVEL FROM V$DATABASE;

    NAME      OPEN_MODE            DATABASE_ROLE    PROTECTION_MODE      PROTECTION_LEVEL
    --------- -------------------- ---------------- -------------------- --------------------
    ORCLCDB   MOUNTED              PHYSICAL STANDBY MAXIMUM PERFORMANCE  MAXIMUM PERFORMANCE

    17:12:23 SYS @ orclcdb:>select inst_id, pid, process, thread#, sequence#, status from gv$managed_standby where process='MRP0';

       INST_ID PID                      PROCESS      THREAD#  SEQUENCE# STATUS
    ---------- ------------------------ --------- ---------- ---------- ------------
             1 27307                    MRP0               1         18 WAIT_FOR_LOG

    17:12:30 SYS @ orclcdb:>exit
    Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
    With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
    and Real Application Testing options
    [oracle@ora12c-si-asm-oel682 ~]$ cd /u01/app/oracle/diag/rdbms/orclstb/orclcdb/trace/
    [oracle@ora12c-si-asm-oel682 trace]$ ls -lrt | tail
    -rw-r-----. 1 oracle dba   34895 Feb 12 17:07 drcorclcdb.log
    -rw-r-----. 1 oracle dba    3335 Feb 12 17:07 orclcdb_rfs_26965.trm
    -rw-r-----. 1 oracle dba   24927 Feb 12 17:07 orclcdb_rfs_26965.trc
    -rw-r-----. 1 oracle dba      82 Feb 12 17:07 orclcdb_rfs_27314.trm
    -rw-r-----. 1 oracle dba    1074 Feb 12 17:07 orclcdb_rfs_27314.trc
    -rw-r-----. 1 oracle dba     229 Feb 12 17:07 orclcdb_mrp0_27307.trm
    -rw-r-----. 1 oracle dba    3774 Feb 12 17:07 orclcdb_mrp0_27307.trc
    -rw-r-----. 1 oracle dba  348822 Feb 12 17:08 alert_orclcdb.log
    -rw-r-----. 1 oracle dba    2556 Feb 12 17:08 orclcdb_rsm0_26912.trm
    -rw-r-----. 1 oracle dba   13241 Feb 12 17:08 orclcdb_rsm0_26912.trc
    [oracle@ora12c-si-asm-oel682 trace]$ date
    Mon Feb 12 17:12:59 CET 2018
    [oracle@ora12c-si-asm-oel682 trace]$ tail alert_orclcdb.log
    Mon Feb 12 17:07:54 2018
    Media Recovery Log +FRA/ORCLSTB/ARCHIVELOG/2018_02_12/thread_1_seq_14.276.967913829
    Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT  NODELAY
    Mon Feb 12 17:07:55 2018
    Media Recovery Log +FRA/ORCLSTB/ARCHIVELOG/2018_02_12/thread_1_seq_15.277.967913829
    Mon Feb 12 17:07:56 2018
    Media Recovery Log +FRA/ORCLSTB/ARCHIVELOG/2018_02_12/thread_1_seq_16.278.967913831
    Mon Feb 12 17:07:58 2018
    Media Recovery Log +FRA/ORCLSTB/ARCHIVELOG/2018_02_12/thread_1_seq_17.279.967914469
    Media Recovery Waiting for thread 1 sequence 18 (in transit)
    [oracle@ora12c-si-asm-oel682 trace]$

Problemas encontrados


a) Si no creamos el alias en ASM (o ajustamos el nombre del spfile en el init, es otra solución posible), vamos a tener este error al intentar tomar un respaldo de la base primaria:

    [oracle@ora12c-si-asm-oel681 ~]$ rman target sys/Oracle123 auxiliary sys/Oracle123@orclstb

    Recovery Manager: Release 12.1.0.2.0 - Production on Wed Jan 24 23:49:57 2018

    Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

    connected to target database: ORCLCDB (DBID=2737326422)
    connected to auxiliary database: ORCLCDB (not mounted)

    RMAN> run
    2> {
    3> allocate channel c1 type disk;
    4> allocate channel c2 type disk;
    5> allocate auxiliary channel aux type disk;
    d6> uplicate target database for standby from active database nofilenamecheck spfile
      7> set log_archive_max_processes='8'
    8>   set db_unique_name='orclstb'
    9>   set standby_file_management='AUTO';
    10> }


    using target database control file instead of recovery catalog
    allocated channel: c1
    channel c1: SID=57 device type=DISK

    allocated channel: c2
    channel c2: SID=82 device type=DISK

    allocated channel: aux
    channel aux: SID=22 device type=DISK

    Starting Duplicate Db at 24-JAN-18

    contents of Memory Script:
    {
       backup as copy reuse
       targetfile  '/u01/app/oracle/12.1.0.2/db1/dbs/orapworclcdb' auxiliary format
     '/u01/app/oracle/12.1.0.2/db1/dbs/orapworclcdb'   targetfile
     '+DATA/orclcdb/spfileorclcdb.ora' auxiliary format
     '/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora'   ;
       sql clone "alter system set spfile= ''/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora''";
    }
    executing Memory Script

    Starting backup at 24-JAN-18
    released channel: c1
    released channel: c2
    released channel: aux
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of Duplicate Db command at 01/24/2018 23:51:46
    RMAN-05501: aborting duplication of target database
    RMAN-03015: error occurred in stored script Memory Script
    RMAN-03009: failure of backup command on c2 channel at 01/24/2018 23:51:46
    ORA-19505: failed to identify file "+DATA/orclcdb/spfileorclcdb.ora"
    ORA-15173: entry 'spfileorclcdb.ora' does not exist in directory 'orclcdb'

    RMAN> exit


    Recovery Manager complete.


b) Si no agregamos los parametros de memoria al usar RMAN, vamos a tener este error al intentar crear la copia:

    [oracle@ora12c-si-asm-oel681 ~]$ rman target sys/Oracle123 auxiliary sys/Oracle123@orclstb

    Recovery Manager: Release 12.1.0.2.0 - Production on Thu Jan 25 00:55:33 2018

    Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

    connected to target database: ORCLCDB (DBID=2737326422)
    connected to auxiliary database: ORCLCDB (not mounted)

    RMAN> run
    2> {
    3> allocate channel c1 type disk;
    a4> llocate channel c2 type disk;
    5> allocate auxiliary channel aux type disk;
    6> duplicate target database for standby from active database nofilenamecheck spfile
    7>   set log_archive_max_processes='8'
    8>   set db_unique_name='orclstb'
    9>   set standby_file_management='AUTO';
    10> }


    using target database control file instead of recovery catalog
    allocated channel: c1
    channel c1: SID=51 device type=DISK

    allocated channel: c2
    channel c2: SID=59 device type=DISK

    allocated channel: aux
    channel aux: SID=1 device type=DISK

    Starting Duplicate Db at 25-JAN-18

    contents of Memory Script:
    {
       backup as copy reuse
       targetfile  '/u01/app/oracle/12.1.0.2/db1/dbs/orapworclcdb' auxiliary format
     '/u01/app/oracle/12.1.0.2/db1/dbs/orapworclcdb'   targetfile
     '+DATA/orclcdb/spfileorclcdb.ora' auxiliary format
     '/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora'   ;
       sql clone "alter system set spfile= ''/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora''";
    }
    executing Memory Script

    Starting backup at 25-JAN-18
    Finished backup at 25-JAN-18

    sql statement: alter system set spfile= ''/u01/app/oracle/12.1.0.2/db1/dbs/spfileorclcdb.ora''

    contents of Memory Script:
    {
       sql clone "alter system set  log_archive_max_processes =
     8 comment=
     '''' scope=spfile";
       sql clone "alter system set  db_unique_name =
     ''orclstb'' comment=
     '''' scope=spfile";
       sql clone "alter system set  standby_file_management =
     ''AUTO'' comment=
     '''' scope=spfile";
       shutdown clone immediate;
       startup clone nomount;
    }
    executing Memory Script

    sql statement: alter system set  log_archive_max_processes =  8 comment= '''' scope=spfile

    sql statement: alter system set  db_unique_name =  ''orclstb'' comment= '''' scope=spfile

    sql statement: alter system set  standby_file_management =  ''AUTO'' comment= '''' scope=spfile

    Oracle instance shut down

    connected to auxiliary database (not started)
    released channel: c1
    released channel: c2
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of Duplicate Db command at 01/25/2018 00:57:53
    RMAN-05501: aborting duplication of target database
    RMAN-03015: error occurred in stored script Memory Script
    RMAN-04014: startup failed: ORA-00845: MEMORY_TARGET not supported on this system

    RMAN>

Conclusiones


Crear una configuración primary/standby en Oracle es un procedimiento conocido, y muy simple usando Dataguard broker.
Hay varias formas de crear la copia inicial de la base de datos, y en este artículo vimos como hacerlo usando RMAN duplicate from active.
Lo más importante aquí es mostrar los pasos adicionales necesarios para completar esta configuración si creamos las bases de forma automática usando Ansible, Vagrant y VirtualBox, como describí en el post anterior.

Un saludo.