合 在同一个主机上安装集群(非TiUP Playground方式)
参考:https://docs.pingcap.com/zh/tidb/stable/quick-start-with-tidb#Linux
其它内容可以参考:
- 【DB宝54】NewSQL数据库之TiDB简介 :https://www.dbaup.com/dbbao54newsqlshujukuzhitidbjianjie.html
- 【DB宝57】使用Docker-Compose快速部署TiDB集群环境:https://www.dbaup.com/dbbao57shiyongdocker-composekuaisubushutidbjiqunhuanjing.html
- 使用TiUP快速部署TiDB上手环境(在同一个主机上安装TiDB集群–使用TiUP Playground方式):https://www.dbaup.com/shiyongtiupkuaisubushutidbshangshouhuanjing.html
https://docs.pingcap.com/zh/tidb/stable/quick-start-with-tidb/#Linux
适用场景:希望用单台 Linux 服务器,体验 TiDB 最小的完整拓扑的集群,并模拟生产环境下的部署步骤。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | docker rm -f lhrtidb53 docker run -d --name lhrtidb53 -h lhrtidb53 \ -p 54000-54001:4000-4001 -p 52379-52385:2379-2385 -p 59090:9090 -p 53000:3000 -p 53389:3389 \ -v /sys/fs/cgroup:/sys/fs/cgroup \ --privileged=true lhrbest/lhrcentos76:8.5 \ /usr/sbin/init docker exec -it lhrtidb53 bash -- 安装tiup curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh source /root/.bash_profile echo "export PATH=/root/.tiup/bin:$PATH" >> /root/.bashrc -- 安装cluster组件并升级 tiup cluster tiup update --self && tiup update cluster -- 由于模拟多机部署,需要通过 root 用户调大 sshd 服务的连接数限制 echo 'MaxSessions=40' >> /etc/ssh/sshd_config systemctl restart sshd -- 安装用户 useradd tidb echo "tidb:lhr" | chpasswd |
配置参数(1个tidb,1个pd,1个tiflash,1个monitor,3个tikv):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | cat > /tmp/topo.yaml <<"EOF" # # Global variables are applied to all deployments and used as the default value of # # the deployments if a specific deployment value is missing. global: user: "tidb" ssh_port: 22 deploy_dir: "/tidb-deploy" data_dir: "/tidb-data" # # Monitored variables are applied to all the machines. monitored: node_exporter_port: 9100 blackbox_exporter_port: 9115 server_configs: tidb: log.slow-threshold: 300 oom-action: log tikv: log-level: warning readpool.storage.use-unified-pool: false readpool.coprocessor.use-unified-pool: true pd: replication.enable-placement-rules: true replication.location-labels: ["host"] tiflash: logger.level: "info" pd_servers: - host: 127.0.0.1 tidb_servers: - host: 127.0.0.1 tikv_servers: - host: 127.0.0.1 port: 20160 status_port: 20180 config: server.labels: { host: "logic-host-1" } - host: 127.0.0.1 port: 20161 status_port: 20181 config: server.labels: { host: "logic-host-2" } - host: 127.0.0.1 port: 20162 status_port: 20182 config: server.labels: { host: "logic-host-3" } tiflash_servers: - host: 127.0.0.1 monitoring_servers: - host: 127.0.0.1 grafana_servers: - host: 127.0.0.1 EOF |
配置参数(2个tidb,3个pd,1个tiflash,1个monitor,3个tikv):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | cat > /tmp/topo.yaml <<"EOF" # # Global variables are applied to all deployments and used as the default value of # # the deployments if a specific deployment value is missing. global: user: "tidb" ssh_port: 22 deploy_dir: "/tidb-deploy" data_dir: "/tidb-data" # # Monitored variables are applied to all the machines. monitored: node_exporter_port: 9100 blackbox_exporter_port: 9115 server_configs: tidb: log.slow-threshold: 300 oom-action: log tikv: log-level: warning storage.reserve-space: 0 readpool.storage.use-unified-pool: false readpool.coprocessor.use-unified-pool: true pd: replication.enable-placement-rules: true replication.location-labels: ["host"] tiflash: logger.level: "info" pd_servers: - host: 127.0.0.1 client_port: 2379 peer_port: 2380 - host: 127.0.0.1 client_port: 2381 peer_port: 2382 - host: 127.0.0.1 client_port: 2383 peer_port: 2384 tidb_servers: - host: 127.0.0.1 port: 4000 status_port: 10080 - host: 127.0.0.1 port: 4001 status_port: 10081 tikv_servers: - host: 127.0.0.1 port: 20160 status_port: 20180 config: server.labels: { host: "logic-host-1" } - host: 127.0.0.1 port: 20161 status_port: 20181 config: server.labels: { host: "logic-host-2" } - host: 127.0.0.1 port: 20162 status_port: 20182 config: server.labels: { host: "logic-host-3" } tiflash_servers: - host: 127.0.0.1 monitoring_servers: - host: 127.0.0.1 grafana_servers: - host: 127.0.0.1 EOF |
开始部署: