TIDB集群部署




  • 资源规划

    在有外网的环境中部署TIDB集群

    资源紧张演示环境配置给的较低,我们这里使用7台虚拟机部署

    节点名 IP地址 CPU 内存 磁盘类型
    PD1 10.0.0.201 1 4G SSD
    PD2 10.0.0.202 1 4G SSD
    PD3 10.0.0.203 1 4G SSD
    KV1 10.0.0.204 1 4G SSD
    KV2 10.0.0.205 1 4G SSD
    KV3 10.0.0.206 1 4G SSD
    TIDB 10.0.0.207 1 2G SSD
    monitoring 10.0.0.201 1 4G SSD
    grafana 10.0.0.201 1 4G SSD
    alertmanager 10.0.0.201 1 4G SSD

    1、连接中控机安装tiup工具

    使用tiup工具下载命令安装

     
    dennis@wutongdeMacBook-Pro ~ % ssh root@10.0.0.207

    root@10.0.0.207's password:

    Last login: Sat Jun 26 11:36:38 2021 from wutongdembp

    [root@tidb ~]# pwd

    /root

    [root@tidb ~]# curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

     

     

    2、声明环境变量并验证tiup工具

     
    [root@tidb ~]# . .bash_profile

    [root@tidb ~]# which tiup

    /root/.tiup/bin/tiup

     

    3、安装tiup cluster工具并验证

     
    [root@tidb ~]# tiup cluster

    The component `cluster` version  is not installed; downloading from repository.

    download https://tiup-mirrors.pingcap.com/cluster-v1.5.2-linux-amd64.tar.gz 8.40 MiB / 8.40 MiB 100.00% 13.28 MiB/s

    Starting component `cluster`: /root/.tiup/components/cluster/v1.5.2/tiup-cluster

    Deploy a TiDB cluster for production

     

    [root@tidb ~]# tiup --binary cluster

    /root/.tiup/components/cluster/v1.5.2/tiup-cluster

     

    4、初始化集群拓扑文件

     
    [root@tidb ~]# tiup cluster template > topology.yaml

    Starting component `cluster`: /root/.tiup/components/cluster/v1.5.2/tiup-cluster template

    [root@tidb ~]# pwd

    /root

    [root@tidb ~]# ls

    anaconda-ks.cfg  topology.yaml

    5、修改集群文件

     
    [root@tidb ~]# vi topology.yaml

     

    找到对应的节点信息修改IP地址

    修改pd_server

    修改tidb_server我们这里只有一台所以其他两个注释掉

    修改tikv-server,没有使用ti flash所以注释掉即可

    修改监控服务这里我们不是到一个PD节点

    6、检查集训是否符合安装要求

     
    [root@tidb ~]# tiup cluster check ./topology.yaml --apply --user root -p

    Starting component `cluster`: /root/.tiup/components/cluster/v1.5.2/tiup-cluster check ./topology.yaml --apply --user root -p

    Input SSH password:

     

     

    红色表示不符合tidb部署要求,首次执行检查会自动修复一些问题,再次运行检查将没能自动修复的问题手动进行解决,swap需要关闭

    7、进行集群部署

    所有 fail解决后开始部署集群,注意Sandata-test是我起的集群名称根据实际需求填写

     
    [root@tidb ~]# tiup cluster deploy sandata-test v5.0.2 ./topology.yaml --user root -p

     

     

    确认集群信息无误输入y开始安装等待自动安装完毕

    8、检查集群并启动

     
    [root@tidb ~]# tiup cluster list

     

     

    [root@tidb ~]# tiup cluster display sandata-test

     

     

    启动集群

     
    [root@tidb ~]# tiup cluster start sandata-test

     

     

    检查启动后状态

     
    [root@tidb ~]# tiup cluster display sandata-test

     

     

    安装完毕现在可以连接并使用数据库了

    <a href="http://www.dbstyle.net/greenplum%e4%bd%bf%e7%94%a8gpcopy%e6%95%b0%e6%8d%ae%e4%bc%a0%e8%be%93%e6%96%b9%e6%a1%88.html/attachment/254595332384850280" rel="attachment wp-att-2650"><img class="aligncenter size-large wp-image-2650" src="http://www.dbstyle.net/wordpress/wp-content/uploads/2021/04/254595332384850280-1024x51.jpg" alt="" width="660" height="33" /></a>
    [root@tidb ~]# mysql -h 10.0.0.207 -P4000 -uroot -p

     

     

    参考文档tidb官方手册

    https://docs.pingcap.com/zh/tidb/stable/overview

     
     
     
     
     
     
     
     
     
     
     

    Speak Your Mind

    *

    京ICP备14059771号-2