婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > 如何使用Maxwell實(shí)時(shí)同步mysql數(shù)據(jù)

如何使用Maxwell實(shí)時(shí)同步mysql數(shù)據(jù)

熱門(mén)標(biāo)簽:大豐地圖標(biāo)注app 400電話(huà)變更申請(qǐng) 催天下外呼系統(tǒng) 武漢電銷(xiāo)機(jī)器人電話(huà) 北京金倫外呼系統(tǒng) 南太平洋地圖標(biāo)注 400電話(huà)辦理服務(wù)價(jià)格最實(shí)惠 html地圖標(biāo)注并導(dǎo)航 呂梁外呼系統(tǒng)

Maxwell簡(jiǎn)介

maxwell是由java編寫(xiě)的守護(hù)進(jìn)程,可以實(shí)時(shí)讀取mysql binlog并將行更新以JSON格式寫(xiě)入kafka、rabbitMq、redis等中,  這樣有了mysql增量數(shù)據(jù)流,使用場(chǎng)景就很多了,比如:實(shí)時(shí)同步數(shù)據(jù)到緩存,同步數(shù)據(jù)到ElasticSearch,數(shù)據(jù)遷移等等。

maxwell官網(wǎng):http://maxwells-daemon.io
 maxwell源代碼:https://github.com/zendesk/maxwell

Maxwell的配置與使用

maxwell 依賴(lài)java sdk,所以需要先配置JDK環(huán)境。

1.下載Maxwell安裝包

root@xxx maxwell]# pwd
/usr/local/maxwell
[root@xxx maxwell]# wget https://github.com/zendesk/maxwell/releases/download/v1.19.5/maxwell-1.19.5.tar.gz
[root@xxx maxwell]# tar zxvf maxwell-1.19.5.tar.gz 
[root@xxx maxwell]# cd maxwell-1.19.5

2.配置mysql,打開(kāi)mysql binlog日志

[root@xxx mysql]# vi /usr/local/mysql/my.cnf 

[mysqld]
log-bin=mysql-bin #添加這一行就
binlog-format=ROW #選擇row模式
server_id=1 #隨機(jī)指定一個(gè)不能和其他集群中機(jī)器重名的字符串,如果只有一臺(tái)機(jī)器,那就可以隨便指定了

重啟mysql服務(wù),登陸mysql,查看binlog日志模式

mysql> show variables like '%log_bin%'
+---------------------------------+-------------------------------+
| Variable_name                   | Value                         |
+---------------------------------+-------------------------------+
| log_bin                         | ON                            |
| log_bin_basename                | /data/mysqldb/mysql-bin       |
| log_bin_index                   | /data/mysqldb/mysql-bin.index |
| log_bin_trust_function_creators | OFF                           |
| log_bin_use_v1_row_events       | OFF                           |
| sql_log_bin                     | ON                            |
+---------------------------------+-------------------------------+
6 rows in set (0.11 sec)

Maxwell需要在schema_database選項(xiàng)指定的數(shù)據(jù)庫(kù)中存儲(chǔ)狀態(tài)的權(quán)限(默認(rèn)庫(kù)名稱(chēng)為maxwell),所以需要提前給權(quán)限:

#創(chuàng)建一個(gè)有同步數(shù)據(jù)的用戶(hù)yhrepl
mysql> create user 'yhrepl'@'*' identified by 'scgaopan'; 
Query OK, 0 rows affected (0.10 sec)

#此用戶(hù)yhrepl要有對(duì)需要同步的數(shù)據(jù)庫(kù)表有操作權(quán)限
mysql> grant all privileges on test.* to 'yhrepl'@'%' identified by 'scgaopan'; 
Query OK, 0 rows affected (0.13 sec)

#給yhrepl有同步數(shù)據(jù)的權(quán)限
mysql> grant select,replication client,replication slave on *.* to 'yhrepl'@'%' identified by 'scgaopan';
Query OK, 0 rows affected (0.10 sec)
# Maxwell需要在schema_database選項(xiàng)指定的數(shù)據(jù)庫(kù)中存儲(chǔ)狀態(tài)的權(quán)限(默認(rèn)庫(kù)名稱(chēng)為maxwell)
mysql> grant all privileges on maxwell.* to 'yhrepl'@'%' identified by 'scgaopan';
Query OK, 0 rows affected (0.09 sec)

3.啟動(dòng)Maxwell,主要介紹數(shù)據(jù)寫(xiě)入rabbitmq的實(shí)戰(zhàn):

[root@xxx maxwell-1.19.5]# vi /usr/local/maxwell/maxwell-1.19.5/config.properties
#日志級(jí)別
log_level=DEBUG

producer=rabbitmq
daemon=true

#監(jiān)控的數(shù)據(jù)庫(kù), mysql用戶(hù)必須擁有讀取binlog權(quán)限和新建庫(kù)表的權(quán)限
host=47.105.110.xxx
user=yhrepl
password=scgaopan

output_nulls=true
jdbc_options=autoReconnet=true

#監(jiān)控?cái)?shù)據(jù)庫(kù)中的哪些表
filter=exclude: *.*,include: test.AA

