首页 > 数据库 >云计算课程设计(Prometheus+grafana+Flume+ganglia+mysql+jdk)

云计算课程设计(Prometheus+grafana+Flume+ganglia+mysql+jdk)

时间:2024-08-14 20:23:50浏览次数:14  
标签:Flume flume 课程设计 return jdk a1 master mysql root

一、准备环境

prometheus下载地址: https://github.com/prometheus/prometheus/releases/download/v2.52.0-rc.1/prometheus-2.52.0-rc.1. windows-amd64.zip
grafana 下 载 地 址 :

https://dl.grafana.com/enterprise/release/grafana-enterprise-10.4.2.windows-amd64.zip windows_exporter下载地址:

https://github.com/prometheus-community/windows_exporter/releases/download/v0.25.1/wi ndows_exporter-0.25.1-amd64.msi
flume下载地址:

https://archive.apache.org/dist/flume/1.7.0/apache-flume-1.7.0-bin.tar.gz
jdk(linux)下载地址:

https://cola-yunos-1305721388.cos.ap-guangzhou.myqcloud.com/20210813/jdk-8u401-linux-x64. tar.gz
mysql下载地址
https://downloads.mysql.com/archives/get/p/23/file/mysql-community-server-5.7.26-1.el7.x86_64.rpm

https://downloads.mysql.com/archives/get/p/23/file/mysql-community-client-5.7.26-1.el7.x86_64.rpm

https://downloads.mysql.com/archives/get/p/23/file/mysql-community-common-5.7.26-1.el7.x86_64.rpm

https://downloads.mysql.com/archives/get/p/23/file/mysql-community-libs-5.7.26-1.el7.x86_64.rpm
驱动包下载地址:  

https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-5.1.16.tar.gz idea

idea下载地址: 
https://www.jetbrains.com/zh-cn/idea/download/download-thanks.html?platform=windows 
maven下载地址: 
https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.zip

二、监视面板搭建

1、解压Prometheus,运行prometheus.exe

2、打开网址

3、配置windows服务器监视:

        双击运行windows_exporter-0.25.1-amd64.msi,在浏览器进入以下地址:
http://10.225.193.16:9182/metrics,出现以下页面即为运行成功:

4、编辑prometheus.yml(此文件在解压的Prometheus里面)

在文件末段添加以下内容:

- job_name: "windows"
    file_sd_configs:
    - refresh_interval: 15s
      files:
      - ".\\windows.yml"

5、在同级目录下新建windows.yml

- targets: ["127.0.0.1:9182"]
  labels:
    instance: 127.0.0.1
serverName: 'windows server'

 

6、重启prometheus(就是把黑框框关掉,然后再双击prometheus.exe)

在浏览器打开:http://127.0.0.1:9090/targets?search=

7、解压grafana,在bin目录打开grafana-server.exe 

8、打开网址

http://127.0.0.1:3000
默认的账号密码都是admin 

9、添加datasource

 

出现下边页面即为搭建成功

三、Flume日志聚集搭建

1、创建目录

在‘/opt’目录下创建 software和module两个目录,命令如下:

mkdir module software

2、使用xftp工具上传文件

3、将JDK和Flume文件解压到‘/opt/module’

tar -zxf jdk-8u371-linux-x64.tar.gz -C /opt/module/
tar -zxf apache-flume-1.6.0-bin.tar.gz -C /opt/module/

4、修改安装目录名称

mv jdk1.8.0_371/ jdk
mv apache-flume-1.6.0-bin/ flume

5、配置环境

A)JDK环境配置

[root@localhost module]# vi /etc/profile
配置内容如下:

export JAVA_HOME=/opt/module/jdk
export PATH=$PATH:$JAVA_HOME/bin # 将 JAVA 安装目录加入 PATH 路径

B)Flume环境配置:

配置Flume文件
[root@localhost conf]# mv flume-env.sh.template flume-env.sh

