TIDB简介
TiDB 是 PingCAP 公司设计的开源分布式 HTAP (Hybrid Transactional and Analytical Processing) 数据库,结合了传统的 RDBMS 和 NoSQL 的最佳特性。TiDB 兼容 MySQL,支持无限的水平扩展,具备强一致性和高可用性。TiDB 的目标是为 OLTP (Online Transactional Processing) 和 OLAP (Online Analytical Processing) 场景提供一站式的解决方案。
官方链接:https://pingcap.com/docs-cn/v3.0/overview/
单节点部署
不建议单节点,开发环境使用.
一、下载官方源
[root@iZ31lo2i2a80qcZ /]# cd tmp/
[root@iZ31lo2i2a80qcZ tmp]# wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
[root@iZ31lo2i2a80qcZ tmp]# wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256
///验证文件完整性/
[root@iZ31lo2i2a80qcZ tmp]# sha256sum -c tidb-latest-linux-amd64.sha256
tidb-latest-linux-amd64.tar.gz: OK #返回ok说明文件没问题
[root@iZ31lo2i2a80qcZ tmp]# tar -zxvf tidb-latest-linux-amd64.tar.gz
[root@iZ31lo2i2a80qcZ tmp]# mv tidb-latest-linux-amd64 /tidb-server
[root@iZ31lo2i2a80qcZ /]# cd tidb-server/
二、分别启动tidb、pd、tikv服务
[root@iZ31la80qcZ tidb-server]# ./bin/pd-server --data-dir=/data/pd --log-file=/data/logs/pd.log &
[root@iZ31la80qcZ tidb-server]# ps -ef|grep pd-server
root 11900 11812 0 14:12 pts/0 00:00:00 ./bin/pd-server --data-dir=/data/pd --log-file=/data/logs/pd.log
root 11916 11812 0 14:13 pts/0 00:00:00 grep --color=auto pd-server
[root@iZ31lo2i2a80qcZ tidb-server]# ./bin/tikv-server --pd="127.0.0.1:2379" --data-dir=/data/tikv --log-file=/data/logs/tikv.log &
[root@iZ31lo2i2a80qcZ tidb-server]# ps -ef|grep tikv-server
root 11920 11812 10 14:14 pts/0 00:00:02 ./bin/tikv-server --pd=127.0.0.1:2379 --data-dir=/data/tikv --log-file=/data/logs/tikv.log
root 12021 11812 0 14:14 pts/0 00:00:00 grep --color=auto tikv-server
[root@iZ31lo2i2a80qcZ tidb-server]# ./bin/tidb-server --store=tikv --path="127.0.0.1:2379" --log-file=/data/logs/tidb.log &
[root@iZ31lo2i2a80qcZ tidb-server]# ps -ef|grep tidb-server
root 12025 11812 1 14:15 pts/0 00:00:00 ./bin/tidb-server --store=tikv --path=127.0.0.1:2379 --log-file=/data/logs/tidb.log
root 12063 11812 0 14:16 pts/0 00:00:00 grep --color=auto tidb-server
三、修改登录密码,开启远程连接权限务
[root@iZ31lo2i2a80qcZ tidb-server]# mysql -h 127.0.0.1 -P 4000 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.25-TiDB-v4.0.0-alpha-1258-g8e88825f5 TiDB Server (Apache License 2.0), MySQL 5.7 compatible
Copyright (c) 2000, 2019, 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> ALTER USER 'root'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.03 sec)
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
踩过的坑:单节点在数据库无连接时会自动关闭