1. 后端 >>数据库

TIDB实战,各种操作指令集合

TIDB启动:
./bin/pd-server --data-dir=/datadisk/data/pd --log-file=/datadisk/data/logs/pd.log &
./bin/tikv-server --pd="127.0.0.1:2379" --data-dir=/datadisk/data/tikv --log-file=/datadisk/data/logs/tikv.log &
./bin/tidb-server --store=tikv --path="127.0.0.1:2379" --log-file=/datadisk/data/logs/tidb.log &
 
数据实时同步
nohup bin/dm-master --master-addr='127.0.0.1:8261' --log-file=/tmp/dm-master.log --name="master1" >> /tmp/dm-master.log 2>&1 &
nohup bin/dm-worker --worker-addr='127.0.0.1:8262' --log-file=/tmp/dm-worker.log --join='127.0.0.1:8261' --name="worker1" >> /tmp/dm-worker.log 2>&1 &
bin/dmctl --master-addr=127.0.0.1:8261 list-member
bin/dmctl --master-addr=127.0.0.1:8261 operate-source create source.yaml
bin/dmctl --master-addr=127.0.0.1:8261 operate-source show
bin/dmctl --master-addr=127.0.0.1:8261 start-task task.yaml
 
==TIDB相关操作
安装
tiup cluster deploy tidb-test v5.0.0 topology.yaml 
topology.yaml
展示
tiup cluster display tidb-test
重启
tiup cluster restart tidb-test
启动
tiup dm start tidb-test
停止
tiup dm stop tidb-test
卸载
tiup cluster destroy  tidb-test
修改配置
tiup cluster edit-config tidb-test
PD操作
tiup ctl:v4.0.13 pd -i -u http://127.0.0.1:2379
==TIDB同步(dm)相关操作
安装
tiup dm deploy dm-test v2.0.3 ./topology2.yaml
topology2.yaml
展示
tiup dm display dm-test
启动
tiup dm start dm-test
添加数据源
tiup dmctl --master-addr 172.17.12.14:8261 operate-source create source2.yaml
source.yaml
停止数据源(删除)
tiup dmctl --master-addr 172.17.12.14:8261 operate-source stop mysql-01
卸载
tiup dm destroy  dm-test
启动同步
tiup dmctl --master-addr=172.17.12.14:8261 start-task task.yaml --remove-meta
task.yaml
停止同步
tiup dmctl --master-addr=172.17.12.14:8261 stop-task test
查看DM状态
tiup dmctl --master-addr 172.17.12.16:8261 query-status
查看DM信息
tiup dmctl --master-addr=172.17.12.14:8261 list-member
tiup更新
tiup update --self && tiup update dm
查看可用的DM
tiup list dm-master
 
==tiflash相关操作
增加tiflash扩展
tiup cluster scale-out tidb-test scale-out.yaml
scale-out.yaml
新增tiflash
ALTER TABLE data_combine.prd_base SET TIFLASH REPLICA 0
删除tiflash
ALTER TABLE data_combine.prd_base SET TIFLASH REPLICA 0
查看tiflash信息
SELECT * FROM information_schema.tiflash_replica WHERE TABLE_SCHEMA = 'data_combine' and TABLE_NAME = 'prd_base';
缩容(强制卸载tiflash):
tiup cluster scale-in tidb-test --node 172.17.12.13:9000
tiup cluster prune tidb-test
 
==数据迁移相关操作
导出
./dumpling -h 10.27.34.121 -P 3306 -u root -p 'Chongdong&*()2019' --consistency none  -t 16 -F 256MB -B data_combine -T data_combine.prd_base,data_combine.prd_detail,data_combine.prd_images -o /data/my_database/
--consistency none:不锁表
-B data_combine:数据库名称
导入
 nohup ./tidb-lightning -config tidb-lightning.toml > nohup.out  2>&1 &
tidb-lightning.toml
 
==数据备份恢复相关操作
全量备份
./br backup full -s local:///home/20210811 --pd "172.17.12.13:2379" --log-file backup.log
全量恢复
 
./br restore full -s local:///home/ --pd "172.17.12.13:2379" --log-file restore.log

本文采摘于网络,不代表本站立场,转载联系作者并注明出处:http://01.pbootcms.shwlz.cn/P0088/dy/21.html

联系我们

在线咨询: 点击这里给我发消息

微信号:13391712801

工作日:9:30-18:30,节假日休息