Tidb集群加mysql_Tidb 集群配置

架构图:

5dde451f9064adee9107a3b236639e48.png

准备前的工作:

A、同步系统时间

B、是否把刷屏日志写到一个文件里,可在启动命令后面追加到一个文件

/tmp/sh-error1.log 2>&1 &

C、不同版本需要的包glibc

D、启动服务开启守护进程要加nohup,但实际没效果

E、系统版本为CENTOS6

F、包下载

G、IPTABLES 设置,需要开通集群使用的端口或者直接关闭

1、下载包,解压后把命令存放在/usr/bin/目录下

#ln –s ……..

2、修改57上pd配置文件,并启动:##默认参数不展示

name = "tidb_pd"

data-dir= "/home/tidb_pd"

cluster-id=1921681557 ##是否可以写在这里

client-urls= "http://192.168.15.57:2379"

advertise-client-urls= ""

peer-urls= "http://192.168.15.57:2380"

advertise-peer-urls="http://192.168.15.57:2380"

initial-cluster= "tidb_pd=http://192.168.15.57:2380"

initial-cluster-state= "new"

lease = 1

log-level= "error"

tso-save-interval= "3s"

max-peer-count= 3

[balance]

min-capacity-used-ratio= 0.1

max-capacity-used-ratio= 0.9

address =""

说明配置文件生效

[root@nod2 conf]# ll/home/tidb_pd/member/

总用量 8

drwx------2 root root 4096 11月 17 10:20 snap

drwx------2 root root 4096 11月 17 10:20 wal

#/usr/local/tidb/bin/pd-server–config=/usr/local/tidb/conf/pd.toml  &

###

当前窗口关闭后,服务也跟着关闭,pd开启守护无效

检查是否启动OK:

root@nod2 conf]# netstat -nletp |grep pd-server

tcp 0  0192.168.15.57:2379    0.0.0.0:* ……

tcp 0  0192.168.15.57:2380   0.0.0.0:*  ……….

3、修改三个节点的tikv配置文件并 并启动  #####默认参数不展示

addr ="192.168.15.13:20160" #写各个节点IP

advertise-addr= ""

store = "/home/tikv13"

log-level = "debug"

job = "tikv_13"

endpoints ="192.168.15.57:2379"#写PD的IP

#/usr/local/tidb/bin/tikv-server--config=/usr/local/tidb/conf/tikv.toml &

此方式启动没办法做到后台后台守护,需要在启动前加nohup

#nohup /usr/local/tidb/bin/tikv-server--config=/usr/local/tidb/conf/tikv.toml>>/tmp/aa.tx 2>&1  &

直接这样启动 当前会话窗口不停的刷日志。

.rs:836 - DEBUG - [region 2] 7 send raft msgMsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,508 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:04,508 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,508 peer_storage.rs:444 - DEBUG - [region2] 7 append 1 entries

2016-11-17 10:45:04,508 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,509 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:04,509 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,509 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,509 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuidUuid("7d9aeeca-950e-4ccd-8096-948ec80356bd") at log index 324

2016-11-17 10:45:04,510 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:04,510 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,510 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,511 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuidUuid("ca947ae9-675e-469f-8fa6-05ebdb48660f") at log index 325

2016-11-17 10:45:04,512 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:04,512 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,512 peer_storage.rs:444 - DEBUG - [region2] 7 append 1 entries

2016-11-17 10:45:04,512 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,513 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:04,513 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,513 peer_storage.rs:444 - DEBUG - [region2] 7 append 1 entries

2016-11-17 10:45:04,513 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,513 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:04,513 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,513 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,513 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuidUuid("685e2718-cbf9-4618-828d-7a6a89f769c8") at log index 326

2016-11-17 10:45:04,514 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:04,514 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,514 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:04,514 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuidUuid("a3467d45-abc4-46ab-b7f6-c5162ce51eec") at log index 327

2016-11-17 10:45:04,699 store.rs:603 - DEBUG - [region 2]handle raft message MsgHeartbeat, from 3 to 7

