TIDB distributed Database (ii)

Source: Internet
Author: User


#

# tidb:a Distributed SQL Database

# GITHUB:HTTPS://GITHUB.COM/PINGCAP/TIDB

# DOC:HTTPS://GITHUB.COM/PINGCAP/DOCS-CN

#


#架构

Name
Host IP Services
Node1 192.168.174.134
PD, TIDB
Node2 192.168.174.136 TiKV1
Node3 192.168.174.137 TiKV2
Node4 192.168.174.138 TiKV3


#软件下载 (requires operation per station)

[Email protected] ~]# wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz[[email protected] ~]# TAR-XF Tidb-latest-linux-amd64.tar.gz-c/usr/local/[[email protected] ~]# Mkdir/data/tidb/{data,log}-P


#开启服务 (Note: The boot order of the cluster cannot be wrong)

#在node1开启PD

[Email protected] ~]#/usr/local/tidb-latest-linux-amd64/bin/pd-server--name=pd1--data-dir=/data/tidb/data--clie nt-urls= "http://192.168.174.134:2379"--peer-urls= "http://192.168.174.134:2380"--initial-cluster= "pd1=http:// 192.168.174.134:2380 "--log-file=/data/tidb/log/pd.log &


Parameter explanation: HTTPS://GITHUB.COM/PINGCAP/DOCS-CN/BLOB/MASTER/OP-GUIDE/CONFIGURATION.MD#TIDB


Open tikv on Node3 node4 #在node2

[Email protected] ~]#/usr/local/tidb-latest-linux-amd64/bin/tikv-server--pd= "192.168.174.134:2379"--addr= " 192.168.174.136:20160 "--data-dir=/data/tidb/data--log-file=/data/tidb/log/tikv.log & [[email protected] ~]#/ Usr/local/tidb-latest-linux-amd64/bin/tikv-server--pd= "192.168.174.134:2379"--addr= "192.168.174.137:20160"-- Data-dir=/data/tidb/data--log-file=/data/tidb/log/tikv.log &[[email protected] ~]#/usr/local/ Tidb-latest-linux-amd64/bin/tikv-server--pd= "192.168.174.134:2379"--addr= "192.168.174.138:20160"--data-dir=/ Data/tidb/data--log-file=/data/tidb/log/tikv.log &


Parameter explanation: HTTPS://GITHUB.COM/PINGCAP/DOCS-CN/BLOB/MASTER/OP-GUIDE/CONFIGURATION.MD#TIDB



Open TIDB on #在node1

[Email protected] ~]#/usr/local/tidb-latest-linux-amd64/bin/tidb-server--store=tikv--path= "192.168.174.134:2379 "--log-file=/data/tidb/log/tidb.log &


#登陆数据库

[[email protected] ~]# yum install -y mariadb                           #安装mariadb数据库客户端 [[email protected] ~]# mysql -uroot -h 192.168.174.134  -p 4000welcome to the mariadb monitor.  commands end with  ; or \g.your mysql connection id is 2server version: 5.7.1- tidb-1.0 mysql community server  (GPL) copyright  (c)  2000, 2015, oracle,  mariadb corporation ab and others. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement. mysql [(None)]> show databases;+--------------------+| database            |+--------------------+| information_schema | |  performance_schema | |  mysql              | |  test               |+-------- ------------+4 rows in set  (0.00 sec) mysql [(none)]> select host, user from mysql.user ;+------+------+| host | user |+------+------+| %     | root |+------+------+1 row in set  (0.00 sec) MySQL  [(None)]> exitbye



#集群状态


TIDB externally exposed HTTP interface is http://host:port/status, the default port number is 10080 (can be set by the--status parameter),

You can get the status of the current TIDB Server by accessing this interface and determine if it is alive. The returned result is in Json format:

[[email protected] ~]# Curl 192.168.174.134:10080/status{"connections": 0, "version": "5.7.1-tidb-1.0", "Git_hash": " D6ec37bb4219e95babce41bd0400d04d84b1fb88 "}



PD Server

PD API Address:http://${host}:${port}/pd/api/v1/${api_name}

Where port defaults to 2379, various api_name details see

https://cdn.rawgit.com/pingcap/docs/master/op-guide/pd-api-v1.html

[[email protected] ~]# curl 192.168.174.134:2379/pd/api/v1/stores{   "Count":  3,   "Stores": [    {       "store":  {         "id": 1,          "Address":  "192.168.174.138:20160",         "state":  0,          "State_name":  "Up"       },        "status": {         "store_id" : 1,         "Capacity":  "19 GB",          "Available":  "17 GB",         " Leader_count ": 1,        " Region_count ": 1,          "Sending_snap_count": 0,         "Receiving_snap_count":  0,         "Applying_snap_count": 0,          "Is_busy": false,         "Start_ts":   "2017-05-13t03:16:51+08:00",         "Last_heartbeat_ts":  " 2017-05-13t03:23:58.709890548+08:00 ",        " uptime ": " 7m7.709890548s "      }    },    {        "Store": {         "id":  4,          "Address":  "192.168.174.137:20160",          "state": 0,         "State_name":   "Up"       },       "status": {         " store_id ": 4,        " Capacity ": " 19 GB ",          "Available":  "16 GB",          "Leader_count": 0,         "Region_count": 1,          "Sending_snap_count": 0,          "Receiving_snap_count": 0,         "Applying_snap_ Count ": 0,        " Is_busy ": false,          "Start_ts":  "2017-05-12t18:17:02+08:00",          "Last_heartbeat_ts":  "2017-05-13t03:24:00.555315502+08:00",          "Uptime":  "9h6m58.555315502s "      }    },    {        "Store": {         "id":  5,          "Address":  "192.168.174.136:20160",          "state": 0,         "State_name":   "Up"       },       "status": {          "store_id": 5,         " Capacity ": " 16 GB ",        " available ": " 13 GB ",          "Leader_count": 0,          "Region_count": 1,         "Sending_snap_count":  0,         "Receiving_snap_count": 0,         "Applying_ Snap_count ": 0,        " Is_busy ": false,          "Start_ts":  "2017-05-12t18:17:02+08:00",          "Last_heartbeat_ts":  "2017-05-13t03:23:56.955220422+08:00",          "Uptime":  "9h6m54.955220422s"       }     }  ]}[[email protected] ~]#










This article is from the "Chauncey" blog, make sure to keep this source http://cqwujiang.blog.51cto.com/10808946/1925169

TIDB distributed Database (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.