mysql冷熱分離的技術 資料歸檔,冷熱資料分離

2021-10-25 14:55:38 字數 2176 閱讀 1805

一.關於tokudb引擎

1.tokudb引擎特點

2.tokudb安裝步驟

1.yum install jemalloc -y

2.vim/etc/my.cnf #新增如下

[mysqld_safe]

malloc-lib=/usr/lib64/libjemalloc.so.1

3.echo never >/sys/kernel/mm/transparent_hugepage/enabled

echo never >/sys/kernel/mm/transparent_hugepage/defrag

4.yum install percona-server-tokudb-57.x86_64

5.啟動引擎ps-admin --enable -uroot -p

6.重啟mysql服務

service mysql restart

7.ps-admin --enable -uroot -p

8.檢視引擎

執行mysql -u root -p,登入mysql,執行show engines

3.建立測試表

1.在源資料庫建立表

create table t_purchase (

id int unsigned primary key,

purchase_price decimal (10, 2) not null,

purchase_num int unsigned not null,

purchase_sum decimal (10, 2) not null,

purchase_buyer int unsigned not null,

purchase_date timestamp not null default current_timestamp,

company_id int unsigned not null,

goods_id int unsigned not null,

key idx_company_id ( company_id ),

key idx_goods_id ( goods_id )

2.在歸檔資料庫中建立歸檔表

create table t_purchase_201807 (

id int unsigned primary key,

purchase_price decimal ( 10, 2 ) not null,

purchase_num int unsigned not null,

purchase_sum decimal ( 10, 2 ) not null,

purchase_buyer int unsigned not null,

purchase_date timestamp not null default current_timestamp,

company_id int unsigned not null,

goods_id int unsigned not null,

key idx_company_id ( company_id ),

key idx_goods_id ( goods_id )

) engine = tokudb;

4.安裝pt-archiver

yum install percona-toolkit -y

pt-archiver --version

pt-archiver --help

5.歸檔資料

pt-archiver --source h=192.168.192.135,p=3306,u=root,p=123456,d=test1,t=t_purchase

--dest h=192.168.192.129,p=3306,u=admin,p=abc_123456,d=test1,t=t_purchase_201807

--no-check-charset

--where 'purchase_date

--progress 5000 --bulk-delete --bulk-insert --limit=1000 --statistics

#執行完成後,源資料庫的冷資料就歸檔到歸檔資料庫中了

6.總結

1.使用tokudb引擎儲存歸檔資料,擁有告訴寫入特性2.使用雙機熱備方案搭建歸檔資料庫,具備高可用性3.使用pt-archiver執行資料歸檔,簡便易行

找技術資料的方法和注意事項

且在找資料的時候,帶著乙個評價的態度去找。如果不加評價的相信,按照資料說的去做,很容易就遇到與你需要的內容不相關的資料從而走偏。因而帶著評價的態度去查資料,如果看起來可行性不高,則跳過,選擇可行性高的資料。並且在找資料的時候,實時的評價資料中的方案要素,是否已經解決我的問題,如果解決則即刻開始下乙個...

WEB服務於WCF服務的技術資料

web服務的描述與參考資料 web 服務是一種新的重要的應用程式。web 服務是一段可以用 xml 發現 描述和訪問的 在這一領域有許多活動,但有三種主要的用於 web 服務的 xml 標準 wsdl web 服務描述語言 web services description language 是乙個描...

Mysql資料庫的分離和附加《轉》

一.mysql的命令列模式的設定 桌面 我的電腦 屬性 環境變數 新建 path path mysql bin 其中path為mysql的安裝路徑。二.簡單的介紹一下命令列進入mysql的方法 1.c mysql h hostname u username p 按enter鍵,等待然後輸入密碼。這裡...