1.TiDB 简介
TiDB 是 PingCAP 公司自主设计、研发的开源分布式关系型数据库,是一款同时支持在线事务处理与在线分析处理 (Hybrid Transactional and Analytical Processing, HTAP) 的融合型分布式数据库产品,具备水平扩容或者缩容、金融级高可用、实时 HTAP、云原生的分布式数据库、兼容 MySQL 5.7 协议和 MySQL 生态等重要特性。目标是为用户提供一站式 OLTP (Online Transactional Processing)、OLAP (Online Analytical Processing)、HTAP 解决方案。TiDB 适合高可用、强一致要求较高、数据规模较大等各种应用场景。
2.Tidb+Zabbix的简单部署
实验环境部署 三台主机 172.25.14.1 server1 zabbix-server mariadb PD1,TiDB 172.25.14.2 server2 Tikv1 172.25.14.3 server3 Tikv2 172.25.14.4 server4 Tikv3
server1解压并安装
[root@server1 ~]# tar zxf tidb-latest-linux-amd64.tar.gz
[root@server1 ~]# cd tidb-latest-linux-amd64/
[root@server1 tidb-latest-linux-amd64]# ls
bin
[root@server1 tidb-latest-linux-amd64]# ./bin/pd-server --name=pd1 --data-dir=pd1 --client-urls="http://172.25.14.1:2379" --peer-urls="http://172.25.14.1:2380" --initial-cluster="pd1=http://172.25.14.1:2380" --log-file=pd.log &
[1] 12003
[root@server1 tidb-latest-linux-amd64]# netstat -antlp |grep :2379
tcp 0 0 172.25.14.1:2379 0.0.0.0:* LISTEN 12003/./bin/pd-serv
tcp 0 0 172.25.14.1:2379 172.25.14.1:50804 ESTABLISHED 12003/./bin/pd-serv
tcp 0 0 172.25.14.1:2379 172.25.14.1:50784 ESTABLISHED 12003/./bin/pd-serv
tcp 0 0 172.25.14.1:50784 172.25.14.1:2379 ESTABLISHED 12003/./bin/pd-serv
tcp 0 0 172.25.14.1:50804 172.25.14.1:2379 ESTABLISHED 12003/./bin/pd-serv
[root@server1 tidb-latest-linux-amd64]# netstat -antlp |grep :2380
tcp 0 0 172.25.14.1:2380 0.0.0.0:* LISTEN 12003/./bin/pd-serv
server2、3、4解压并开启tikv
[root@server2 ~]# tar zxf tidb-latest-linux-amd64.tar.gz
[root@server2 ~]# cd tidb-latest-linux-amd64/
[root@server2 tidb-latest-linux-amd64]# ./bin/tikv-server --pd="172.25.14.1:2379" --addr="172.25.14.2:20160" --data-dir=tikv1 --log-file=tikv.log &
[1] 22226
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3138/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3374/master
tcp 0 0 172.25.14.2:22 172.25.14.250:41652 ESTABLISHED 3400/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 3138/sshd
tcp6 0 0 ::1:25 :::* LISTEN 3374/master
./bin/tikv-server --pd="172.25.14.1:2379" --addr="172.25.14.2:20160" --data-dir=tikv1 --log-file=tikv.log
[root@server3 ~]# tar zxf tidb-latest-linux-amd64.tar.gz
[root@server3 ~]# cd tidb-latest-linux-amd64/
[root@server3 tidb-latest-linux-amd64]# ./bin/tikv-server --pd="172.25.14.1:2379" --addr="172.25.14.3:20160" --data-dir=tikv1 --log-file=tikv.log &
[1] 5790
[root@server3 tidb-latest-linux-amd64]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3138/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3355/master
tcp 0 0 172.25.14.3:22 172.25.14.250:37962 ESTABLISHED 3401/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 3138/sshd
tcp6 0 0 ::1:25 :::* LISTEN 3355/master
./bin/tikv-server --pd="172.25.14.1:2379" --addr="172.25.14.3:20160" --data-dir=tikv1 --log-file=tikv.log
[root@server4 ~]# tar zxf tidb-latest-linux-amd64.tar.gz
[root@server4 ~]# cd tidb-latest-linux-amd64/
[root@server4 tidb-latest-linux-amd64]# ./bin/tikv-server --pd="172.25.14.1:2379" --addr="172.25.14.4:20160" --data-dir=tikv1 --log-file=tikv.log&
[1] 3890
[root@server4 tidb-latest-linux-amd64]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3140/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3380/master
tcp 0 0 172.25.14.4:22 172.25.14.250:35176 ESTABLISHED 3434/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 3140/sshd
tcp6 0 0 ::1:25 :::* LISTEN 3380/master
./bin/tikv-server --pd="172.25.14.1:2379" --addr="172.25.14.4:20160" --data-dir=tikv1 --log-file=tikv.log
开启zabbix及tidb
[root@server1 tidb-latest-linux-amd64]# systemctl stop mariadb.service
[root@server1 tidb-latest-linux-amd64]# ./bin/tidb-server
2021/07/15 15:32:03.466 printer.go:33: [info] Welcome to TiDB.
2021/07/15 15:32:03.466 printer.go:34: [info] Release Version: 0.9.0
2021/07/15 15:32:03.466 printer.go:35: [info] Git Commit Hash: e11c4fbaad847df82b704b0b029999c312ad8322
2021/07/15 15:32:03.466 printer.go:36: [info] Git Branch: master
2021/07/15 15:32:03.466 printer.go:37: [info] UTC Build Time: 2017-10-09 09:43:51
2021/07/15 15:32:03.466 terror.go:327: [fatal] resource temporarily unavailable
/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/store/tikv/mock-tikv/mvcc_leveldb.go:108:
/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/store/tikv/kv.go:274:
/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/misc.go:32:
/home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/tidb.go:258:
[root@server1 tidb-latest-linux-amd64]# netstat -antlp |grep :4000
tcp6 0 0 :::4000 :::* LISTEN 22379/./bin/tidb-se
[root@server1 tidb-latest-linux-amd64]# netstat -antlp |grep :4000
tcp6 0 0 :::4000 :::* LISTEN 22379/./bin/tidb-se
[root@server1 tidb-latest-linux-amd64]# ps ax | grep tidb
22379 ? Sl 0:00 ./bin/tidb-server
23349 pts/1 R+ 0:00 grep --color=auto tidb
数据库连接tidb
[root@server1 tidb-latest-linux-amd64]# mysql -h 172.25.14.1 -P 4000 -uroot
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.1-TiDB-0.9.0 MySQL Community Server (Apache License 2.0)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 0 rows affected (0.01 sec)
MySQL [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'westos';
Query OK, 1 row affected (0.01 sec)
MySQL [(none)]> grant all privileges on *.* to 'zabbix'@'%';
Query OK, 1 row affected (0.00 sec)
给数据库中导入数据
[root@server1 tidb-latest-linux-amd64]# cd /usr/share/doc/zabbix-server-mysql-4.0.5/
[root@server1 zabbix-server-mysql-4.0.5]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@server1 zabbix-server-mysql-4.0.5]# zcat create.sql.gz |mysql -h 172.25.14.1 -P 4000 -uroot zabbix
zabbix配置文件的修改
vim /etc/zabbix/zabbix_server.conf
DBPort=4000 ##修改端口为4000
[root@server1 ~]# cd /etc/zabbix/
[root@server1 zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@server1 zabbix]# cd web/
[root@server1 web]# ls
maintenance.inc.php zabbix.conf.php
[root@server1 web]# vim zabbix.conf.php
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '4000';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'westos';
重启服务
[root@server1 web]# systemctl restart zabbix-server
[root@server1 web]# systemctl restart zabbix-agent
浏览器访问http://172.25.14.1/zabbix
|