CentOS7 通过 Docker 安装 Oracle11g 并配置SharePlex 连接 kafka 同步数据

CentOS7 通过 Docker 安装 Oracle11g 并配置SharePlex 连接 kafka 同步数据

木子李 495 2022-03-30

CentOS7 通过 Docker 安装 Oracle11g 并配置SharePlex 连接 kafka 同步数据

Docker安装Oracle11g

详细文章链接

创建容器,与链接中不同

docker run --name oracle11g -d -p 1521:1521 -p 2300:2300 -h src \
--privileged=true --restart=always -e TZ=Asia/Shanghai \
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

Oracle11g容器中安装准备

将SharePlex安装文件上传到物理机的 /home 路径下

# 将文件复制进入docker容器中
docker cp /home/SharePlex-10.0.0-b107-rhel-amd64-m64.tpm oracle11g:/SharePlex-10.0.0-b107-rhel-amd64-m64.tpm

# 进入容器
docker exec -it oracle11g bash

切换到root用户

su root

# 密码
helowin

创建并授权目录

# 切换到根目录
cd /

mkdir -p /quest/8.6/

chown -R oracle:oinstall /quest/8.6/

chmod -R 777 /quest/8.6/

mkdir -p /home4/archivelog/portal01

chmod -R 777 /home4/archivelog/portal01

chown -R oracle:oinstall /home4/archivelog/portal01

mkdir -p /home2/oradata/portal01

chmod -R 777 /home2/oradata/portal01

chown -R oracle:oinstall /home2/oradata/portal01

chmod 777 SharePlex-10.0.0-b107-rhel-amd64-m64.tpm

配置环境变量

打开环境变量配置文件:vi /etc/profile

按大写G,快速到达最下方,输入 i 进入编辑模式

复制下方配置信息

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
TH=$PATH:$HOME/bin
export PATH
PATH=$PATH:$HOME/bin
export TMP=/tmp
export TMPDIR=$TMP
export NLS_LANG='AMERICAN_AMERICA.AL32UTF8'
export LANG=en_US.UTF-8
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH:/quest/8.6/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib:/usr/local/lib:/usr/lib:/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACEL_HOME/network/jlib
export TNS_ADMIN=$ORALE_HOME/network/admin
export SP_SYS_VARDIR=/quest/8.6/vardir2300

让配置文件生效:source /etc/profile

打开 oracle11g 日志归档模式

下方命令逐行执行

su - oracle

sqlplus /nolog

conn /as sysdba

shutdown immediate;

startup mount;

alter system set log_archive_dest_1='location=/home4/archivelog/portal01';

alter database archivelog;

alter database open;

archive log list;

打开源端的补充日志

alter database add supplemental log data (primary key, unique index) columns;

select SUPPLEMENTAL_LOG_DATA_MIN, SUPPLEMENTAL_LOG_DATA_PK,SUPPLEMENTAL_LOG_DATA_UI from v$database;

退出SQL输入模式:exit

安装SharePlex

执行安装文件

执行安装包:cd / && ./SharePlex-10.0.0-b107-rhel-amd64-m64.tpm

Unpacking ..................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  ..........................................................................
  .....................................................

SharePlex installation program:
    SharePlex Version: 10.0.0
    Build platform: rhel-amd64
    Target platform: lin-amd64
# 输入安装路径:/quest/8.6
Please enter the product directory location? /quest/8.6
# 输入队列信息路径:/quest/8.6/vardir2300
Please enter the variable data directory location? /quest/8.6/vardir2300
# 输入 1
Please specify the SharePlex Admin group (select a number):
1. [oinstall]
2. dba
3. oper
?  1
# 输入2300
Please enter the TCP/IP port number for SharePlex communications? [2100] 2300

Preparing to install SharePlex v.10.0.0:
    User:                     oracle
    Admin Group:              oinstall
    Product Directory:        /quest/8.6
    Variable Data Directory:  /quest/8.6/vardir2300
# 输入yes
Proceed with installation? [yes] yes
Installing ................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  ......................................................
Setting file ownerships ...................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  ...................................................................
Setting file permissions ..................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  .........................................................................
  ....................................................................
# 询问是否有许可证,输入:yes
Do you have a valid SharePlex v. 10.0.0 license? [yes] yes
# 输入获取的许可证:XXXXXXXXXXXXXXXXXXXXXXXX
Please enter the License key? XXXXXXXXXXXXXXXXXXXXXXXX
# 输入许可证令牌:XXXX
Please enter the customer name associated with this license key? XXXX
# 下方表示安装成功
SharePlex v. 10.0.0 license validation successful:
    Customer Name:      XXXX
    License Key:        XXXXXXXXXXXXXXXXXXXXXXXX
    Product Name:       SharePlex for Oracle - RAC
    License Key Type:   "Trial Key"
    Expires:            at Midnight of May 19, 2022

