Java web

009.统一数据采集平台DBus-0.6.1安装部署

2020-11-09  本文已影响0人  CoderJed

1. 准备工作

1.1 环境准备

以下软件为DBus-0.6.1依赖的软件:

组件 版本 备注
Zookeeper v3.4.6+ 用于构建整个系统和提供配置通知等,推荐版本:v3.4.8
Kafka v0.10 用于存储相关数据和消息,提供订阅和发布的能力
Storm v1.0.2 用于提供DBus流式计算
Influxdb v1.1.0 用于记录实时监控数据
Grafana v4.2.0 用于展示监控信息
MySQL v5.6.x 创建数据库dbusmgr,创建好账号,后续配置需提供
Nginx v1.9.3 用于存放静态html、js文件及反向代理
Canal v1.1.4 用于实时抽取binlog日志,具体配置可参考canal相关支持说明,支持mysql5.6、5.7
kafka-manager v1.3.3.4 选装,用于便捷地查看、管理Kafka集群,建议安装

我的环境已经安装了Ambari-2.7.4.0+HDP-3.1.4.0大数据平台,已安装的组件的版本如下:

关于Ambari-2.7.4.0+HDP-3.1.4.0大数据平台的安装部署参考:基于CentOS7.8安装Ambari2.7+HDP3.1大数据平台

1.2 角色规划

hdp01 hdp02 hdp03 hdp04
MySQL MySQL
Zookeeper Zookeeper Zookeeper Zookeeper
Kafka Kafka-Manager Kafka Kafka Kafka
Storm Storm UI Server/Supervisor/Nimbus Nimbus Nimbus Nimbus
InfluxDB InfluxDB
Grafana Grafana
Nginx Nginx
DBus heartbeat server heartbeat server/web server heartbeat server heartbeat server

1.3 DBus源码编译

由于我的大数据平台的Kafka和Strom版本不满足DBus-0.6.1的要求,所以需要根据自己的组件版本来编译DBus源码

1.2.1 Maven安装部署

[admin@hdp01 apps]$ wget https://mirror.bit.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
[admin@hdp01 apps]$ tar -zxvf apache-maven-3.6.3-bin.tar.gz
[admin@hdp01 apps]$ mv apache-maven-3.6.3 maven-3.6.3
[admin@hdp01 apps]$ ln -s maven-3.6.3 maven
[admin@hdp01 apps]$ ll
total 0
lrwxrwxrwx 1 admin admin 11 2020-10-29 21:08 maven -> maven-3.6.3
drwxr-xr-x 6 admin admin 99 2020-10-29 21:07 maven-3.6.3

# 设置环境变量
[admin@hdp01 apps]$ sudo vim /etc/profile
export MAVEN_HOME=/opt/apps/maven
export MAVEN_OPTS="-Xms512m -Xmx1024m"
export PATH=$MAVEN_HOME/bin:$PATH
[admin@hdp01 apps]$ source /etc/profile

# 修改settings.xml配置文件,为列出的保持默认即可
[admin@hdp01 apps]$ vim maven/conf/settings.xml

<localRepository>/data/maven/repo</localRepository>

<mirrors>
  <mirror>
    <id>alimaven</id>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
</mirrors>

<profiles>
  <profile>
    <id>jdk-1.8</id>
    <activation>
      <activeByDefault>true</activeByDefault>
      <jdk>1.8</jdk>
    </activation>
    <properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
      <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    </properties>
  </profile>
</profiles>

# 创建指定的仓库目录
[admin@hdp01 apps]$ sudo mkdir -p /data/maven/repo
[admin@hdp01 apps]$ sudo chown -R admin:admin /data/maven

1.2.2 从git上拉取源码

# 安装git
[admin@hdp01 package]$ sudo yum install git -y
# 拉取源码,这里拉取的master是0.6.1版本
[admin@hdp01 package]$ git clone https://github.com/BriData/DBus.git

1.2.3 下载Oracle数据库的驱动包

下载地址:https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html

官网下载是需要登录的,没有的话注册一个账号登录即可,我这里一口气把所有的jar包都下载好了,并且上传到服务器的目录结构如下,算是做了一个备份:

[admin@hdp01 package]$ tree Oracle-JDBC-Driver/
Oracle-JDBC-Driver/
├── 11.2.0.4
│   ├── ojdbc5.jar
│   └── ojdbc6.jar
├── 12.1.0.1
│   ├── ojdbc6.jar
│   └── ojdbc7.jar
├── 12.1.0.2
│   ├── ojdbc6.jar
│   └── ojdbc7.jar
├── 12.2.0.1
│   └── ojdbc8.jar
├── 18.3
│   └── ojdbc8.jar
├── 19.3
│   ├── ojdbc10.jar
│   └── ojdbc8.jar
├── 19.6
│   ├── ojdbc10.jar
│   └── ojdbc8.jar
├── 19.7
│   ├── ojdbc10.jar
│   └── ojdbc8.jar
└── 19.8
    ├── ojdbc10.jar
    └── ojdbc8.jar

