step 1 file connect standalone version

edit connect-stand-alone.sh

hduser@node7:~/kafka/bin $ more connect-standalone.sh 
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if [ $# -lt 1 ];
then
        echo "USAGE: $0 [-daemon] connect-standalone.properties"
        exit 1
fi

base_dir=$(dirname $0)

if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
    export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/connect-log4j.properties"
fi

if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
  export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
fi

EXTRA_ARGS=${EXTRA_ARGS-'-name connectStandalone'}

COMMAND=$1
case $COMMAND in
  -daemon)
    EXTRA_ARGS="-daemon "$EXTRA_ARGS
    shift
    ;;
  *)
    ;;
esac

exec $(dirname $0)/kafka-run-class.sh $EXTRA_ARGS org.apache.kafka.connect.cli.ConnectStandalone "$@"

nano kafka-run-class.sh

# JVM performance options
if [ -z "$KAFKA_JVM_PERFORMANCE_OPTS" ]; then
  KAFKA_JVM_PERFORMANCE_OPTS="-client -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupan$
fi

start the server

bin/zookeeper-server-start.sh config/zookeeper.properties

bin/kafka-server-start.sh config/server.properties
#This is an example script for setting up a Kafka Connect
#Task that uses a file system source to publish a topic.

#Command to run kafka-connect with a file source connector and a task.
~/kafka/bin/connect-standalone.sh \
~/kafka/config/connect-standalone.properties \
/home/hduser/kafka-test/connect-file-source.properties

#Command to subscribe and listen
~/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic file-source-test \
--from-beginning
#--------------------------------------------------
#Content of connect-file-source.properties
#--------------------------------------------------

#A logical name for your task
name=demo-file-source

#Class of connector to use
connector.class=FileStreamSource

#Number of parallel tasks to launch. Provides scalability
tasks.max=1

#Local file to monitor for new input
file=/home/hduser/kafka-test/source-file/file-test.txt

#Topic to publish data to.
topic=file-source-test

step 2 jdbc connect standalone version

start the server

~/kafka/bin/zookeeper-server-start.sh ~/kafka/config/zookeeper.properties

~/kafka/bin/kafka-server-start.sh ~/kafka/config/server.properties

~/kafka/bin/connect-standalone.sh \
~/kafka/config/connect-standalone.properties \
/home/huayun/lib/connect-jdbc-source.properties 

#Command to subscribe and listen
~/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--zookeeper localhost:2181 \
--topic jdbc-source-jdbc_source \
--from-beginning

#--------------------------------------------------
#Content of connect-jdbc-source.properties
#--------------------------------------------------
#name of the connector
name=demo-jdbc-source
#connector class to be used.
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
#JDBC connector URL for mysql. make sure the mysql driver is in classpath.
connection.url=jdbc:mysql://localhost:3306/jdbctest?user=root&password=
#List of tables to publish. you can also use blacklists
table.whitelist=jdbc_source
#No. of parallel tasks. Ideally one per table.
tasks.max=1

#How frequently to poll the db for new records
poll.interval.ms=2000
#mode - incrementing or timestamp+incrementing
mode=incrementing
incrementing.column.name=TEST_ID

#topic name to be created. This will create a topic jdbc-source-jdbc_source
#with the database name appended.
topic.prefix=jdbc-source-

#------------------------------------------------------------------

#This is the sample structure of each record published.
{
	"schema": {
		"type": "struct",
		"fields": [{
			"type": "int32",
			"optional": false,
			"field": "TEST_ID"
		},
		{
			"type": "int64",
			"optional": false,
			"name": "org.apache.kafka.connect.data.Timestamp",
			"version": 1,
			"field": "TEST_TIMESTAMP"
		}],
		"optional": false,
		"name": "jdbc_source"
	},
	"payload": {
		"TEST_ID": 1,
		"TEST_TIMESTAMP": 1495379345000
	}
}