NOTE: You can upgrade this license key or add license keys for additional machines
      by executing utility /quest/8.6/install/splex_add_key.

Installation log saved to: /home/oracle/.shareplex/INSTALL-SharePlex-10.0.0-2203281705.log
SharePlex v.10.0.0 installation successful.

创建关联oracle数据库用户

根据下方命令逐行执行

# 打开数据连接
sqlplus /nolog

# 连接dba角色
conn /as sysdba

# 创建用户空间
create tablespace splex datafile '/home2/oradata/portal01/splex01.dbf' size 1G autoextend on;

# 创建一个账号:splex2300,密码:splex2300 的用户
create user splex2300 identified by splex2300 default tablespace splex temporary tablespace temp;

# 授予dba权限给splex2300
grant dba to splex2300;

# 退出
exit

配置SharePlex关联oracle数据库

开始配置:ora_setup

可能会出现以下两种情况

第一种:配置管理用户时,默认缺少索引表空间,需要手动输入

Welcome to the Oracle SharePlex setup process for port 2300.
This process creates tables and user accounts needed to run
Oracle SharePlex replication.

# 输入 y
Will the SharePlex install be using a BEQUEATH connection? (Entering 'n' implies a SQL*net connection)  [y] : y
Please note the following:
** In response to prompts, a carriage return will choose the default
   given in brackets.  If there is no default, a reply must be entered.

** To exit the program while the program is waiting for input, use the
   CTRL-C key sequence.
   This sequences can be entered by holding down the CONTROL key and
   pressing the C key.

# 输入实例名:helowin
Enter the Oracle SID for which SharePlex should be installed [helowin] : helowin


In order to create the SharePlex tables and user account, we must connect to the database as a DBA user

# 输入用于关联的账号:splex2300
Enter a DBA user for helowin  : splex2300
# 输入密码:splex2300
Enter password for the DBA account, which will not echo :

connecting--This may take a few seconds.

validating user name and password. . . This may take a few seconds.
SharePlex objects will need to be created under a special
account.  You can pick an existing user or create a new one.
# 输入 n
Would you like to create a new SharePlex user ? [y] : n

# 输入用于关联的账号:splex2300
Enter username of an existing user : splex2300
# 输入密码:splex2300
Enter user password for splex2300 :
validating user name and password. . . This may take a few seconds.

Warning:  This user is now being granted unlimited tablespace.
This privilege will remain in effect until it is explicitly changed.

# 输入 n
Do you want to enable replication of tables with TDE? [n] : n

To enable replication of tables with TDE in the future, please rerun ora_setup.

Setup will now install SharePlex objects.

These are the existing tablespaces.

SYSTEM SYSAUX UNDOTBS1 TEMP USERS EXAMPLE SPLEX

# 输入表空间:SPLEX
Enter the default tablespace for use by SharePlex [SPLEX] : SPLEX
# 输入缓冲区:TEMP
Enter the temporary tablespace for use by SharePlex [TEMP] : TEMP
# 此时默认缺少表空间,需要手动指定:SPLEX
Enter the index tablespace for use by SharePlex [ ] : SPLEX

The current index tablespace for user splex2300 is TOOLS.
# 输入 y ,确定修改表空间
Do you want to change to SPLEX? [y] : Y

Creating SharePlex objects [Installation type: Fresh]. . .

Creating SharePlex Oracle-timezone-region map . . . Done.

Creating Conflict Resolution Package . . . Done.

Creating SharePlex Dataequator package . . .

Loading Compare Package from "/quest/8.6/util/sp_deq_pkg.plb"...Done.

Loading Compare Varray Package from "/quest/8.6/util/sp_deq_v_pkg.plb"...Done.

# 输入 y
Will the current setup for sid: [helowin] be used as source (including cases as source for failover or master-master setups)?  [y] : y

Setup of SharePlex objects successful . . .

Changing SharePlex connection database . . .

Setup of helowin completed successfully

-- The datasource identifier in the SharePlex configuration is 'o.helowin' --

当出现第一种情况,需要重新配置一次

第二种情况:默认有索引表空间

开始配置:ora_setup

Welcome to the Oracle SharePlex setup process for port 2300.
This process creates tables and user accounts needed to run
Oracle SharePlex replication.
# 输入 y
Will the SharePlex install be using a BEQUEATH connection? (Entering 'n' implies a SQL*net connection)  [y] : y
Please note the following:
** In response to prompts, a carriage return will choose the default
   given in brackets.  If there is no default, a reply must be entered.

