当前位置:网站首页>Tidb二进制集群搭建

Tidb二进制集群搭建

2022-08-11 05:59:00 JACK-JIE

机器准备

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

关闭防火墙及selinux

[[email protected] software]# systemctl stop firewalld && systemctl disable firewalld
[[email protected] software]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

安装用到的工具

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

安装包准备

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

解压软件包到指定目录

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

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

[[email protected] data]# useradd tidb
[[email protected] data]# chown -R tidb.tidb /data/tidb/

创建所需目录

[[email protected] tidb]# su tidb
[[email protected] tidb]$ mkdir /data/tidb/{
    data,logs} -p
[[email protected] tidb]$ mkdir /data/tidb/data/{
    pd,tikv} -p

部署pd-server

  1. tidb-1
[[email protected] 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
[[email protected] 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
[[email protected] 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. 验证
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] 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. 验证
[[email protected] 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
[[email protected] 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
[[email protected] 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
[[email protected] 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. 验证
[[email protected] 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

在这里插入图片描述

链接测试

[[email protected] ~]# 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)
原网站

版权声明
本文为[JACK-JIE]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_34158880/article/details/126265236