2016-11-17 10:45:04,699 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:04,699 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgHeartbeatResponse[size: 10] from 7 to 3

2016-11-17 10:45:06,507 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,507 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,507 peer_storage.rs:444 - DEBUG - [region2] 7 append 1 entries

2016-11-17 10:45:06,508 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,508 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,508 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,508 peer_storage.rs:444 - DEBUG - [region2] 7 append 1 entries

2016-11-17 10:45:06,508 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,509 store.rs:603 - DEBUG - [region 2] handleraft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,509 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,509 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,509 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuidUuid("5edfc7e5-e449-42dc-a4a8-7ff660172792") at log index 328

2016-11-17 10:45:06,510 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,510 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,510 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,510 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuid Uuid("4e5d2470-0671-443f-a974-da4e9a1abbed")at log index 329

2016-11-17 10:45:06,512 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,512 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,512 peer_storage.rs:444 - DEBUG - [region2] 7 append 1 entries

2016-11-17 10:45:06,512 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,513 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,513 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,513 peer_storage.rs:444 - DEBUG - [region2] 7 append 1 entries

2016-11-17 10:45:06,513 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,513 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,513 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,513 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,514 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuidUuid("f2cbe0a6-ec1a-4c51-97dd-fdf473843423") at log index 330

2016-11-17 10:45:06,514 store.rs:603 - DEBUG - [region 2]handle raft message MsgAppend, from 3 to 7

2016-11-17 10:45:06,514 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-17 10:45:06,514 peer.rs:836 - DEBUG - [region 2] 7send raft msg MsgAppendResponse[size: 11] from 7 to 3

2016-11-17 10:45:06,515 peer.rs:1012 - DEBUG - [region 2] 7applied command with uuidUuid("6f78cf76-9db9-4eab-8368-c9805f2f64a3") at log index 331

2016-11-17 10:45:06,699 store.rs:603 - DEBUG - [region 2]handle raft message MsgHeartbeat, from 3 to 7

2016-11-17 10:45:06,699 peer.rs:499 - DEBUG - [region 2] 7handle raft ready

2016-11-1710:45:06,699 peer.rs:836 - DEBUG - [region 2] 7 send raft msgMsgHeartbeatResponse[size: 10] from 7 to 3

4、启动tidb ##

#nohup /usr/local/tidb/bin/tidb-server--store=tikv --path="192.168.15.57:2379" &

当前窗口关闭后,服务也跟着关闭,tidb开启守护无效

##--store=tikv为分布式是的引擎

Tidb这样也会不停的刷日志

2016/11/17 10:47:48 session.go:590:[info] [0] new txn:387802953988964358

[root@nod2 conf]# netstat-nltp |grep tidb

tcp        0     0 :::10080                   :::*                       LISTEN

tcp        0     0 :::4000                    :::*                        LISTEN

4000:为服务监听端口

10080:服务状态监听端口,此端口展示

###基础操作tidb

TiDB内部数据用的,包括prometheus统计

spacer.gifd57d100fe8fe4dd5013a8a13df2b96fb.png

03aa80598b134f740da9f3cc9c39bb84.png

{"connections":1,"version":"5.7.1-TiDB-1.0","git_hash":"01dde4433a0e5aabb183b3f6d00bd2f43107421a"}

查看集群状态,集群状态通过查看pd服务信息既可看到tikv信息

或者在本地查看 直接加curl 加地址

ad4efbf96cfbb41cd454571c4cf21c3d.png

首次登录在tidb-server端:mysql –h192.168.15.57 –P4000 -uroot

1、给添加连接用户,和MySQL点区别,不能通过直接grant直接加

mysql> createuser 'dlan'@'%' identified by 'root123'

-> ;

Query OK, 1 rowaffected (0.02 sec)

mysql> grant allprivileges on *.* to 'dlan'@'%';

Query OK, 1 rowaffected (0.02 sec)

mysql> exit

Bye

[root@nod2 ~]# mysql-h 192.168.15.57 -P4000 -udlan -p

Enter password:

mysql> create database tidb;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值