码迷,mamicode.com
首页 > 数据库 > 详细

Tidb 集群配置

时间:2016-11-17 21:31:23      阅读:457      评论:0      收藏:0      [点我收藏+]

标签:配置文件   启动命令   守护 tidb   


架构图:

技术分享

准备前的工作:

A、同步系统时间

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

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

C、不同版本需要的包glibc

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

E、系统版本为CENTOS6

F、包下载

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

http://down.51cto.com/data/2258987  ##CENTOS7

http://down.51cto.com/data/2259295   ##CENTOS6

http://down.51cto.com/data/2259848   ##pd tikv配置文件


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

#ln –s ……..

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

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" #PDIP

#/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统计

http://192.168.15.57:10080/debug/pprof

技术分享技术分享

http://192.168.15.57:10080/metrics

技术分享

查看tidb状态信息:http://192.168.15.57:10080/status

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

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

http://192.168.15.57:2379/pd/api/v1/stores

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

技术分享

 

首次登录在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;


本文出自 “DBSpace” 博客,请务必保留此出处http://dbspace.blog.51cto.com/6873717/1873839

Tidb 集群配置

标签:配置文件   启动命令   守护 tidb   

原文地址:http://dbspace.blog.51cto.com/6873717/1873839

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!