当前位置:   article > 正文

社区声音:恭喜 TiProxy 组件 GA!

社区声音:恭喜 TiProxy 组件 GA!

作者: ShawnYan 原文来源: https://tidb.net/blog/529996b3

no-alt

网传,ACE 装国产数据库花了两周,吃瓜群众纷纷表示惊讶,

都 4202 年了,DBaaS 概念已经不热了,安装数据库怎么还跟 10 年前一样需要持久战~

...

使用 TiUP 部署 TiDB v8.0.0 集群

回看两年前发的文章, TiUP:TiDBAer 必备利器

现在更加肯定 TiUP 真乃神器也,使用 TiUP 在本地模拟部署 TiDB v8.0.0 集群仅需 10 分钟。

no-alt

具体演示如下:

1. 下载并安装 TiUP

  1. [root@shawnyan ~ 11:57:40]$ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
  2.   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
  3.                                  Dload  Upload   Total   Spent    Left  Speed
  4. 100 5095k  100 5095k    0     0  5065k      0  0:00:01  0:00:01 --:--:-- 5069k
  5. Successfully set mirror to https://tiup-mirrors.pingcap.com
  6. Detected shell: bash
  7. Shell profile:  /root/.bash_profile
  8. Installed path: /root/.tiup/bin/tiup
  9. ===============================================
  10. Have a try:     tiup playground
  11. ===============================================
  12. [root@shawnyan ~ 11:57:46]$ source /root/.bash_profile

2. 调大 sshd 服务的连接数限制

由于是本地安装集群,会并发连接,调整最大会话数量到 20。

  1. vi /etc/ssh/sshd_config
  2. MaxSessions = 20

并重启 sshd 服务。

systemctl restart sshd

3. 创建集群拓扑文件

可用 tiup cluster template 命令生成拓扑模板。

[root@shawnyan ~ 11:59:00]$ vi topo.yaml

4. 部署集群

  1. [root@shawnyan ~ 12:00:40]$ tiup cluster deploy mytidb v8.0.0 ./topo.yaml --user root -p
  2. Input SSH password: 
  3. + Detect CPU Arch Name
  4. + Detect CPU OS Name
  5. Please confirm your topology:
  6. Cluster type:    tidb
  7. Cluster name:    mytidb
  8. Cluster version: v8.0.0
  9. Role        Host           Ports                            OS/Arch       Directories
  10. ----        ----           -----                            -------       -----------
  11. pd          192.168.8.161  2379/2380                        linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379
  12. tikv        192.168.8.161  20160/20180                      linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160
  13. tikv        192.168.8.161  20161/20181                      linux/x86_64  /tidb-deploy/tikv-20161,/tidb-data/tikv-20161
  14. tidb        192.168.8.161  4000/10080                       linux/x86_64  /tidb-deploy/tidb-4000
  15. tiflash     192.168.8.161  9000/8123/3930/20170/20292/8234  linux/x86_64  /tidb-deploy/tiflash-9000,/tidb-data/tiflash-9000
  16. prometheus  192.168.8.161  9090/12020                       linux/x86_64  /tidb-deploy/prometheus-9090,/tidb-data/prometheus-9090
  17. grafana     192.168.8.161  3000                             linux/x86_64  /tidb-deploy/grafana-3000
  18. Attention:
  19.     1If the topology is not what you expected, check your yaml file.
  20.     2. Please confirm there is no port/directory conflicts in same host.
  21. Do you want to continue? [y/N]: (default=N) y
  22. + Generate SSH keys ... Done
  23. + Download TiDB components
  24. + Initialize target host environments
  25. + Deploy TiDB instance
  26. + Copy certificate to remote host
  27. + Init instance configs
  28. + Init monitor configs
  29. Enabling component pd
  30. Enabling component tikv
  31. Enabling component tidb
  32. Enabling component tiflash
  33. Enabling component prometheus
  34. Enabling component grafana
  35. Enabling component node_exporter
  36. Enabling component blackbox_exporter
  37. Cluster `mytidb` deployed successfully, you can start it with command: `tiup cluster start mytidb --init`

集群安装完成,接下来启动集群。

