Tidb二进制集群搭建

机器准备

IP主机名用户组件
192.168.10.61tidb-1tidbpd,tikv,tidb
192.168.10.62tidb-2tidbpd,tikv,tidb
192.168.10.63tidb-3tidbpd,tikv,tidb

关闭防火墙及selinux

[root@tidb-1 software]# systemctl stop firewalld && systemctl disable firewalld
[root@tidb-1 software]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

安装用到的工具

yum -y install wget lrzsz curl vim net-tools screen

安装包准备

  1. 下载安装包
[root@tidb-1 software]# wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
[root@tidb-1 software]# wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256
  1. 检查安装包完整性,返回 ok 则正确
[root@tidb-1 software]# sha256sum -c tidb-latest-linux-amd64.sha256
tidb-latest-linux-amd64.tar.gz: 确定

解压软件包到指定目录

[root@tidb-1 software]# tar -zxf tidb-latest-linux-amd64.tar.gz -C /data/
[root@tidb-1 software]# cd /data/
[root@tidb-1 data]# mv tidb-v5.0.1-linux-amd64/ tidb

添加tidb用户并配置属主属组

[root@tidb-1 data]# useradd tidb
[root@tidb-1 data]# chown -R tidb.tidb /data/tidb/

创建所需目录

[root@tidb-1 tidb]# su tidb
[tidb@tidb-1 tidb]$ mkdir /data/tidb/{data,logs} -p
[tidb@tidb-1 tidb]$ mkdir /data/tidb/data/{pd,tikv} -p

部署pd-server

  1. tidb-1
[tidb@tidb-1 tidb]$ ./bin/pd-server --name=pd1 --data-dir=/data/tidb/data/pd --client-urls="http://192.168.10.61:2379" --peer-urls="http://192.168.10.61:2380" --initial-cluster="pd1=http://192.168.10.61:2380,pd2=http://192.168.10.62:2380,pd3=http://192.168.10.63:2380" -L "info" --log-file=/data/tidb/logs/pd.log &
  1. tidb-2
[tidb@tidb-2 tidb]$ ./bin/pd-server --name=pd2 --data-dir=/data/tidb/data/pd --client-urls="http://192.168.10.62:2379" --peer-urls="http://192.168.10.62:2380" --initial-cluster="pd1=http://192.168.10.61:2380,pd2=http://192.168.10.62:2380,pd3=http://192.168.10.63:2380" -L "info" --log-file=/data/tidb/logs/pd.log &
  1. tidb-3
[tidb@tidb-3 tidb]$ ./bin/pd-server --name=pd3 --data-dir=/data/tidb/data/pd --client-urls="http://192.168.10.63:2379" --peer-urls="http://192.168.10.63:2380" --initial-cluster="pd1=http://192.168.10.61:2380,pd2=http://192.168.10.62:2380,pd3=http://192.168.10.63:2380" -L "info" --log-file=/data/tidb/logs/pd.log &
  1. 验证
[tidb@tidb-1 tidb]$ netstat -lntp | grep pd
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 192.168.10.61:2379      0.0.0.0:*               LISTEN      17187/./bin/pd-serv
tcp        0      0 192.168.10.61:2380      0.0.0.0:*               LISTEN      17187/./bin/pd-serv

在这里插入图片描述

部署tikv

  1. tidb-1
[tidb@tidb-1 tidb]$ ./bin/tikv-server --pd="192.168.10.61:2379,192.168.10.62:2379,192.168.10.63:2379" --addr="192.168.10.61:20160" --data-dir=/data/tidb/data/tikv --log-file=/data/tidb/logs/tikv.log &
  1. tidb-2
[tidb@tidb-3 tidb]$ ./bin/tikv-server --pd="192.168.10.61:2379,192.168.10.62:2379,192.168.10.63:2379" --addr="192.168.10.62:20160" --data-dir=/data/tidb/data/tikv --log-file=/data/tidb/logs/tikv.log &
  1. tidb-3
[tidb@tidb-3 tidb]$ ./bin/tikv-server --pd="192.168.10.61:2379,192.168.10.62:2379,192.168.10.63:2379" --addr="192.168.10.63:20160" --data-dir=/data/tidb/data/tikv --log-file=/data/tidb/logs/tikv.log &
  1. 验证
[tidb@tidb-1 tidb]$ netstat -lntp | grep kv
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:20180         0.0.0.0:*               LISTEN      17342/./bin/tikv-se
tcp6       0      0 192.168.10.61:20160     :::*                    LISTEN      17342/./bin/tikv-se

在这里插入图片描述

部署tidb

  1. tidb-1
[tidb@tidb-1 tidb]$ ./bin/tidb-server --store=tikv --path="192.168.10.61:2379,192.168.10.62:2379,192.168.10.63:2379" --log-file=/data/tidb/logs/tidb.log &
  1. tidb-2
[tidb@tidb-2 tidb]$ ./bin/tidb-server --store=tikv --path="192.168.10.61:2379,192.168.10.62:2379,192.168.10.63:2379" --log-file=/data/tidb/logs/tidb.log &
  1. tidb-3
[tidb@tidb-3 tidb]$ ./bin/tidb-server --store=tikv --path="192.168.10.61:2379,192.168.10.62:2379,192.168.10.63:2379" --log-file=/data/tidb/logs/tidb.log &
  1. 验证
[tidb@tidb-1 tidb]$ netstat -lntp | grep db
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::10080                :::*                    LISTEN      17462/./bin/tidb-se
tcp6       0      0 :::4000                 :::*                    LISTEN      17462/./bin/tidb-se

在这里插入图片描述

链接测试

[root@localhost ~]# mysql -h 192.168.10.61 -P 4000 -uroot -D test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.25-TiDB-v5.0.1 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| METRICS_SCHEMA     |
| PERFORMANCE_SCHEMA |
| mysql              |
| test               |
+--------------------+
5 rows in set (0.00 sec)
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值