Docker学习笔记_15 docker应用 - 部署Goldengate

OGG on docker准备

OGG MA是从OGG 12.3起被引入的,是一种以云计算为视角设计的架构。原有架构称为Traditional or Classic Architecture

GoldenGate Image没有现成的,需要手工生成。
由于ogg for oracle需要有OCI才能正常运行,所以可以直接使用docker oracle instant client image,在此基础上再安装ogg for oracle.
oracle docker images: https://github.com/oracle/docker-images

Build OracleInstantClient

mkdir /docker_build/oracle_instantclient/12.2.0.1
cd /docker_build/oracle_instantclient/12.2.0.1
cp /usr/share/zoneinfo/Asia/Shanghai .

# From http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
#  Download the following three RPMs:
#    - oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
#    - oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
#    - oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm 

vi Dockerfile
#-------------------------------------------------------------------------------------------------
FROM 10.240.4.159/os/oraclelinux:7.5

ADD Shanghai /etc/localtime
ADD oracle-instantclient*.rpm /tmp/
ADD rlwrap /usr/local/bin/

RUN yum -y install /tmp/oracle-instantclient*.rpm && \
    yum -y install lrzsz lsof unzip && \
    rm -rf /var/cache/yum && \
    rm -f /tmp/oracle-instantclient*.rpm && \
    echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient12.2.conf && \
    ldconfig && \
    echo "export LANG=en_US.utf8" >> /etc/profile && \
    groupadd -g 54321 oinstall && \
    groupadd -g 54322 dba && \
    useradd -u 54321 -g oinstall -G dba oracle && \
    mkdir -p /usr/lib/oracle/12.2/client64/network/admin && \
    chmod u+s /bin/ping && \
    printf "%s\n"  'export PATH=$PATH:/usr/lib/oracle/12.2/client64/bin' \
                   'export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK' \
                   'export ORACLE_HOME=/usr/lib/oracle/12.2/client64' \
                   'export TNS_ADMIN=$ORACLE_HOME/network/admin' \
                   'export LD_LIBRARY_PATH=$ORACLE_HOME/lib' \
                   'alias sqlplus="rlwrap sqlplus"' \
                   >> /home/oracle/.bash_profile && \
    printf "%s\n"  'export PATH=$PATH:/usr/lib/oracle/12.2/client64/bin' \
                   'export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK' \
                   'export ORACLE_HOME=/usr/lib/oracle/12.2/client64' \
                   'export TNS_ADMIN=$ORACLE_HOME/network/admin' \
                   'export LD_LIBRARY_PATH=$ORACLE_HOME/lib' \
                   'alias sqlplus="rlwrap sqlplus"' \
                   >> /root/.bash_profile && \
    printf "%s\n"  'ORCL =' \
                   '  (DESCRIPTION =' \
                   '    (ADDRESS_LIST =' \
                   '      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.240.4.162)(PORT = 1521))' \
                   '    )' \
                   '    (CONNECT_DATA =' \
                   '      (SERVICE_NAME = orcl)' \
                   '    )' \
                   '  )' \
                   >> /usr/lib/oracle/12.2/client64/network/admin/tnsnames.ora
#-------------------------------------------------------------------------------------------------
# rlwrap从已编译的系统中拷贝出来,注意权限
# chmod u+s /bin/ping,解决普通用户不能ping 
# yum -y install xorg-x11-utils

vi build.sh
#-------------------------------------------------------------------------------------------------
#!/usr/bin/env bash

imagetag="10.240.4.159/app/oracle_instantclient:12.2.0.1"
docker build -t ${imagetag} .
#-------------------------------------------------------------------------------------------------

chmod +x build.sh
./build.sh

docker images | grep instantclient
#-------------------------------------------------------------------------------------------------
10.240.4.159/app/oracle_instantclient   12.2.0.1            bded85c950fc        2 hours ago         528MB
#-------------------------------------------------------------------------------------------------

docker push 10.240.4.159/app/oracle_instantclient:12.2.0.1

Build OracleGoldengate

mkdir /docker_build/oracle_goldengate
cd /docker_build/oracle_goldengate

curl -o dockerBuild.sh https://raw.githubusercontent.com/oracle/docker-images/master/OracleGoldenGate/dockerBuild.sh
curl -o runOracleGoldenGate.sh https://raw.githubusercontent.com/oracle/docker-images/master/OracleGoldenGate/runOracleGoldenGate.sh
curl -o Dockerfile https://raw.githubusercontent.com/oracle/docker-images/master/OracleGoldenGate/Dockerfile
chmod +x dockerBuild.sh
chmod +x runOracleGoldenGate.sh

# 不带参数显示帮助
./dockerBuild.sh
#-------------------------------------------------------------------------------------------------
Oracle GoldenGate distribution ZIP file not specified.