# 编辑配置文件
[root@localhost conf]# vi flume-env.sh 

6、刷新环境变量

[root@localhost module]# source /etc/profile

四、ganglia监控搭建

1、安装相关依赖包

[root@localhost ~]# yum -y install httpd php

[root@localhost ~]# yum -y install rrdtool perl-rrdtool rrdtool-devel

[root@localhost ~]# yum -y install apr-devel

[root@localhost ~]# yum install -y epel-release

[root@localhost ~]# yum -y install ganglia-gmetad

[root@localhost ~]# yum -y install ganglia-web

[root@localhost ~]# yum install -y ganglia-gmond

2、安装telent

[root@localhost ~]# yum install telnet -y

3、修改配置文件

[root@localhost ~]# vi /etc/httpd/conf.d/ganglia.conf

[root@localhost ~]# vi /etc/ganglia/gmetad.conf

修改host文件
[root@localhost ~]# vi /etc/hosts

[root@localhost ~]# vi /etc/ganglia/gmond.conf

五、禁用selinux

[root@localhost ~]# vi /etc/selinux/config

1、设置服务自启动

[root@master ~]# systemctl enable httpd && systemctl enable gmetad && systemctl enable gmond

2、关闭防火墙

[root@master ~]# systemctl stop firewalld && systemctl disable firewalld

3、授权

[root@master ~]# chmod -R 777 /var/lib/ganglia

4、重启虚拟机

[root@master ~]# reboot

5、访问ganglia

http://192.168.229.160/ganglia/

6、修改flume配置文件

[root@master ~]# vi /opt/module/flume/conf/flume-env.sh

添加以下内容:

JAVA_OPTS="-Dflume.monitoring.type=ganglia
-Dflume.monitoring.hosts=192.168.229.160:8649  #(修改IP)
-Xms100m
-Xmx200m"

7、创建job文件

在‘/opt/module/flume’目录下创建文件夹‘job’

进入该目录下创建一个名字为‘flume-telnet-logger.conf’文件,并编辑该文件,编辑内容如下:

[root@master job]# vi flume-telnet-logger.conf

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 44444

# Describe the sink 
a1.sinks.k1.type = logger

# Use a channel which buffers events in memory 
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

8、启动Flume服务

[root@master ~]# /opt/module/flume/bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-telnet-logger.conf -Dflume.root.logger=INFO,console -Dflume.monitoring.type=ganglia -Dflume.monitoring.hosts=192.168.229.160:8649

9、重新开启一个xshell端口,发送数据

[root@master ~]# telnet localhost 44444

 

10、查看网页端监控情况

http://192.168.229.160/ganglia/?r=hour&cs=&ce=&c=master&h=master&tab=m&vn=&tz=&hide-hf=false&m=load_one&sh=1&z=small&hc=4&host_regex=&max_graphs=0&s=by+name

 

六、flume日志聚集(MySQL)

1、使用xftp工具上传文件

2、删除mariadb依赖

系统中已经安装了 mariadb-libs-5.5.52-2.el7.x86_64 软件包,需要将其卸载

[root@master ~]# rpm -e mariadb-libs-5.5.65-1.el7.x86_64 --nodeps

已删除。

3、安装mysql服务

[root@master software]# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm --nodeps

[root@master software]# rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm --nodeps

[root@master software]# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm --nodeps

[root@master software]# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm --nodeps

4、启动MySQL服务

[root@master software]# systemctl start mysqld

已启动。

5、查找MySQL初始密码

[root@master software]# grep "password" /var/log/mysqld.log

6、登录MySQL

[root@master ~]# mysql -uroot -p

# 输入初始密码:>q.r#A9(f&4<

7、设置密码复杂度

set global validate_password_policy=LOW;

set global validate_password_length=4;

8、修改密码, 这里设置为root

alter user 'root'@'localhost' identified by 'root';

