databus bootstrap 部署

databus 分為 relay bootstrap-producer(bst-producer) bootstrap-server(bst-server) client,他們之間的關系可以去網(wǎng)上找 這里主要介紹部署這四個工程的方法

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 這個類已經(jīng)把sources-person.json定死了 或者 你也可以在sh文件中定死
比較一下 PersonRelayServer 與 DatabusRelayMain 中的main方法 發(fā)現(xiàn) PersonRelayServer 中就多了一行

cli.setDefaultPhysicalSrcConfigFiles("conf/sources-person.json");

2 bst-producer 偵聽端口為 11116

2.1 在mysql中添加相應的數(shù)據(jù)庫

默認的數(shù)據(jù)庫名稱為 bootstarp 你可以在配置文件中更改
然后運行 cdsddl.tab 文件 把相應的表數(shù)據(jù)添加到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<DatabusHttpClientImpl.StaticConfig> configLoader = new ConfigLoader<DatabusHttpClientImpl.StaticConfig>(
                "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 參數(shù)

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
最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市券时,隨后出現(xiàn)的幾起案子矩距,更是在濱河造成了極大的恐慌,老刑警劉巖瘩绒,帶你破解...
    沈念sama閱讀 222,378評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件列牺,死亡現(xiàn)場離奇詭異,居然都是意外死亡划纽,警方通過查閱死者的電腦和手機脆侮,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,970評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來勇劣,“玉大人靖避,你說我怎么就攤上這事”饶” “怎么了幻捏?”我有些...
    開封第一講書人閱讀 168,983評論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長命咐。 經(jīng)常有香客問我篡九,道長,這世上最難降的妖魔是什么醋奠? 我笑而不...
    開封第一講書人閱讀 59,938評論 1 299
  • 正文 為了忘掉前任榛臼,我火速辦了婚禮,結(jié)果婚禮上窜司,老公的妹妹穿的比我還像新娘沛善。我一直安慰自己,他們只是感情好塞祈,可當我...
    茶點故事閱讀 68,955評論 6 398
  • 文/花漫 我一把揭開白布金刁。 她就那樣靜靜地躺著,像睡著了一般议薪。 火紅的嫁衣襯著肌膚如雪尤蛮。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,549評論 1 312
  • 那天斯议,我揣著相機與錄音产捞,去河邊找鬼。 笑死捅位,一個胖子當著我的面吹牛轧葛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播艇搀,決...
    沈念sama閱讀 41,063評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼尿扯,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了焰雕?” 一聲冷哼從身側(cè)響起衷笋,我...
    開封第一講書人閱讀 39,991評論 0 277
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎矩屁,沒想到半個月后辟宗,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體爵赵,經(jīng)...
    沈念sama閱讀 46,522評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,604評論 3 342
  • 正文 我和宋清朗相戀三年泊脐,在試婚紗的時候發(fā)現(xiàn)自己被綠了空幻。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,742評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡容客,死狀恐怖秕铛,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情缩挑,我是刑警寧澤但两,帶...
    沈念sama閱讀 36,413評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站供置,受9級特大地震影響谨湘,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜芥丧,卻給世界環(huán)境...
    茶點故事閱讀 42,094評論 3 335
  • 文/蒙蒙 一紧阔、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧娄柳,春花似錦寓辱、人聲如沸艘绍。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,572評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽诱鞠。三九已至挎挖,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間航夺,已是汗流浹背蕉朵。 一陣腳步聲響...
    開封第一講書人閱讀 33,671評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留阳掐,地道東北人始衅。 一個月前我還...
    沈念sama閱讀 49,159評論 3 378
  • 正文 我出身青樓,卻偏偏與公主長得像缭保,于是被迫代替她去往敵國和親汛闸。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,747評論 2 361

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理艺骂,服務發(fā)現(xiàn)诸老,斷路器摊唇,智...
    卡卡羅2017閱讀 134,714評論 18 139
  • 一碌廓、入門1、簡介Kafka is a distributed,partitioned,replicated com...
    HxLiang閱讀 3,352評論 0 9
  • Kafka入門經(jīng)典教程-Kafka-about云開發(fā) http://www.aboutyun.com/threa...
    葡萄喃喃囈語閱讀 10,842評論 4 54
  • ** 今天看了一下kafka官網(wǎng),嘗試著在自己電腦上安裝和配置盅称,然后學一下官方document。** Introd...
    RainChang閱讀 5,010評論 1 30
  • 一拷橘、基本概念 介紹 Kafka是一個分布式的舞虱、可分區(qū)的、可復制的消息系統(tǒng)类茂。它提供了普通消息系統(tǒng)的功能调卑,但具有自己獨...
    ITsupuerlady閱讀 1,632評論 0 9