Usage: dockerBuild.sh [-h | <ogg-zip-file-name>] [<docker-build-options> ...]
Where:
  ogg-zip-file-name       Name of OGG ZIP file
  docker-build-options    Command line options for Docker build

Example:
  ./dockerBuild.sh ~/Downloads/123014_fbo_ggs_Linux_x64_services_shiphome.zip --no-cache
#-------------------------------------------------------------------------------------------------

sed -i "s/BASE_IMAGE=.*/BASE_IMAGE=10.240.4.159\/app\/oracle_instantclient:12.2.0.1/g" Dockerfile

# ./dockerBuild.sh 123014_fbo_ggs_Linux_x64_services_shiphome.zip --no-cache
unzip -l 123014_fbo_ggs_Linux_x64_services_shiphome.zip | grep 'oracle.oggcore.*.ora.*filegroup1.jar'
#-------------------------------------------------------------------------------------------------
125089328  2018-04-16 20:46   fbo_ggs_Linux_x64_services_shiphome/Disk1/stage/Components/oracle.oggcore.services.ora11g/12.3.0.1.2/1/DataFiles/filegroup1.jar
119782012  2018-04-16 20:45   fbo_ggs_Linux_x64_services_shiphome/Disk1/stage/Components/oracle.oggcore.services.ora12c/12.3.0.1.2/1/DataFiles/filegroup1.jar
#-------------------------------------------------------------------------------------------------

# The filegroup1.jar for Oracle RDBMS 12c can be extracted into the current directory with a command like this:
unzip -j 123014_fbo_ggs_Linux_x64_services_shiphome.zip \
  fbo_ggs_Linux_x64_services_shiphome/Disk1/stage/Components/oracle.oggcore.services.ora12c/12.3.0.1.2/1/DataFiles/filegroup1.jar

# Then, conversion of filegroup1.jar to 123014_fbo_ggs_Linux_x64_services_shiphome.tar is done with this command:
unzip -q filegroup1.jar -d ./oggcore && \
  tar Ccf ./oggcore 123014_fbo_ggs_Linux_x64_services_shiphome.tar --owner=54321 --group=54321 . && \
  rm -fr  ./oggcore

vi build.sh
#-------------------------------------------------------------------------------------------------
#!/usr/bin/env bash

docker build --build-arg OGG_VERSION="12.3.0.1.4" \
             --build-arg OGG_EDITION="microservices" \
             --build-arg OGG_TARFILE="123014_fbo_ggs_Linux_x64_services_shiphome.tar" \
             --tag 10.240.4.159/app/oracle_goldengate_ma:12.3.0.1.4 --no-cache .
#-------------------------------------------------------------------------------------------------

chmod +x build.sh

yum -y install lsof
lsof -i -Pn | grep 9000

相关参考:

其他

为Oracle Database安装Oracle GoldenGate Microservices Architecture (以下简称OGG MA)的步骤:
1.安装Oracle GoldenGate MA
2.设置必要的环境变量
3.使用配置助理部署Oracle GoldenGate实例

REST,即Representational State Transfer的缩写,翻译是”表现层状态转化”
REST的名称”表现层状态转化”中,省略了主语。”表现层”其实指的是”资源”(Resources)的”表现层”。
所谓”资源”,用在互联网上就是网络上的一个实体,或者说是网络上的一个具体信息。它可以是一段文本、一张图片、一首歌曲、一种服务,总之就是一个具体的实在。
你可以用一个URI(统一资源定位符)指向它,每种资源对应一个特定的URI。
要获取这个资源,访问它的URI就可以,因此URI就成了每一个资源的地址或独一无二的识别符。

如果一个架构符合REST原则,就称它为RESTful架构。以网络为基础的应用软件的架构设计

访问一个网站,就代表了客户端和服务器的一个互动过程。在这个过程中,势必涉及到数据和状态的变化。

互联网通信协议HTTP协议,是一个无状态协议。这意味着,所有的状态都保存在服务器端。因此,如果客户端想要操作服务器,必须通过某种手段,让服务器端发生”状态转化”(State Transfer)。而这种转化是建立在表现层之上的,所以就是”表现层状态转化”。
客户端用到的手段,只能是HTTP协议。具体来说,就是HTTP协议里面,四个表示操作方式的动词:GET、POST、PUT、DELETE。
它们分别对应四种基本操作:GET用来获取资源,POST用来新建资源(也可以用于更新资源),PUT用来更新资源,DELETE用来删除资源。

docker Failed to get D-Bus connection 报错处理,将你的CMD或者entrypoint设置为/usr/sbin/init即可,然后就可以使用systemctl了

文章目录
  1. 1. OGG on docker准备
    1. 1.1. Build OracleInstantClient
    2. 1.2. Build OracleGoldengate
  2. 2. 相关参考:
  3. 3. 其他