5. 启动集群

  1. [root@shawnyan ~ 12:04:17]$ tiup cluster start mytidb --init
  2. Starting cluster mytidb...
  3. + [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/mytidb/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/mytidb/ssh/id_rsa.pub
  4. + [Parallel] - UserSSH: user=tidb, host=192.168.8.161
  5. ...
  6. + [ Serial ] - StartCluster
  7. Starting component pd
  8. Starting component tikv
  9. Starting component tidb
  10. Starting component tiflash
  11. Starting component prometheus
  12. Starting component grafana
  13. Starting component node_exporter
  14. Starting component blackbox_exporter
  15. + [ Serial ] - UpdateTopology: cluster=mytidb
  16. Started cluster `mytidb` successfully
  17. The root password of TiDB database has been changed.
  18. The new password is'2mKNM_976^-+1h8BEL'.
  19. Copy and record it to somewhere safe, it is only displayed once, and will not be stored.
  20. The generated password can NOT be get and shown again.

此时,TiDB 集群已启动成功,并且自动创建了 root 账号密码。

6. 查看 TiDB 集群状态

连接 TiDB,查看版本号。

  1. [root@shawnyan ~ 12:05:20]$ mysql -h 192.168.8.161 -P 4000 -u root -p
  2. Enter password: 
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.
  4. Your MySQL connection id is 3290431496
  5. Server version: 8.0.11-TiDB-v8.0.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible
  6. Copyright (c) 20002024, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> select tidb_version()\G
  12. *************************** 1. row ***************************
  13. tidb_version(): Release Version: v8.0.0
  14. Edition: Community
  15. Git Commit Hash: 8ba1fa452b1ccdbfb85879ea94b9254aabba2916
  16. Git Branch: HEAD
  17. UTC Build Time2024-03-28 14:22:15
  18. GoVersion: go1.21.4
  19. Race Enabled: false
  20. Check Table Before Drop: false
  21. Store: tikv
  22. 1 row in set (0.00 sec)
  23. mysql> \q
  24. Bye

查看 TiDB 集群列表。

  1. [root@shawnyan ~ 12:05:46]$ tiup cluster list
  2. Name    User  Version  Path                                         PrivateKey
  3. ----    ----  -------  ----                                         ----------
  4. mytidb  tidb  v8.0.0   /root/.tiup/storage/cluster/clusters/mytidb  /root/.tiup/storage/cluster/clusters/mytidb/ssh/id_rsa

查看集群拓扑结构和状态。

  1. [root@shawnyan ~ 12:05:54]$ tiup cluster display mytidb
  2. Cluster type:       tidb
  3. Cluster name:       mytidb
  4. Cluster version:    v8.0.0
  5. Deploy user:        tidb
  6. SSH type:           builtin
  7. Dashboard URL:      http://192.168.8.161:2379/dashboard
  8. Grafana URL:        http://192.168.8.161:3000
  9. ID                   Role        Host           Ports                            OS/Arch       Status   Data Dir                    Deploy Dir
  10. --                   ----        ----           -----                            -------       ------   --------                    ----------
  11. 192.168.8.161:3000   grafana     192.168.8.161  3000                             linux/x86_64  Up       -                           /tidb-deploy/grafana-3000
  12. 192.168.8.161:2379   pd          192.168.8.161  2379/2380                        linux/x86_64  Up|L|UI  /tidb-data/pd-2379          /tidb-deploy/pd-2379
  13. 192.168.8.161:9090   prometheus  192.168.8.161  9090/12020                       linux/x86_64  Up       /tidb-data/prometheus-9090  /tidb-deploy/prometheus-9090
  14. 192.168.8.161:4000   tidb        192.168.8.161  4000/10080                       linux/x86_64  Up       -                           /tidb-deploy/tidb-4000
  15. 192.168.8.161:9000   tiflash     192.168.8.161  9000/8123/3930/20170/20292/8234  linux/x86_64  Up       /tidb-data/tiflash-9000     /tidb-deploy/tiflash-9000
  16. 192.168.8.161:20160  tikv        192.168.8.161  20160/20180                      linux/x86_64  Up       /tidb-data/tikv-20160       /tidb-deploy/tikv-20160
  17. 192.168.8.161:20161  tikv        192.168.8.161  20161/20181                      linux/x86_64  Up       /tidb-data/tikv-20161       /tidb-deploy/tikv-20161
  18. Total nodes: 7
  19. [root@shawnyan ~ 12:06:04]$ 

到此,仅用了不到 10 分钟,就部署完成了一套 TiDB 集群。

遥想当年写 Shell 脚本和 Ansible 脚本的岁月,有 TiUP 助力简直不要 Ti 幸福。


“带货”时间:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/519576
推荐阅读
相关标签