** To exit the program while the program is waiting for input, use the
   CTRL-C key sequence.
   This sequences can be entered by holding down the CONTROL key and
   pressing the C key.

# 输入实例名:helowin
Enter the Oracle SID for which SharePlex should be installed [helowin] : helowin


In order to create the SharePlex tables and user account, we must
connect to the database as a DBA user
# 输入用于关联的账号:splex2300
Enter a DBA user for helowin  : splex2300
# 输入密码:splex2300
Enter password for the DBA account, which will not echo :

connecting--This may take a few seconds.

validating user name and password. . . This may take a few seconds.
SharePlex objects will need to be created under a special
account.  You can pick an existing user or create a new one.

Current SharePlex user is : SPLEX2300

Warning: Changing SharePlex user requires
reactivating the current configuration.
# 输入 n ,不创建新用户
Would you like to create a new SharePlex user ? [y] : n
# 输入用于关联的账号:splex2300
Enter username of an existing user : splex2300
# 输入密码:splex2300
Enter user password for splex2300 :
validating user name and password. . . This may take a few seconds.

Warning:  This user is now being granted unlimited tablespace.
This privilege will remain in effect until it is explicitly changed.
SPLEX_ROLE_BOTH  already exists; continuing setup . . .
# 输入 n
Do you want to enable replication of tables with TDE? [n] : n

To enable replication of tables with TDE in the future, please rerun ora_setup.

Setup will now install SharePlex objects.

These are the existing tablespaces.

SYSTEM SYSAUX UNDOTBS1 TEMP USERS EXAMPLE SPLEX
# 输入表空间:SPLEX
Enter the default tablespace for use by SharePlex [SPLEX] : SPLEX
# 输入缓冲区:TEMP
Enter the temporary tablespace for use by SharePlex [TEMP] : TEMP
# 此时出现默认索引表空间,输入:SPLEX
Enter the index tablespace for use by SharePlex [SPLEX] : SPLEX

Creating SharePlex objects [Installation type: Upgrade]. . .
SPLEX2300.SHAREPLEX_ACTID already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_MARKER already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_OBJMAP already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_OBJMAP_I1 already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_TRANS already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_CONF_LOG already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_CONF_LOG_SEQ already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_LOGLIST already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_LOBMAP already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_PARTITION_CACHE already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_PARTITION_CACHE_I1 already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_LOB_CACHE already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_LOB_CACHE_I1 already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_CONFIG already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_COMMAND already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_DATAEQUATOR already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_DATAEQUATOR_INS_TEMP already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_DATAEQUATOR_UPD_TEMP already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_DATAEQUATOR_DEL_TEMP already exists; continuing setup . . .
SPLEX2300.DEMO_SRC already exists; continuing setup . . .
SPLEX2300.DEMO_DEST already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_ACT_MARKER already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_SYNC_MARKER already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_CHANGE_OBJECT already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_DDL_CONTROL already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_RECOVERY already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_RECOVERY_OP_SEQ already exists; continuing setup . . .
SPLEX2300.SHAREPLEX_ANALYZE already exists; continuing setup . . .

Creating SharePlex Oracle-timezone-region map . . . Done.

Creating Conflict Resolution Package . . . Done.

Creating SharePlex Dataequator package . . .
drop package:sp_deq_pkg
drop package:sp_deq_v_pkg

Loading Compare Package from "/quest/8.6/util/sp_deq_pkg.plb"...Done.

Loading Compare Varray Package from "/quest/8.6/util/sp_deq_v_pkg.plb"...Done.
# 输入 y
Will the current setup for sid: [helowin] be used as source (including cases as source for failover or master-master setups)?  [y] : y

Setup of SharePlex objects successful . . .

Setup of helowin completed successfully

-- The datasource identifier in the SharePlex configuration is 'o.helowin' --

完成SharePlex关联oracle配置

Docker 安装 Kafka

详细文章链接

配置连接kafka

连接sharePlex

sp_cop -u2300&

打开sharePlex控制台

sp_ctrl

停止推送进程

stop post

修改默认kafka连接信息地址

topic需要提前在kafka上创建好

修改连接地址

target x.kafka set kafka broker=10.160.6.161:9092

修改推送主题

target x.kafka set kafka topic=splex

查看配置是否生效

target x.kafka show

创建关于kafka配置文件

copy config ORA_config to kafka_config

编辑kafka配置文件

edit config kafka_config

datasource:o.helowin

splex2300.demo_src      !kafka      src

激活配置文件

activate config kafka_config nolock

开启推送进程

start post

查看进程状态

如果发现有未开启的,及时启动

status

及时启动进程

查看输出日志

show log reverse