# 安装到maven仓库,我们只需要一个12.1.0.2版本ojdbc7jar包即可,我这里还是全部安装了...
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.4 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/11.2.0.4/ojdbc5.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/11.2.0.4/ojdbc6.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=12.1.0.1 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/12.1.0.1/ojdbc6.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/12.1.0.1/ojdbc7.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=12.1.0.2 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/12.1.0.2/ojdbc6.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/12.1.0.2/ojdbc7.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/12.2.0.1/ojdbc8.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=18.3 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/18.3/ojdbc8.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=19.3 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.3/ojdbc8.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc10 -Dversion=19.3 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.3/ojdbc10.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=19.6 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.6/ojdbc8.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc10 -Dversion=19.6 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.6/ojdbc10.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=19.7 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.7/ojdbc8.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc10 -Dversion=19.7 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.7/ojdbc10.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=19.8 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.8/ojdbc8.jar -DgeneratePom=true

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc10 -Dversion=19.8 -Dpackaging=jar -Dfile=/opt/package/Oracle-JDBC-Driver/19.8/ojdbc10.jar -DgeneratePom=true

1.2.4 下载DB2数据库的驱动包

下载地址:https://www.ibm.com/support/pages/node/382667

这时候同样需要登录IBM的账号,没有的话需要注册。

压缩包里面的db2jcc4.jar就是我们需要的jar包,安装到maven仓库中:

mvn install:install-file -DgroupId=com.ibm.db2.jcc -DartifactId=db2jcc4 -Dversion=4.23.42 -Dpackaging=jar -Dfile=/opt/package/db2jcc4.jar -DgeneratePom=true

1.2.5 后端源码编译

# 进入git拉下来的DBus目录下
[admin@hdp01 package]$ cd DBus/

# 1.修改项目根目录下的pom.xml文件,升级storm和kafka的版本
<dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-core</artifactId>
    <!-- <version>1.0.1</version> -->
    <version>1.2.1</version>
    <scope>${scope.provided}</scope>
    <exclusions>
        <exclusion>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <!-- <version>0.10.0.0</version> -->
    <version>2.0.0</version>
</dependency>

# 2.修改dbus-commons/pom.xml文件,填入JDBC驱动和OJDBC驱动的依赖
[admin@hdp01 DBus]$ vim dbus-commons/pom.xml

<!-- 你需要添加 mysql 依赖在这里 mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.49</version>
</dependency>

<!-- 你需要添加 oracle 依赖在这里 ojdbc7 -->
<!-- mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.2 -Dpackaging=jar -Dfile=ojdbc7-12.1.0.2.jar -DgeneratePom=true -->
<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>

<!-- 你需要添加 db2 依赖在这里 db2jcc4 -->
<!--  mvn install:install-file -DgroupId=com.ibm.db2.jcc -DartifactId=db2jcc4 -Dversion=4.23.42 -Dpackaging=jar   -Dfile=db2jcc4-4.23.42.jar -DgeneratePom=true-->
<dependency>
    <groupId>com.ibm.db2.jcc</groupId>
    <artifactId>db2jcc4</artifactId>
    <version>4.23.42</version>
</dependency>

# 3.修改dbus-fullpuller/pom.xml
<dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-kafka</artifactId>
    <!-- <version>1.0.1</version> -->
    <version>1.2.1</version>
</dependency>

# 4.修改dbus-keeper/keeper-base/pom.xml
<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.11</artifactId>
    <!-- <version>0.10.0.1</version> -->
    <version>2.0.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>

# 5.修改dbus-heartbeat/assembly.xml
# 在第20行下面新增一行
<fileMode>0755</fileMode> # 这是第20行
<lineEnding>unix</lineEnding>
// 1.文件:dbus-stream/dbus-stream-main/src/main/java/com/creditease/dbus/stream/dispatcher/bout/Db2KafkaProducerBout.java

// import org.apache.storm.shade.com.codahale.metrics.Meter;
import com.codahale.metrics.Meter;
// import org.apache.storm.shade.com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.MetricRegistry;
// import org.apache.storm.shade.com.codahale.metrics.Slf4jReporter;
import com.codahale.metrics.Slf4jReporter;
[admin@hdp01 DBus]$ mvn clean package
# 编译完成后,DBus/deployer/target目录下的deployer-0.6.1.zip就是最终的部署文件