#replica_server_id 和 client_id 唯一標(biāo)示,用于集群部署
replica_server_id=64
client_id=test-id

#metrics_type=http
#metrics_slf4j_interval=60
#http_port=8111
#http_diagnostic=true # default false

#rabbitmq
rabbitmq_host=47.105.110.xxx
rabbitmq_port=5672
rabbitmq_user=guest
rabbitmq_pass=guest
rabbitmq_virtual_host=/
rabbitmq_exchange=maxwell
rabbitmq_exchange_type=topic
rabbitmq_exchange_durable=false
rabbitmq_exchange_autodelete=false
rabbitmq_routing_key_template=%db%.%table%
rabbitmq_message_persistent=false
rabbitmq_declare_exchange=true

啟動(dòng)Maxwell:

[root@xxx maxwell-1.19.5]# ./bin/maxwell
#可以后臺(tái)啟動(dòng)
[root@xxx maxwell-1.19.5]# nohub ./bin/maxwell 

啟動(dòng)成功,此時(shí)會(huì)自動(dòng)生成maxwell庫(kù),該庫(kù)記錄了maxwell同步的狀態(tài),最后一次同步的id等等信息,在主庫(kù)失敗或同步異常后,只要maxwell庫(kù)存在,下次同步會(huì)根據(jù)最后一次同步的id。如果沒(méi)有生成maxwell庫(kù)或報(bào)錯(cuò),可能config.properties中配置的mysql用戶(hù)權(quán)限不夠

rabbitmq的操作

rabbitmq的操作,啟動(dòng)maxwell后就有一個(gè)maxwell的exchage生成

但對(duì)應(yīng)的queue和exchange和queue的綁定需要用戶(hù)自己去實(shí)現(xiàn)

新建一個(gè)maxwell-test的queue:

把queue與exchange進(jìn)行綁定:

注意,這里的Routing key 是區(qū)分大小寫(xiě)的

在數(shù)據(jù)庫(kù)中修改一條記錄,可以看到maxwell-test隊(duì)列里面有一第記錄了。

全量同步

使用maxwell-bootstrap命令

./bin/maxwell-bootstrap --database xhd --table xhd-sso --host 127.0.0.1 --user xiehd --password xiehd2018 --client_id maxwell_dev

同步xhd.xhd-sso表的所有數(shù)據(jù),并指定client_id示maxwell_dev的maxwell執(zhí)行同步

上一個(gè)命令先開(kāi)著,然后再啟動(dòng)client_id=maxwell_dev的maxwell

./bin/maxwell --client_id maxwell_dev

等待執(zhí)行完成即可

以上就是如何使用Maxwell實(shí)時(shí)同步mysql數(shù)據(jù)的詳細(xì)內(nèi)容,更多關(guān)于用Maxwell同步mysql數(shù)據(jù)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

您可能感興趣的文章:
  • python實(shí)現(xiàn)MySQL指定表增量同步數(shù)據(jù)到clickhouse的腳本
  • MySQL數(shù)據(jù)庫(kù)主從同步實(shí)戰(zhàn)過(guò)程詳解
  • scrapy數(shù)據(jù)存儲(chǔ)在mysql數(shù)據(jù)庫(kù)的兩種方式(同步和異步)
  • Mysql主從數(shù)據(jù)庫(kù)(Master/Slave)同步配置與常見(jiàn)錯(cuò)誤
  • ktl工具實(shí)現(xiàn)mysql向mysql同步數(shù)據(jù)方法
  • 用python簡(jiǎn)單實(shí)現(xiàn)mysql數(shù)據(jù)同步到ElasticSearch的教程
  • MySQL數(shù)據(jù)庫(kù)的主從同步配置與讀寫(xiě)分離
  • node.js將MongoDB數(shù)據(jù)同步到MySQL的步驟
  • Linux下MySQL數(shù)據(jù)庫(kù)的主從同步復(fù)制配置
  • PHP使用SWOOLE擴(kuò)展實(shí)現(xiàn)定時(shí)同步 MySQL 數(shù)據(jù)

標(biāo)簽:徐州 自貢 麗水 迪慶 無(wú)錫 西寧 龍巖 南充

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《如何使用Maxwell實(shí)時(shí)同步mysql數(shù)據(jù)》,本文關(guān)鍵詞  如何,使用,Maxwell,實(shí)時(shí),同步,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《如何使用Maxwell實(shí)時(shí)同步mysql數(shù)據(jù)》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于如何使用Maxwell實(shí)時(shí)同步mysql數(shù)據(jù)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 五河县| 靖边县| 新密市| 类乌齐县| 苏尼特左旗| 伽师县| 大冶市| 庐江县| 齐河县| 利川市| 闽侯县| 武胜县| 山东省| 庆云县| 永仁县| 云浮市| 宁夏| 疏附县| 灌阳县| 徐水县| 漠河县| 哈巴河县| 平遥县| 洮南市| 喀喇沁旗| 凤台县| 报价| 鄂托克前旗| 栖霞市| 陵川县| 革吉县| 鹿邑县| 南华县| 梁河县| 钟祥市| 大方县| 通道| 秀山| 阜宁县| 扬州市| 馆陶县|