国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

elasticsearch+canal增量、全量同步

這篇具有很好參考價值的文章主要介紹了elasticsearch+canal增量、全量同步。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

目錄

一、搭建環(huán)境:

1.1 下載軟件上傳到linux目錄/data/soft下

1.2? 把所有軟件解壓到/data/es-cluster

二、單節(jié)點(多節(jié)點同理)集群部署elasticsearch

2.1 創(chuàng)建es用戶

2.2 準備節(jié)點通訊證書

2.3 配置elasticsearch,編輯/data/es-cluster/elasticsearch-7.9.0-node1/config/elasticsearch.yml文件

2.4 在每一臺集群機器上修改linux讀寫配置

2.5 使用ik分詞器

?編輯2.6 啟動es服務(wù)

2.7 es加密訪問(只需要一個節(jié)點執(zhí)行即可,es會把密碼創(chuàng)建到.security索引下)

2.8 測試訪問,請求xxx.xxx.xxx.xxx:9201/_cat/nodes,需要輸入密碼(elastic賬號為超管),輸入密碼,顯示節(jié)點信息說明成功。

三、安裝kibana控制臺

四、安裝canal服務(wù)端(canal-deployer-1.1.5)(單機)

4.1 mysql開啟binlog,并創(chuàng)建canal從節(jié)點賬號

4.2 修改canal服務(wù)端(canal-deployer-1.1.5)配置

五、安裝canal客戶端(canal-adapter-1.1.5)

5.1 修改配置/conf/application .yml ,按如下配置即可,主要是修改canal-server配置、數(shù)據(jù)源配置和客戶端適配器配置:

5.2 添加配置文件canal-adapter/conf/es7/canal_xxx_01_index.yml,用于配置MySQL中的表與Elasticsearch中索引的映射關(guān)系

5.3?客戶端啟動druid依賴沖突解決

5.4 啟動

5.5?查看日志

六、?canal-admin安裝(可以選擇性安裝)

6.1?創(chuàng)建canal-admin需要使用的數(shù)據(jù)庫canal_manager,創(chuàng)建SQL腳本為/mydata/canal-admin/conf/canal_manager.sql,會創(chuàng)建如下表;

6.2?修改配置文件conf/application.yml,按如下配置即可,主要是修改數(shù)據(jù)源配置和canal-admin的管理賬號配置,注意需要用一個有讀寫權(quán)限的數(shù)據(jù)庫賬號,比如管理賬號root:root;

6.3?接下來對之前搭建的canal-server的conf/canal_local.properties文件進行配置,主要是修改canal-admin的配置,修改完成后使用sh bin/startup.sh local重啟canal-server

七、 全量同步

7.1 方法一

7.2 全量同步方法二(推薦)

查詢所有訂閱同步的canal instance或MQ topic

數(shù)據(jù)同步開關(guān)狀態(tài)

手動ETL


一、搭建環(huán)境:

jdk 8

mysql 8

centos 7.8

canal.adapter-1.1.5 ?

canal.admin-1.1.5 ?

canal.deployer-1.1.5

elasticsearch-7.9.0

kibana-7.9.0

elasticsearch-analysis-ik-7.9.0

1.1 下載軟件上傳到linux目錄/data/soft下
1.2? 把所有軟件解壓到/data/es-cluster
## tar.gz解壓命令
tar -zxvf /data/soft/xxx.tar.gz -C /data/es-cluster
## unzip解壓命令
unzip /data/soft/xxx.zip /data/es-cluster

?解壓后如下:(elasticsearch-7.9.0-node1跟elasticsearch-7.9.0-node2配置不一樣,后邊會說到,node2由node1解壓后復制而來)es增量同步,elasticsearch,大數(shù)據(jù),搜索引擎,canal

二、單節(jié)點(多節(jié)點同理)集群部署elasticsearch

2.1 創(chuàng)建es用戶

因為安全問題,Elasticsearch 不允許 root 用戶直接運行,所以要在每個節(jié)點中創(chuàng)建新用
戶,在 root 用戶中創(chuàng)建新用戶:

useradd es-cluster #新增 es-cluster 用戶
passwd es-cluster #為 es-cluster 用戶設(shè)置密碼
userdel -r es-cluster #如果錯了,可以刪除再加
chown -R es-cluster:es-cluster /data/es-cluster #文件夾所有者
2.2 準備節(jié)點通訊證書
  • 生成ca證書:
## 切換到/data/es-cluster/elasticsearch-7.9.0-node1/bin,執(zhí)行下邊的命令,生成的壓縮包在/data/es-cluster/elasticsearch-7.9.0-node1下:
./elasticsearch-certutil ca --pem --out ca.zip --days 365000 -s  
## 查看證書有效期:
openssl x509 -in ca.crt -noout -dates
  • 到/data/es-cluster/elasticsearch-7.9.0-node1下解壓ca.zip:
unzip ca.zip
  • 使用解壓出來的ca.key、ca.crt生成cert證書,并解壓:
./elasticsearch-certutil cert --ca-cert ca/ca.crt --ca-key ca/ca.key --pem --name za-test --out za-test.zip --days 365000 -s
## 解壓za-test.zip 
unzip za-test.zip
  • 將證書拷貝到目錄/data/es-cluster/elasticsearch-7.9.0-node1/config/certs,沒有certs目錄自己建一個:
cp ca/* za-test/* config/certs
  • 將/data/es-cluster/elasticsearch-7.9.0-node1/config/certs文件夾拷貝到集群所有機器
2.3 配置elasticsearch,編輯/data/es-cluster/elasticsearch-7.9.0-node1/config/elasticsearch.yml文件
#集群名稱
cluster.name: cluster-es
#節(jié)點名稱,每個節(jié)點的名稱不能重復
node.name: node-1
#ip 地址,每個節(jié)點的地址不能重復(填localhost訪問不了)
network.host: xxx.xxx.xxx.xxx
#是不是有資格主節(jié)點
node.master: true
node.data: true
http.port: 9201
transport.tcp.port: 9301
# head 插件需要這打開這兩個配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一個新的集群時需要此配置來選舉 master.(子節(jié)點不需要配置)
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,節(jié)點發(fā)現(xiàn)(localhost節(jié)點沒法找到主節(jié)點,無法加入集群),因為我是單節(jié)點,所以ip是一樣的,端口不一樣。如果是多節(jié)點,端口可以都是9301.
discovery.seed_hosts: ["xxx.xxx.xxx.xxx:9301","xxx.xxx.xxx.xxx:9302"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
#集群內(nèi)同時啟動的數(shù)據(jù)任務(wù)個數(shù),默認是 2 個
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或刪除節(jié)點及負載均衡時并發(fā)恢復的線程個數(shù),默認 4 個
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化數(shù)據(jù)恢復時,并發(fā)恢復線程的個數(shù),默認 4 個
cluster.routing.allocation.node_initial_primaries_recoveries: 16
#索引自動創(chuàng)建。這里限制需不需要自動創(chuàng)建索引。因為我自己的索引都是canal開頭,所以我使用-canal*,不讓es自己創(chuàng)建索引。根據(jù)自己的實際來配置。除了-canal*根據(jù)自己的實際配置,其他都是必須的。
action.auto_create_index: +first*,-canal_*,+.watches*,+.triggered_watches,+.watcher-history-*,+.kibana*,+.ilm*,+.tasks*,+.apm*
#配置密碼
xpack.security.enabled: true
#xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.key: certs/za-test.key
xpack.security.transport.ssl.certificate: certs/za-test.crt
xpack.security.transport.ssl.certificate_authorities: certs/ca.crt

編輯/data/es-cluster/elasticsearch-7.9.0-node2/config/elasticsearch.yml文件:

#集群名稱
cluster.name: cluster-es
#節(jié)點名稱,每個節(jié)點的名稱不能重復
node.name: node-1
#ip 地址,每個節(jié)點的地址不能重復(填localhost訪問不了)
network.host: xxx.xxx.xxx.xxx
#是不是有資格主節(jié)點
node.master: true
node.data: true
## 如果是多節(jié)點集群,端口可以不用修改默認9201即可
http.port: 9202
## 如果是多節(jié)點集群,端口可以不用修改默認9301即可
transport.tcp.port: 9302
# head 插件需要這打開這兩個配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一個新的集群時需要此配置來選舉 master.(子節(jié)點不需要配置)
#cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,節(jié)點發(fā)現(xiàn)(localhost節(jié)點沒法找到主節(jié)點,無法加入集群),因為我是單節(jié)點,所以ip是一樣的,端口不一樣。如果是多節(jié)點,端口可以都是9301.
discovery.seed_hosts: ["xxx.xxx.xxx.xxx:9301","xxx.xxx.xxx.xxx:9302"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
#集群內(nèi)同時啟動的數(shù)據(jù)任務(wù)個數(shù),默認是 2 個
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或刪除節(jié)點及負載均衡時并發(fā)恢復的線程個數(shù),默認 4 個
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化數(shù)據(jù)恢復時,并發(fā)恢復線程的個數(shù),默認 4 個
cluster.routing.allocation.node_initial_primaries_recoveries: 16
#索引自動創(chuàng)建,這里限制需不需要自動創(chuàng)建索引。因為我自己的索引都是canal開頭,所以我使用-canal*,不讓es自己創(chuàng)建索引。除了-canal*根據(jù)自己的實際配置,其他都是必須的。
action.auto_create_index: +first*,-canal_*,+.watches*,+.triggered_watches,+.watcher-history-*,+.kibana*,+.ilm*,+.tasks*,+.apm*
#配置密碼
xpack.security.enabled: true
#xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.key: certs/za-test.key
xpack.security.transport.ssl.certificate: certs/za-test.crt
xpack.security.transport.ssl.certificate_authorities: certs/ca.crt
2.4 在每一臺集群機器上修改linux讀寫配置
  • 修改/etc/security/limits.conf
# 注:* 帶表 Linux 所有用戶名稱
* soft nofile 65535
* hard nofile 65535
或者(指定用戶)
es-cluster soft nofile 65535
es-cluster hard nofile 65535
  • 修改/etc/security/limits.d/20-nproc.conf
es-cluster soft nofile 65536
es-cluster hard nofile 65536
* hard nproc 4096
  • 修改/etc/sysctl.conf
# 在文件中增加下面內(nèi)容
vm.max_map_count=655360
  • 重新加載配置
sysctl -p 
2.5 使用ik分詞器

解壓/data/soft/elasticsearch-analysis-ik-7.9.0.zip到每一臺集群機器/data/es-cluster/elasticsearch-7.9.0-nodexx/plugins下。

如果某些內(nèi)容需要自定義分詞效果,可以進行以下操作:

進入 es plugins 文件夾下的 ik 文件夾,進入 config 目錄,創(chuàng)建 custom.dic文件,比如我要`弗雷爾卓德`不分詞,就把`弗雷爾卓德`寫到custom.dic里邊,使用回車換行,區(qū)分。同時打開 IKAnalyzer.cfg.xml 文件,將新建的 custom.dic 配置其中:

es增量同步,elasticsearch,大數(shù)據(jù),搜索引擎,canal
2.6 啟動es服務(wù)

首次啟動es,先給文件賦值權(quán)限,使用root賬戶執(zhí)行:

chown -R es-cluster:es-cluster /data/es-cluster #文件夾所有者

切換es-cluster用戶:

su es-cluster

執(zhí)行命令依次啟動每個集群es:

#啟動
bin/elasticsearch
#后臺啟動
bin/elasticsearch -d

注意:首次啟動,因為沒有l(wèi)og文件,報錯,暫停,切換root執(zhí)行chown -R es-cluster:es-cluster /data/soft/es-cluster,再切換回es用戶啟動即可。

2.7 es加密訪問(只需要一個節(jié)點執(zhí)行即可,es會把密碼創(chuàng)建到.security索引下

切換到es bin目錄執(zhí)行命令,并輸入密碼即可:

./elasticsearch-setup-passwords interactive

需要配置密碼的內(nèi)置用戶有:?

## es內(nèi)置用戶
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
2.8 測試訪問,請求xxx.xxx.xxx.xxx:9201/_cat/nodes,需要輸入密碼(elastic賬號為超管),輸入密碼,顯示節(jié)點信息說明成功。

三、安裝kibana控制臺

  • 修改解壓出來的kibana文件 /data/es-cluster/kibana-7.9.0/config/kibana.yml文件:
# 默認端口
server.port: 5601
#允許遠程訪問的地址配置,默認為本機,如果需要把 Kibana 服務(wù)給遠程主機訪問,只需要在這個配置中填寫遠程的那臺
#主機的 ip 地址,那如果希望所有的遠程主機都能訪問,那就填寫 0.0.0.0
server.host: "0.0.0.0"

# ES 服務(wù)器的地址
elasticsearch.hosts: ["http://xxx.xxx.xx1:9201","http://xxx.xxx.xx2:9201"]
# 索引名
kibana.index: ".kibana"
# 支持中文
i18n.locale: "zh-CN"

## 配置es與kibana通訊賬密
# 該參數(shù)意思為任意長度為32以上的字符串
elasticsearch.username: "kibana_system"
## 上邊es設(shè)置的kibana_system的密碼
elasticsearch.password: "xxxx"

# must be a positive integer.
elasticsearch.requestTimeout: 50000
# Time in milliseconds for Elasticsearch to wait for responses from shards. Set to 0 to disable.
elasticsearch.shardTimeout: 30000
# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying.
elasticsearch.startupTimeout: 5000


## 日志輸出
# Enables you to specify a file where Kibana stores log output.
logging.dest: ./kibana.log
# Set the value of this setting to true to suppress all logging output.
logging.silent: false
# Set the value of this setting to true to suppress all logging output other than error messages.
logging.quiet: false
# Set the value of this setting to true to log all events, including system usage information
# and all requests.
logging.verbose: false
  • 啟動kibana:
## kibana啟動:
./bin/kibana &
## kibana指定配置文件啟動:
nohup /bin/kibana -c /config/kibana.yml > /dev/null 2>&1 &

訪問xxx.xxx.xxx.xxx:5601輸入賬號密碼即可訪問。

四、安裝canal服務(wù)端(canal-deployer-1.1.5)(單機)

4.1 mysql開啟binlog,并創(chuàng)建canal從節(jié)點賬號
  • mysql需要開啟binlog,以及設(shè)置日志格式

[mysqld]
## 設(shè)置server_id,同一局域網(wǎng)中需要唯一
server_id=101 
## 指定不需要同步的數(shù)據(jù)庫名稱
binlog-ignore-db=mysql  
## 開啟二進制日志功能
log-bin=mall-mysql-bin  
## 設(shè)置二進制日志使用內(nèi)存大?。ㄊ聞?wù))
binlog_cache_size=1M  
## 設(shè)置使用的二進制日志格式(mixed,statement,row)
binlog_format=row  
## 二進制日志過期清理時間。默認值為0,表示不自動清理。
expire_logs_days=30
## 跳過主從復制中遇到的所有錯誤或指定類型的錯誤,避免slave端復制中斷。
## 如:1062錯誤是指一些主鍵重復,1032錯誤是因為主從數(shù)據(jù)庫數(shù)據(jù)不一致
slave_skip_errors=1062  
  • ?配置完成后需要重新啟動MySQL,重啟成功后通過如下命令查看binlog是否啟用.
show variables like '%log_bin%';
show variables like 'binlog_format%';  
  • 創(chuàng)建從庫賬號(后邊需要使用)
CREATE USER canal IDENTIFIED BY 'canal';  
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
FLUSH PRIVILEGES;
4.2 修改canal服務(wù)端(canal-deployer-1.1.5)配置
  • 修改配置/conf/canal.properties,除了ip和port外,其他配置可不改動。
#canal的server地址:127.0.0.1
canal.ip = xxx.xxx.xxx.aaa
#canal端口,用于客戶端監(jiān)聽
canal.port = 11111
  • 修改配置/conf/example/instance.properties
#被同步的mysql地址
canal.instance.master.address=xxx.xxx.xxx.bbb:3306
#數(shù)據(jù)庫從庫權(quán)限賬號(需要提前準備)
canal.instance.dbUsername=canal
#數(shù)據(jù)庫從庫權(quán)限賬號的密碼
canal.instance.dbPassword=canal
#數(shù)據(jù)庫連接編碼 
canal.instance.connectionCharset = UTF-8 
#需要訂閱binlog的表過濾正則表達式
#canal.instance.filter.regex=.*\\..* # 訂閲所有庫所有表
# 配置需要同步的表,xxx_db表示數(shù)據(jù)庫名,xxx_01等表示具體的表
canal.instance.filter.regex=xxx_db.xxx_01,xxx_db.xxx_02,xxx_db.xxx_03

?不配置這幾個,canal會使用`show master status`命令獲取最新的提交位置(如果想讀取binlog歷史,可以通過show binary logs獲取到你需要同步的起始文件,并查看起始位置的position已經(jīng)timestamp。除了這樣讀取歷史,還可以執(zhí)行canal提供的etl同步表歷史數(shù)據(jù),這個在下邊有說):

canal.instance.master.journal.name=
canal.instance.master.position=
canal.instance.master.timestamp=
canal.instance.master.gtid=
  • 啟動: bin目錄下 ./startup.sh
  • 查看日志:/logs/canal/canal.log
  • 查看實例日志/logs/example/example.log(example可以是默認的,可以自己改名)
  • 可能的問題: caching_sha2_password Auth failed

原因: ? 使用mysql版本為8.0,而創(chuàng)建用戶時默認的密碼加密方式為caching_sha2_password,所以修改為 mysql_native_password

ALTER USER 'canal'@'%' IDENTIFIED WITH mysql_native_password BY '密碼'; #更新一下用戶密碼
FLUSH PRIVILEGES; #刷新權(quán)限

五、安裝canal客戶端(canal-adapter-1.1.5)

5.1 修改配置/conf/application .yml ,按如下配置即可,主要是修改canal-server配置、數(shù)據(jù)源配置和客戶端適配器配置:
server:
  port: 9401
spring:
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
    default-property-inclusion: non_null
canal.conf:
  mode: tcp # 客戶端的模式,可選tcp kafka rocketMQ
#  flatMessage: true # 扁平message開關(guān), 是否以json字符串形式投遞數(shù)據(jù), 僅在kafka/rocketMQ模式下有效
#  zookeeperHosts:    # 對應(yīng)集群模式下的zk地址
  syncBatchSize: 1000 # 每次同步的批數(shù)量
  retries: 0 # 重試次數(shù), -1為無限重試
  timeout: 120000 # 同步超時時間, 單位毫秒
  accessKey:
  secretKey:
  consumerProperties:
    # canal tcp consumer
    canal.tcp.server.host: xxx.xxx.xxx.aaa:11111 #設(shè)置canal-server的地址
    canal.tcp.zookeeper.hosts:
    canal.tcp.batch.size: 500
    canal.tcp.username:
    canal.tcp.password:

  srcDataSources: # 源數(shù)據(jù)庫配置
    defaultDS:
      url: jdbc:mysql://xxx.xxx.xxx.bbb:3306/xxx_db?useUnicode=true
      username: canal
      password: canal
      maxActive: 10 #額外增加這一行,默認的連接數(shù)只有3,會導致全量同步出現(xiàn)異常,導致全量同步數(shù)據(jù)缺失,最好改大一點
  canalAdapters: # 適配器列表
  - instance: example # canal實例名或者MQ topic名
    groups: # 分組列表
    - groupId: g1 # 分組id, 如果是MQ模式將用到該值
      outerAdapters:
      - name: logger # 日志打印適配器
      # 配置目標數(shù)據(jù)源
        #key: esKey
      - 
      	name: es7 # ES同步適配器
      	key: eskey
        hosts: http://xxx.xxx.xxx.xxx1:9201,http://xxx.xxx.xxx.xxx2:9202 # ES連接地址,逗號分隔。
        properties:
          mode: rest # 模式可選transport(9300) 或者 rest(9200)
          security.auth: elastic:xxxxxx #  only used for rest mode
          cluster.name: cluster-es # ES集群名稱
5.2 添加配置文件canal-adapter/conf/es7/canal_xxx_01_index.yml,用于配置MySQL中的表與Elasticsearch中索引的映射關(guān)系

注意:如果這里寫了映射關(guān)系,但是索引里的mapping沒有寫,數(shù)據(jù)無法同步

dataSourceKey: defaultDS # 源數(shù)據(jù)源的key, 對應(yīng)上面配置的srcDataSources中的值
outerAdapterKey: eskey # 與上述application.yml中配置的outerAdapters.key一致
destination: example  #  默認為example,與application.yml中配置的instance保持一致
groupId: g1 # 對應(yīng)MQ模式下的groupId, 只會同步對應(yīng)groupId的數(shù)據(jù)
esMapping:
  _index: canal_xxx_01_index # es 的索引名稱
  _type: _doc
  _id: id  # es 的_id, 如果不配置該項必須配置下面的pk項_id則會由es自動分配
  sql: "SELECT
        	p.id AS id,
        	p.title,
        	p.sub_title,
        	p.price,
        	p.pic
        FROM
        	xxx_01 p"        # sql映射
  etlCondition: "where a.c_time>={}"   #etl的條件參數(shù)
  commitBatch: 3000   # 提交批大小
5.3?客戶端啟動druid依賴沖突解決
1、https://github.com/alibaba/canal/tree/canal-1.1.5
到github下載源碼。解壓修改client-adapter/escore/pom.xml:
<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <!--add by whx 20220112-->
            <scope>provided</scope>
 </dependency>

2、編譯,將client-adapter/es7x/target/client-adapter.es7x-1.1.5-jar-with-dependencies.jar上傳到服務(wù)器,替換adataper/plugin下的同名jar文件。
3、給文件賦值權(quán)限:chmod 777 /data/es-cluster/canal-adapter-1.1.5/plugin/client-adapter.es7x-1.1.5-jar-with-dependencies.jar 
4、重啟客戶端。
5.4 啟動
sh bin/startup.sh
5.5?查看日志
tail -f logs/adapter/adapter.log

六、?canal-admin安裝(可以選擇性安裝)

6.1?創(chuàng)建canal-admin需要使用的數(shù)據(jù)庫canal_manager,創(chuàng)建SQL腳本為/mydata/canal-admin/conf/canal_manager.sql,會創(chuàng)建如下表;

es增量同步,elasticsearch,大數(shù)據(jù),搜索引擎,canal

6.2?修改配置文件conf/application.yml,按如下配置即可,主要是修改數(shù)據(jù)源配置和canal-admin的管理賬號配置,注意需要用一個有讀寫權(quán)限的數(shù)據(jù)庫賬號,比如管理賬號root:root;
server:
  port: 9402
spring:
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8

spring.datasource:
  address: 127.0.0.1:3306
  database: canal_manager
  username: root
  password: root
  driver-class-name: com.mysql.jdbc.Driver
  url: jdbc:mysql://${spring.datasource.address}/${spring.datasource.database}?useUnicode=true&characterEncoding=UTF-8&useSSL=false
  hikari:
    maximum-pool-size: 30
    minimum-idle: 1

canal:
  adminUser: admin
  adminPasswd: admin
6.3?接下來對之前搭建的canal-serverconf/canal_local.properties文件進行配置,主要是修改canal-admin的配置,修改完成后使用sh bin/startup.sh local重啟canal-server
# register ip
canal.register.ip =

# canal admin config
canal.admin.manager = 127.0.0.1:9401
canal.admin.port = 11110
canal.admin.user = admin
canal.admin.passwd = admin
# admin auto register
canal.admin.register.auto = true
canal.admin.register.cluster = 

七、 全量同步

7.1 方法一

查看mysql中的binlog文件

show binary logs;

es增量同步,elasticsearch,大數(shù)據(jù),搜索引擎,canal在conf/example/instance.properties中修改

# 全量同步 
# 第一個binlog文件
canal.instance.master.journal.name=mysql-bin.000001
canal.instance.master.position=0
#2019-01-01 00:00:00 上一次更新的時間 時間戳形式
canal.instance.master.timestamp=1546272000000

如果之前同步過,想要重新做全量同步,那么需要刪除conf/example/meta.dat文件,這個文件會記錄上次同步的時間和binlog位置

rm -rf ./conf/example/meta.dat
7.2 全量同步方法二(推薦)
查詢所有訂閱同步的canal instance或MQ topic
## 訪問canal-adapter,elastic 是es管理員賬號,回車,輸入密碼即可看到:
curl -u elastic http://xxx.xxx.xxx.xxx:9401/destinations
數(shù)據(jù)同步開關(guān)狀態(tài)
curl -u elastic http://xxx.xxx.xxx.xxx:9401/syncSwitch/example
手動ETL
## 開始請求接口同步,es7為adapter實例配置的name,eskey為adapter配置的key,canal_xxx_01_index.yml為es7文件下,需要同步的文件。回車輸入elastic 的密碼等待同步即可:
curl -u elastic http://10.252.194.1:9401/etl/es7/eskey/canal_xxx_01_index.yml -X POST

不刪除索引,直接刪除索引下的所有數(shù)據(jù):文章來源地址http://www.zghlxwxcb.cn/news/detail-821685.html

## 打開kibana控制臺,輸入這個查詢
POST -u username xxx.xxx.xxx.xxx:9201/索引名/_delete_by_query
 
請求體:
{
  "query": {
    "match_all": {}
  }
}
 
注釋:
其中 my_index是索引名稱

到了這里,關(guān)于elasticsearch+canal增量、全量同步的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包