1.2.6 前端源码编译

# 1. 安装nodejs
[admin@hdp01 apps]$ wget https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/v14.15.0/node-v14.15.0-linux-x64.tar.gz

# 2.解压,配置环境变量
[admin@hdp01 apps]$ sudo tar -zxvf node-v14.15.0-linux-x64.tar.gz
[admin@hdp01 apps]$ sudo mv node-v14.15.0-linux-x64 nodejs-14.15.0
[admin@hdp01 apps]$ sudo ln -s nodejs-14.15.0 nodejs
[admin@hdp01 apps]$ sudo chown -R admin:admin nodejs*
[admin@hdp01 apps]$ sudo vim /etc/profile
export NODEJS_HOME=/opt/apps/nodejs
export PATH=$NODEJS_HOME/bin:$PATH
[admin@hdp01 apps]$ source /etc/profile
[admin@hdp01 apps]$ node -v
v14.15.0

# 3.使用淘宝npm镜像
[admin@hdp01 apps]$ npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/opt/apps/nodejs-14.15.0/bin/cnpm -> /opt/apps/nodejs-14.15.0/lib/node_modules/cnpm/bin/cnpm
+ cnpm@6.1.1
added 688 packages from 971 contributors in 19.23s

# 4.进入DBus\dbus-keeper\keeper-web目录下
[admin@hdp01 apps]$ cd /opt/src/DBus/dbus-keeper/keeper-web/

# 5.修改源码
# (1) 文件:DBus/dbus-keeper/keeper-web/app/containers/Project/route/index.js,确保目录Project首字母P是大写,源码中有几行是project
// 导入自定义组件
# 注意,确保第一行import的路径为'@/app/containers/App'
import App from '@/app/containers/App'
import TopologyWrapper from '@/app/containers/Project/TopologyWrapper'
import TableWrapper from '@/app/containers/Project/TableWrapper'
import SinkWrapper from '@/app/containers/Project/SinkWrapper'
import UserWrapper from '@/app/containers/Project/UserWrapper'
import ResourceWrapper from '@/app/containers/Project/ResourceWrapper'
import FullpullWrapper from '@/app/containers/Project/FullpullWrapper'
import MonitorWrapper from '@/app/containers/Project/MonitorWrapper'
import UserKeyDownloadWrapper from '@/app/containers/Project/UserKeyDownloadWrapper'
# (2) 文件:DBus/dbus-keeper/keeper-web/app/components/index.js,确保目录common是小写,源码中有几行是Common
// common 公共无状态组件
export Bread from './common/Bread'
export Navigator from './common/Navigator'
export Header from './common/Header'
export Foot from './common/Foot'
export OperatingButton from './common/OperatingButton'
export FileTree from './common/FileTree'
# (3) 将DBus/dbus-keeper/keeper-web/app/containers/Project目录下的几个js文件的名称首字母改成大写
[admin@hdp01 Project]$ mv resourceWrapper.js ResourceWrapper.js
[admin@hdp01 Project]$ mv tableWrapper.js TableWrapper.js
[admin@hdp01 Project]$ mv topologyWrapper.js TopologyWrapper.js

# 6.编译前端代码
# 先下载依赖包
[admin@hdp01 keeper-web]$ cnpm install
...
✔ All packages installed (1602 packages installed from npm registry, 1 packages installed from git, used 31s(network 19s), speed 2.7MB/s, json 1328(3.65MB), tarball 46.35MB)
# 编译源码
[admin@hdp01 keeper-web]$ cnpm run build
# 编译成功后,在keeper-web生成了build目录,整个目录都是我们需要的前端文件

2. 基础软件安装部署

所有基础软件略过的部分,参考:基于CentOS7.8安装Ambari2.7+HDP3.1大数据平台,其中包括操作系统环境的配置(免秘钥登录,时钟同步等)也是安装DBus需要的配置

2.1 安装MySQL

2.2 Zookeeper安装部署

2.3 安装Kafka

需要开启kafka的JMX端口:


然后重启一下需要重启的所有组件,页面会有提示。

2.4 安装Kafka-Manager

参考:Kafka集群管理工具CMAK-3.0.0.5源码编译以及安装部署

2.5 安装Storm

2.6 安装InfluxDB

# 安装
[admin@hdp01 ~]$ wget https://dl.influxdata.com/influxdb/releases/influxdb-1.1.0.x86_64.rpm
[admin@hdp01 ~]$ sudo yum -y localinstall influxdb-1.1.0.x86_64.rpm

# 启动
sudo systemctl start influxdb
sudo systemctl status influxdb
sudo systemctl enable influxdb