9、开启远程访问

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

10、使用navicat工具远程连接MySQL

确保MySQL服务正在运行,使用navicat进行远程访问:

连接成功

七、创建msyql source jar包

1、安装maven,在windows本机解压后打开conf目录下的setting.conf,添加阿里云镜像源

2、打开idea,新建一个maven项目

项目详细信息,如果本机没有jdk需要安装jdk

3、导入依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>mysql_sourcde</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.flume</groupId>
            <artifactId>flume-ng-core</artifactId>
            <version>1.6.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.16</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.12</version>
        </dependency>
    </dependencies>


</project>

刷新项目

4、创建目录

5、创建资源文件夹

6、创建两个资源文件jdbc.properties和log4j.properties

7、添加配置

jdbc.properties配置文件如下:

dbDriver=com.mysql.jdbc.Driver
dbUrl=jdbc:mysql://192.168.229.160:3306/mysqlsource? useUnicode=true&characterEncoding=utf-8
dbUser=root
dbPassword=root

log4j.properties配置文件如下:

#--------console-----------
log4j.rootLogger=info,myconsole,myfile log4j.appender.myconsole=org.apache.log4j.ConsoleAppender log4j.appender.myconsole.layout=org.apache.log4j.SimpleLayout #log4j.appender.myconsole.layout.ConversionPattern =%d [%t] %-5p [%c] - %m%n

#log4j.rootLogger=error,myfile
log4j.appender.myfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.myfile.File=/tmp/flume.log log4j.appender.myfile.layout=org.apache.log4j.PatternLayout log4j.appender.myfile.layout.ConversionPattern =%d [%t] %-5p [%c] - %m%n

8、右键java目录,创建包

9、在包内新建两个类

SQLSource代码:

package com.nuit.source;
import org.apache.flume.Context;
import org.apache.flume.Event;
import org.apache.flume.EventDeliveryException;
import org.apache.flume.PollableSource;
import org.apache.flume.conf.Configurable;
import org.apache.flume.event.SimpleEvent;
import org.apache.flume.source.AbstractSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class SQLSource extends AbstractSource implements Configurable, PollableSource {

    //打印日志
    private static final Logger LOG = LoggerFactory.getLogger(SQLSource.class);

    //定义sqlHelper
    private SQLSourceHelper sqlSourceHelper;


    @Override
    public long getBackOffSleepIncrement() {
        return 0;
    }

    @Override
    public long getMaxBackOffSleepInterval() {
        return 0;
    }

    @Override
    public void configure(Context context) {

        try {
            //初始化
            sqlSourceHelper = new SQLSourceHelper(context);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    @Override
    public Status process() throws EventDeliveryException {

        try {
            //查询数据表
            List<List<Object>> result = sqlSourceHelper.executeQuery();

            //存放event的集合
            List<Event> events = new ArrayList<>();

            //存放event头集合
            HashMap<String, String> header = new HashMap<>();

            //如果有返回数据,则将数据封装为event
            if (!result.isEmpty()) {

                List<String> allRows = sqlSourceHelper.getAllRows(result);

                Event event = null;

                for (String row : allRows) {
                    event = new SimpleEvent();
                    event.setBody(row.getBytes());
                    event.setHeaders(header);
                    events.add(event);
                }

                //将event写入channel
                this.getChannelProcessor().processEventBatch(events);

                //更新数据表中的offset信息
                sqlSourceHelper.updateOffset2DB(result.size());
            }

            //等待时长
            Thread.sleep(sqlSourceHelper.getRunQueryDelay());

            return Status.READY;
        } catch (InterruptedException e) {
            LOG.error("Error procesing row", e);

            return Status.BACKOFF;
        }
    }

    @Override
    public synchronized void stop() {

        LOG.info("Stopping sql source {} ...", getName());

        try {
            //关闭资源
            sqlSourceHelper.close();
        } finally {
            super.stop();
        }
    }
}

SQLSourceHelper代码:

package com.nuit.source;
import org.apache.flume.Context;
import org.apache.flume.conf.ConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.sql.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class SQLSourceHelper {

    private static final Logger LOG = LoggerFactory.getLogger(SQLSourceHelper.class);

    private int runQueryDelay, //两次查询的时间间隔
            startFrom,            //开始id
            currentIndex,	        //当前id
            recordSixe = 0,      //每次查询返回结果的条数
            maxRow;                //每次查询的最大条数

    private String table,       //要操作的表
            columnsToSelect,     //用户传入的查询的列
            customQuery,          //用户传入的查询语句
            query,                 //构建的查询语句
            defaultCharsetResultSet;//编码集

    //上下文,用来获取配置文件
    private Context context;

    //为定义的变量赋值(默认值),可在flume任务的配置文件中修改
    private static final int DEFAULT_QUERY_DELAY = 10000;
    private static final int DEFAULT_START_VALUE = 0;
    private static final int DEFAULT_MAX_ROWS = 2000;
    private static final String DEFAULT_COLUMNS_SELECT = "*";
    private static final String DEFAULT_CHARSET_RESULTSET = "UTF-8";

    private static Connection conn = null;
    private static PreparedStatement ps = null;
    private static String connectionURL, connectionUserName, connectionPassword;

    //加载静态资源
    static {

        Properties p = new Properties();

        try {
            p.load(SQLSourceHelper.class.getClassLoader().getResourceAsStream("jdbc.properties"));
            connectionURL = p.getProperty("dbUrl");
            connectionUserName = p.getProperty("dbUser");
            connectionPassword = p.getProperty("dbPassword");
            Class.forName(p.getProperty("dbDriver"));

        } catch (IOException | ClassNotFoundException e) {
            LOG.error(e.toString());
        }
    }

    //获取JDBC连接
    private static Connection InitConnection(String url, String user, String pw) {
        try {

            Connection conn = DriverManager.getConnection(url, user, pw);

            if (conn == null)
                throw new SQLException();

            return conn;

        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }

    //构造方法
    SQLSourceHelper(Context context) throws ParseException {

        //初始化上下文
        this.context = context;

        //有默认值参数:获取flume任务配置文件中的参数,读不到的采用默认值
        this.columnsToSelect = context.getString("columns.to.select", DEFAULT_COLUMNS_SELECT);

        this.runQueryDelay = context.getInteger("run.query.delay", DEFAULT_QUERY_DELAY);

        this.startFrom = context.getInteger("start.from", DEFAULT_START_VALUE);

        this.defaultCharsetResultSet = context.getString("default.charset.resultset", DEFAULT_CHARSET_RESULTSET);

        //无默认值参数:获取flume任务配置文件中的参数
        this.table = context.getString("table");
        this.customQuery = context.getString("custom.query");

        connectionURL = context.getString("connection.url");

        connectionUserName = context.getString("connection.user");

        connectionPassword = context.getString("connection.password");

        conn = InitConnection(connectionURL, connectionUserName, connectionPassword);

        //校验相应的配置信息,如果没有默认值的参数也没赋值,抛出异常
        checkMandatoryProperties();

        //获取当前的id
        currentIndex = getStatusDBIndex(startFrom);

        //构建查询语句
        query = buildQuery();
    }

    //校验相应的配置信息(表,查询语句以及数据库连接的参数)
    private void checkMandatoryProperties() {

        if (table == null) {
            throw new ConfigurationException("property table not set");
        }

        if (connectionURL == null) {
            throw new ConfigurationException("connection.url property not set");
        }

        if (connectionUserName == null) {
            throw new ConfigurationException("connection.user property not set");
        }

        if (connectionPassword == null) {
            throw new ConfigurationException("connection.password property not set");
        }
    }

    //构建sql语句
    private String buildQuery() {

        String sql = "";

        //获取当前id
        currentIndex = getStatusDBIndex(startFrom);
        LOG.info(currentIndex + "");

        if (customQuery == null) {
            sql = "SELECT " + columnsToSelect + " FROM " + table;
        } else {
            sql = customQuery;
        }

        StringBuilder execSql = new StringBuilder(sql);

        //以id作为offset
        if (!sql.contains("where")) {
            execSql.append(" where ");
            execSql.append("id").append(">").append(currentIndex);

            return execSql.toString();
        } else {
            int length = execSql.toString().length();

            return execSql.toString().substring(0, length - String.valueOf(currentIndex).length()) + currentIndex;
        }
    }

    //执行查询
    List<List<Object>> executeQuery() {

        try {
            //每次执行查询时都要重新生成sql,因为id不同
            customQuery = buildQuery();

            //存放结果的集合
            List<List<Object>> results = new ArrayList<>();

            if (ps == null) {
                //
                ps = conn.prepareStatement(customQuery);
            }

            ResultSet result = ps.executeQuery(customQuery);

            while (result.next()) {

                //存放一条数据的集合(多个列)
                List<Object> row = new ArrayList<>();

                //将返回结果放入集合
                for (int i = 1; i <= result.getMetaData().getColumnCount(); i++) {
                    row.add(result.getObject(i));
                }

                results.add(row);
            }

            LOG.info("execSql:" + customQuery + "\nresultSize:" + results.size());

            return results;
        } catch (SQLException e) {
            LOG.error(e.toString());

            // 重新连接
            conn = InitConnection(connectionURL, connectionUserName, connectionPassword);

        }

        return null;
    }

    //将结果集转化为字符串,每一条数据是一个list集合,将每一个小的list集合转化为字符串
    List<String> getAllRows(List<List<Object>> queryResult) {

        List<String> allRows = new ArrayList<>();

        if (queryResult == null || queryResult.isEmpty())
            return allRows;

        StringBuilder row = new StringBuilder();

        for (List<Object> rawRow : queryResult) {

            Object value = null;

            for (Object aRawRow : rawRow) {

                value = aRawRow;

                if (value == null) {
                    row.append(",");
                } else {
                    row.append(aRawRow.toString()).append(",");
                }
            }

            allRows.add(row.toString());
            row = new StringBuilder();
        }

        return allRows;
    }

    //更新offset元数据状态,每次返回结果集后调用。必须记录每次查询的offset值,为程序中断续跑数据时使用,以id为offset
    void updateOffset2DB(int size) {
        //以source_tab做为KEY,如果不存在则插入,存在则更新(每个源表对应一条记录)
        String sql = "insert into flume_meta(source_tab,currentIndex) VALUES('"
                + this.table
                + "','" + (recordSixe += size)
                + "') on DUPLICATE key update source_tab=values(source_tab),currentIndex=values(currentIndex)";

        LOG.info("updateStatus Sql:" + sql);

        execSql(sql);
    }

    //执行sql语句
    private void execSql(String sql) {

        try {
            ps = conn.prepareStatement(sql);

            LOG.info("exec::" + sql);

            ps.execute();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    //获取当前id的offset
    private Integer getStatusDBIndex(int startFrom) {

        //从flume_meta表中查询出当前的id是多少
        String dbIndex = queryOne("select currentIndex from flume_meta where source_tab='" + table + "'");

        if (dbIndex != null) {
            return Integer.parseInt(dbIndex);
        }

        //如果没有数据,则说明是第一次查询或者数据表中还没有存入数据,返回最初传入的值
        return startFrom;
    }

    //查询一条数据的执行语句(当前id)
    private String queryOne(String sql) {

        ResultSet result = null;

        try {
            ps = conn.prepareStatement(sql);
            result = ps.executeQuery();

            while (result.next()) {
                return result.getString(1);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }

    //关闭相关资源
    void close() {

        try {
            ps.close();
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    int getCurrentIndex() {
        return currentIndex;
    }

    void setCurrentIndex(int newValue) {
        currentIndex = newValue;
    }

    int getRunQueryDelay() {
        return runQueryDelay;
    }

    String getQuery() {
        return query;
    }

    String getConnectionURL() {
        return connectionURL;
    }

    private boolean isCustomQuerySet() {
        return (customQuery != null);
    }

    Context getContext() {
        return context;
    }

    public String getConnectionUserName() {
        return connectionUserName;
    }

    public String getConnectionPassword() {
        return connectionPassword;
    }

    String getDefaultCharsetResultSet() {
        return defaultCharsetResultSet;
    }
}

10、打jar包

打包结果:

11、打包成功后,target目录会出现一个jar包

12、打开jar包的位置,并使用xftp工具上传到服务器

13、添加jar包依赖

# 解压mysql-connector-java-5.1.16.tar.gz
[root@master software]# tar -zxf mysql-connector-java-5.1.16.tar.gz -C /opt/module/

# 复制‘mysql-connector-java-5.1.16/mysql-connector-java-5.1.16-bin.jar’、‘mysql_source-1.0-SNAPSHOT.jar’两个压缩包到‘/opt/module/flume/lib/‘目录下

[root@master software]# cp -p mysql_source-1.0-SNAPSHOT.jar /opt/module/flume/lib/

[root@master module]# cp -p mysql-connector-java-5.1.16/mysql-connector-java-5.1.16-bin.jar /opt/module/flume/lib/

14、创建job文件

[root@master job]# pwd

/opt/module/flume/job

[root@master job]# vi mysql.conf

编辑内容如下:

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = com.nuit.source.SQLSource  
a1.sources.r1.connection.url = jdbc:mysql://192.168.229.160:3306/mysqlsource
a1.sources.r1.connection.user = root
a1.sources.r1.connection.password = root
a1.sources.r1.table = student
a1.sources.r1.columns.to.select = *
#a1.sources.r1.incremental.column.name = id
#a1.sources.r1.incremental.value = 0
a1.sources.r1.run.query.delay=5000

# Describe the sink
a1.sinks.k1.type = logger

# Describe the channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

八、测试效果

1、创建一个名为’mysqlsource‘数据库

2、选择刚刚创建的数据库

3、创建数据表

CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `flume_meta` (
`source_tab` varchar(255) NOT NULL,
`currentIndex` varchar(255) NOT NULL,
PRIMARY KEY (`source_tab`)
);

4、向表中插入数据

insert into student values(1,'zhangsan');
insert into student values(2,'lisi');
insert into student values(3,'wangwu');
insert into student values(4,'zhaoliu');

5、查看表的数据

6、退出MySQL,启动flume服务

[root@master flume]# bin/flume-ng agent --conf conf/ --name a1 \
> --conf-file job/mysql.conf -Dflume.root.logger=INFO,console

发现我们插入数据的日志,至此搭建完成!

标签:Flume,flume,课程设计,return,jdk,a1,master,mysql,root
From: https://blog.csdn.net/m0_59839948/article/details/141196429

相关文章

  • 在虚拟机CentOS中安装jdk
    公众号本文地址:在虚拟机CentOS中安装jdk本文主要是记录在CentOS中安装新的JDK的过程。在虚拟机的centos中安装Jdk主要分为三步,第一步上传jdk文件到centos中,第二步解压jdk文件,第三步配置环境变量。一般在安装完CentOS后系统是有jdk的,但是默认为openjdk1.8.0版本由于开发需要使......
  • 课程设计-基于Springboot+Vue的生鲜交易系统的设计与实现(源码+LW+包运行)
    源码获取:https://download.csdn.net/download/u011832806/89460525基于SpringBoot+Vue的生鲜交易系统开发语言:Java数据库:MySQL技术:SpringBoot+MyBatis+Vue.js工具:IDEA/Ecilpse、Navicat、Maven系统演示视频:链接:https://pan.baidu.com/s/1NzmQFwX8e6una-ykZ6KGww?pwd=wa......
  • 课程设计-基于Springboot+Vue的网上书城的设计与实现(源码+LW+包运行)
    源码获取:https://download.csdn.net/download/u011832806/89461644基于SpringBoot+Vue的网上书城开发语言:Java数据库:MySQL技术:SpringBoot+MyBatis+Vue.js工具:IDEA/Ecilpse、Navicat、Maven系统演示视频:链接:https://pan.baidu.com/s/1EWMhc80qzi_R__dAXMtKVA?pwd=t8pv......
  • 高级java每日一道面试题-2024年8月12日-设计模式篇-请列举出在JDK中几个常用的设计模
    如果有遗漏,评论区告诉我进行补充面试官:请列举出在JDK中几个常用的设计模式?我回答:在JavaDevelopmentKit(JDK)中,许多设计模式被广泛使用,以帮助实现软件的结构、行为和复用。下面是一些在JDK中常见的设计模式及其简要说明:工厂模式(FactoryPattern)JDK中的java......
  • JDK自带命令:深入理解Java程序的运行机制
    JDK(JavaDevelopmentKit)是Java开发和运行环境的核心,它提供了丰富的命令和工具来帮助我们更好地理解和控制Java程序的运行。本文将详细介绍JDK自带的一些关键命令,以及它们的详细参数和执行结果。1.jps(JavaVirtualMachineProcessStatusTool)jps命令用于列出正在运行的......
  • 环境配置:如何在IntelliJ IDEA中安装和修改JDK版本配置(以Windows为例)
    环境配置:如何在IntelliJIDEA中安装和修改JDK版本配置(以Windows为例)为了在Java开发中使用最新的功能和优化,升级和配置JDK版本是必不可少的。本文将详细介绍如何下载、安装、配置最新的JDK版本,并在IntelliJIDEA中正确设置项目的JDK版本,确保你的开发环境能够支持最新的Java......
  • Java学习笔记1--JDK,JRE和JVM
    1、Java开发环境Java开发环境是指Java程序员开发、编写、测试和调试Java程序所使用的所有工具和技术。Java开发环境通常由以下几个部分组成:JDK(JavaDevelopmentKit):JDK是Java开发环境的核心组件,它包括了Java编译器、JRE(Java运行环境)、JavaDoc文档生成器和其他一些工具。JDK是J......
  • Java学习笔记2--JDK的安装和配置
    一.进入oracle官网,下载jdkoracle官网:Oracle|CloudApplicationsandCloudPlatformps:不同的浏览器,可能进入oracle官网,会只显示部分内容,所以建议使用googleChrome浏览器在下载之前,首先需要去查看本机电脑的配置型号,如下图,右键---此电脑---选择点击属性,显示x64版本如下......
  • 基于Java的考试信息报名系统 SpringBoot考试报名管理系统 Vue前后端分离【Java毕业设
    ⛄博主介绍:⚡全栈开发工程师,精通Web前后端技术、数据库、架构设计。专注于Java技术领域和小程序领域的开发,毕业设计、课程设计项目中主要包括定制化开发、源代码、代码讲解、文档报告辅导、安装调试等。✅文末获取联系✅目录1项目介绍 2技术选型 3系统总体设计 4......
  • 新手常见错误:Language level is invalid or missing in pom.xml. Current project JDK
    目录Blue留声机:分析报错 Blue留声机:今天开一个maven的时候遇到这样一个报错,这个报错对于我来言是一个并不陌生的报错,早期学习spring框架的时候,遇到过这个问题,当时怎么也弄不出来(现在想想那个时候的我真菜),现在却对这种问题的解决游刃有余。好了,不多bb了,看看我一般处理bu......