大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
databus 分为 relay bootstrap-producer(bst-producer) bootstrap-server(bst-server) client,他们之间的关系可以去网上找 这里主要介绍部署这四个工程的方法
1 relay 侦听端口为 11115
1.1 relay.properties
databus.relay.container.httpPort=11115
databus.relay.container.jmx.rmiEnabled=false
databus.relay.eventBuffer.allocationPolicy=DIRECT_MEMORY
databus.relay.eventBuffer.queuePolicy=OVERWRITE_ON_WRITE
databus.relay.eventLogReader.enabled=false
databus.relay.eventLogWriter.enabled=false
databus.relay.schemaRegistry.type=FILE_SYSTEM
databus.relay.eventBuffer.maxSize=1024000000
databus.relay.eventBuffer.readBufferSize=10240
databus.relay.eventBuffer.scnIndexSize=10240000
#databus.relay.physicalSourcesConfigsPattern=conf/sources.json
databus.relay.dataSources.sequenceNumbersHandler.file.scnDir=./maxScn
databus.relay.startDbPuller=true
1.2 start.sh
cd `dirname $0`/..
script_dir=./bin
source $script_dir/setup.inc
source $script_dir/setup-relay.inc
cli_overrides=
# DEFAULT VALUES
relay_type=default
jvm_gc_log=${logs_dir}/relay-gc.log
db_relay_config=
# JVM ARGUMENTS
jvm_direct_memory_size=40g
jvm_direct_memory=”-XX:MaxDirectMemorySize=${jvm_direct_memory_size}”
jvm_min_heap_size=”1024m”
jvm_min_heap=”-Xms${jvm_min_heap_size}”
jvm_max_heap_size=”1024m”
jvm_max_heap=”-Xmx${jvm_max_heap_size}”
jvm_gc_options=”-XX:NewSize=512m -XX:MaxNewSize=512m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:SurvivorRatio=6 -XX:MaxTenuringThreshold=7″
jvm_gc_log_option=”-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution “
if [ ! -z “${jvm_gc_log}” ] ; then
jvm_gc_log_option=”${jvm_gc_log_option} -Xloggc:${jvm_gc_log}”
fi
jvm_arg_line=”-d64 ${jvm_direct_memory} ${jvm_min_heap} ${jvm_max_heap} ${jvm_gc_options} ${jvm_gc_log_option} -ea”
log4j_file_option=”-l ${conf_dir}/relay_log4j.properties”
config_file_option=”-p ${conf_dir}/relay.properties”
#source_file_option=-db_relay_config=conf/sources.json
java_arg_line=”${config_file_option} ${log4j_file_option}”
if [ ! -z “$cli_overrides” ] ; then
cli_overrides=”-c ‘$cli_overrides'”
fi
#main_class=com.linkedin.databus.relay.example.PersonRelayServer;
main_class=com.linkedin.databus2.relay.DatabusRelayMain
cmdline=”java -cp ${cp} ${jvm_arg_line} ${main_class} ${java_arg_line} $cli_overrides $*”
echo $cmdline
$cmdline 2>&1 > ${relay_out_file} &
echo $! > ${relay_pid_file}
启动
sh start.sh -db_relay_config=conf/sources.json
这个和官方默认提供的 start-example-relay.sh 大部分是一样的 只是把main_cliass改成了DatabusRelayMain 去掉了原来需要启动时 传参的person
然后启动的时候 指定 sources.json
当然 你也可以用原先的 PersonRelayServer 这个类已经把sources-person.json定死了 或者 你也可以在sh文件中定死
比较一下 PersonRelayServer 与 DatabusRelayMain 中的main方法 发现 PersonRelayServer 中就多了一行
cli.setDefaultPhysicalSrcConfigFiles(“conf/sources-person.json”);
2 bst-producer 侦听端口为 11116
2.1 在mysql中添加相应的数据库
默认的数据库名称为 bootstarp 你可以在配置文件中更改
然后运行 cdsddl.tab 文件 把相应的表数据添加到mysql中
CREATE TABLE bootstrap_sources (
id int(11) NOT NULL auto_increment,
src varchar(255) NOT NULL,
status TINYINT default 1,
logstartscn bigint(20) default 0,
PRIMARY KEY (id),
UNIQUE KEY src (src)
) ENGINE=InnoDB;
CREATE TABLE bootstrap_loginfo (
srcid int(11) NOT NULL,
logid int(11) NOT NULL default 0,
minwindowscn bigint(20) NOT NULL default -1,
maxwindowscn bigint(20) NOT NULL default -1,
maxrid bigint(20) NOT NULL default 0,
deleted TINYINT default 0,
PRIMARY KEY (srcid, logid)
) ENGINE=InnoDB;
CREATE TABLE bootstrap_producer_state (
srcid int(11) NOT NULL,
logid int(11) NOT NULL default 0,
windowscn bigint(20) NOT NULL default 0,
rid bigint(20) NOT NULL default 0,
PRIMARY KEY (srcid)
) ENGINE=InnoDB;
CREATE TABLE bootstrap_applier_state (
srcid int(11) NOT NULL,
logid int(11) NOT NULL default 0,
windowscn bigint(20) NOT NULL default 0,
rid bigint(20) NOT NULL default 0,
PRIMARY KEY (srcid)
) ENGINE=InnoDB;
CREATE TABLE bootstrap_seeder_state (
srcid int(11) NOT NULL,
startscn bigint(20) NOT NULL default -1,
endscn bigint(20) NOT NULL default -1,
rid bigint(20) NOT NULL default 0,
srckey varchar(255) NOT NULL,
PRIMARY KEY (srcid)
) ENGINE=InnoDB;
CREATE TABLE bootstrap_tab_minscn (
srcid int(11) NOT NULL,
minscn bigint(20) NOT NULL default -1,
PRIMARY KEY (srcid)
) ENGINE=InnoDB;
2.2 databus-bst-producer.properties
databus.bootstrap.bootstrapDBHostname=your_mysql_host
databus.bootstrap.bootstrapDBUsername=your_mysql_username
databus.bootstrap.bootstrapDBPassword=your_mysql_password
#databus.bootstrap.bootstrapDBName=dbbus
databus.bootstrap.bootstrapLogSize=1024000
databus.bootstrap.client.container.httpPort=11116
databus.bootstrap.client.container.jmx.rmiEnabled=false
databus.bootstrap.client.connectionDefaults.pullerRetries.initSleep=50
databus.bootstrap.client.connectionDefaults.pullerRetries.maxSleep=60000
databus.bootstrap.client.connectionDefaults.pullerRetries.maxRetryNum=-1
databus.bootstrap.client.connectionDefaults.dispatcherRetries.initSleep=0
databus.bootstrap.client.connectionDefaults.dispatcherRetries.maxSleep=60000
databus.bootstrap.client.connectionDefaults.dispatcherRetries.maxRetryNum=-1
databus.bootstrap.client.connectionDefaults.eventBuffer.maxSize=10240000
databus.bootstrap.client.connectionDefaults.eventBuffer.readBufferSize=1024000
databus.bootstrap.client.connectionDefaults.eventBuffer.scnIndexSize=128
databus.bootstrap.client.connectionDefaults.eventBuffer.allocationPolicy=HEAP_MEMORY
databus.bootstrap.client.checkpointPersistence.fileSystem.rootDirectory=var/checkpoints
#这个为relay侦听的ip与端口
databus.bootstrap.client.runtime.relay(1).host=127.0.0.1
databus.bootstrap.client.runtime.relay(1).port=11115
databus.bootstrap.client.runtime.relay(1).sources=com.linkedin.events.example.person.Person
2.3 start-bst-producer.sh
用默认的 start-bst-producer.sh 即可
3 bst-server 侦听端口为11117
3.1 databus-bst-server.properties
#这里的mysql地址应该与bst-producer中一致
databus.bootstrap.db.bootstrapDBHostname=your_mysql_host
databus.bootstrap.db.bootstrapDBUsername=your_mysql_username
databus.bootstrap.db.bootstrapDBPassword=your_mysql_password
#databus.bootstrap.db.bootstrapDBName=dbbus
databus.bootstrap.db.bootstrapLogSize=1024000
databus.bootstrap.db.bootstrapBatchSize=1000
databus.bootstrap.db.container.httpPort=11117
databus.bootstrap.db.container.jmx.rmiEnabled=false
databus.bootstrap.defaultRowsThresholdForSnapshotBypass=-1
databus.bootstrap.enableMinScnCheck=false
3.2 start-bst-server.sh
用官方提供的默认 start-bst-server.sh 即可
4 client 侦听端口为11118
4.1 client.properties
databus.client.container.httpPort=11118
databus.relay.container.jmx.rmiEnabled=false
databus.relay.eventBuffer.allocationPolicy=DIRECT_MEMORY
databus.relay.eventBuffer.queuePolicy=BLOCK_ON_WRITE
databus.relay.schemaRegistry.type=FILE_SYSTEM
databus.relay.eventBuffer.maxSize=10240000
databus.relay.eventBuffer.readBufferSize=1024000
databus.relay.eventBuffer.scnIndexSize=1024000
databus.client.connectionDefaults.pullerRetries.initSleep=1
databus.client.checkpointPersistence.fileSystem.rootDirectory=./client-checkpoints
databus.client.checkpointPersistence.clearBeforeUse=false
databus.client.connectionDefaults.enablePullerMessageQueueLogging=false
#以下为relay的ip和端口
databus.client.runtime.relay(1).host=127.0.0.1
databus.client.runtime.relay(1).port=11115
databus.client.runtime.relay(1).sources=com.linkedin.events.example.person.Person
#以下为bst-server的ip和端口
databus.client.runtime.bootstrap.enabled=true
databus.client.runtime.bootstrap.service(1).host=127.0.0.1
databus.client.runtime.bootstrap.service(1).port=11117
databus.client.runtime.bootstrap.service(1).sources=com.linkedin.events.example.person.Person
4.2 启动类 ClientMain.java
public class ClientMain {
public static void main(String[] args) throws Exception {
Properties startupProps = ServerContainer.processCommandLineArgs(args);
ConfigLoader configLoader = new ConfigLoader(
“databus.client.”, new DatabusHttpClientImpl.Config());
DatabusHttpClientImpl.StaticConfig clientConfig = configLoader.loadConfig(startupProps);
DatabusHttpClientImpl client = new DatabusHttpClientImpl(clientConfig);
PersonConsumer personConsumer = new PersonConsumer();
client.registerDatabusStreamListener(personConsumer, null, PersonClientMain.PERSON_SOURCE,
PersonClientMain.ANIMAL_SOURCE);
client.registerDatabusBootstrapListener(personConsumer, null, PersonClientMain.PERSON_SOURCE,
PersonClientMain.ANIMAL_SOURCE);
client.startAndBlock();
}
}
4.3 start.sh
cd `dirname $0`/..
script_dir=./bin
source $script_dir/setup.inc
source $script_dir/setup-client.inc
cli_overrides=
# DEFAULT VALUES
client_type=default
jvm_gc_log=${logs_dir}/client-gc.log
# JVM ARGUMENTS
jvm_direct_memory_size=40g
jvm_direct_memory=”-XX:MaxDirectMemorySize=${jvm_direct_memory_size}”
jvm_min_heap_size=”1024m”
jvm_min_heap=”-Xms${jvm_min_heap_size}”
jvm_max_heap_size=”1024m”
jvm_max_heap=”-Xmx${jvm_max_heap_size}”
jvm_gc_options=”-XX:NewSize=512m -XX:MaxNewSize=512m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:SurvivorRatio=6 -XX:MaxTenuringThreshold=7″
jvm_gc_log_option=”-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution “
if [ ! -z “${jvm_gc_log}” ] ; then
jvm_gc_log_option=”${jvm_gc_log_option} -Xloggc:${jvm_gc_log}”
fi
jvm_arg_line=”-d64 ${jvm_direct_memory} ${jvm_min_heap} ${jvm_max_heap} ${jvm_gc_options} ${jvm_gc_log_option} -ea”
log4j_file_option=”-l ${conf_dir}/client_log4j.properties”
config_file_option=”-p ${conf_dir}/client.properties”
java_arg_line=”${config_file_option} ${log4j_file_option}”
if [ ! -z “$cli_overrides” ] ; then
cli_overrides=”-c ‘$cli_overrides'”
fi
#main_class=com.linkedin.databus.client.example.PersonClientMain;
main_class=com.linkedin.databus.client.example.ClientMain;
cmdline=”java -cp ${cp} ${jvm_arg_line} ${main_class} ${java_arg_line} $cli_overrides $*”
echo $cmdline
$cmdline 2>&1 > ${client_out_file} &
echo $! > ${client_pid_file}
与老的 start-example-client.sh 相比 也只是把 main_class 改了 同时删除了启动是所需传的person 参数
5 相应的 setup-xxx.inc stop-xxxx.sh 文件也最好改一下
如
setup-client.inc
var_dir=${script_dir}/../var
if [ ! -d ${var_dir} ] ; then
mkdir -p ${var_dir}
fi
client_pid_file=${var_dir}/databus2-client.pid
client_out_file=${logs_dir}/databus2-client.out
setup-relay.inc
var_dir=${script_dir}/../var
if [ ! -d ${var_dir} ] ; then
mkdir -p ${var_dir}
fi
relay_pid_file=${var_dir}/databus2-relay.pid
relay_out_file=${logs_dir}/databus2-relay.out
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/181070.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...