# 修改端口
# 我启动失败,查看/var/log/messages日志发现8088端口被占用
# 修改配置文件/etc/influxdb/influxdb.conf
# 注意,添加的bind-address配置在[meta]的上方,其他不用修改
bind-address="0.0.0.0:8008"
[meta]
  # Where the metadata/raft database is stored
  dir = "/var/lib/influxdb/meta"
  ...

# 初始化配置
[admin@hdp01 ~]$ influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 1.1.0
InfluxDB shell version: 1.1.0
> create database dbus_stat_db
> use dbus_stat_db
Using database dbus_stat_db
> CREATE USER "dbus" WITH PASSWORD '123456'
> ALTER RETENTION POLICY autogen ON dbus_stat_db DURATION 15d
> exit
[admin@hdp01 ~]$

2.7 安装Grafana

# 安装
[admin@hdp02 ~]$ wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.2.0-1.x86_64.rpm
[admin@hdp02 ~]$ sudo yum -y localinstall grafana-4.2.0-1.x86_64.rpm

# 配置文件:/etc/grafana/grafana.ini,保持默认即可

# 启动
[admin@hdp02 ~]$ sudo systemctl start grafana-server
[admin@hdp02 ~]$ sudo systemctl status grafana-server
[admin@hdp02 ~]$ sudo systemctl enable grafana-server.service

登录页面进行配置:

接下来是数据库操作:

mysql> set global validate_password_policy=0;
mysql> set global validate_password_mixed_case_count=0;
mysql> set global validate_password_number_count=3;
mysql> set global validate_password_special_char_count=0;
mysql> set global validate_password_length=3;
mysql> create database dbusmgr DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
mysql> create user 'dbusmgr'@'%' identified by '123456';
mysql> grant all privileges on dbusmgr.* to 'dbusmgr'@'%' identified by '123456';
mysql> flush privileges;
mysql> exit;

2.8 安装Nginx

# 安装
[admin@hdp02 ~]$ sudo yum -y localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
[admin@hdp03 ~]$ sudo yum install -y nginx

# 启动
[admin@hdp02 ~]$ sudo systemctl start nginx
[admin@hdp02 ~]$ sudo systemctl status nginx
[admin@hdp02 ~]$ sudo systemctl enable nginx

访问WEB-UI

3. DBus-0.6.1安装部署

# 检查DBUS安装情况
# 规划的4个节点安装heartbeat server,安装在/data/dbus/heartbeat目录下
# 4个节点都应该安装成功
[admin@hdp01 ~]$ ll /data/dbus/heartbeat/
total 32288
drwxr-xr-x 5 admin admin       90 Nov  5 22:54 dbus-heartbeat-0.6.1
-rw-rw-r-- 1 admin admin 33062689 Nov  5 22:56 dbus-heartbeat-0.6.1.zip

# 启动4个节点的heartbeat服务,4个节点全部执行
[admin@hdp01 heartbeat]$ cd dbus-heartbeat-0.6.1/
[admin@hdp01 dbus-heartbeat-0.6.1]$ nohup sh heartbeat.sh > heartbeat.log 2>&1 &



# 检查表创建情况
mysql> use dbusmgr;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+--------------------------------------------+
| Tables_in_dbusmgr                          |
+--------------------------------------------+
| t_avro_schema                              |
| t_data_schema                              |
| t_data_tables                              |
| t_dbus_datasource                          |
| t_ddl_event                                |
| t_encode_columns                           |
| t_encode_plugins                           |
| t_fullpull_history                         |
| t_meta_version                             |
| t_name_alias_mapping                       |
| t_plain_log_rule_group                     |
| t_plain_log_rule_group_version             |
| t_plain_log_rule_type                      |
| t_plain_log_rules                          |
| t_plain_log_rules_version                  |
| t_project                                  |
| t_project_encode_hint                      |
| t_project_resource                         |
| t_project_sink                             |
| t_project_topo                             |
| t_project_topo_table                       |
| t_project_topo_table_encode_output_columns |
| t_project_topo_table_meta_version          |
| t_project_user                             |
| t_query_rule_group                         |
| t_sink                                     |
| t_sinker_topo                              |
| t_sinker_topo_schema                       |
| t_sinker_topo_table                        |
| t_storm_topology                           |
| t_table_action                             |
| t_table_meta                               |
| t_topology_jar                             |
| t_user                                     |
+--------------------------------------------+
34 rows in set (0.00 sec)

在页面查一下集群状态:

到这里,DBus的安装部署就成功了!在bin目录下执行stop.sh就可以停止DBus服务。

上一篇 下一篇

猜你喜欢

热点阅读