zabbix configuration tidb database

Keywords: Zabbix MySQL ftp Database

zabbix introduction

Zabbix is an enterprise-level open source solution based on WEB interface to provide distributed system monitoring and network monitoring functions.
zabbix consists of zabbix server and optional component zabbix agent.
zabbix server can provide remote server / network status monitoring through SNMP, zabbix agent, ping, port monitoring and other methods.
zabbix agent needs to be installed on the monitored target server, which mainly completes the collection of hardware information or memory, CPU and other information related to the operating system.
Zabbix collects data through C/S mode and displays and configures it on the web side through B/S mode.
The monitored end: the host collects data by installing agent, and the network equipment collects data by SNMP.
Server side: By collecting data sent by SNMP and agent, write to database (MySQL,ORACLE, etc.), and then display it on the front end of the web through php+apache

TiDB introduction

TiDB is an open source distributed NewSQL database implemented by PingCAP based on Google Spanner/F1 paper.

  • TiDB has the following core features of NewSQL:
SQL support (TiDB is MySQL compatible)
Horizontal linear elastic expansion
 Distributed transaction
 Strong consistency guarantee for data across data centers
 High Availability of Fault Self-Recovery

TiDB is designed for 100% OLTP scenarios and 80% OLAP scenarios.
TiDB has no intrusiveness to business, and can gracefully replace Sharing schemes such as traditional database middleware, database sub-database and sub-table. At the same time, it also allows developers to focus on business development without paying attention to the details of database Scale, which greatly improves the productivity of R&D.

TiDB cluster is mainly divided into three components:

TiDB Server

TiDB Server is responsible for receiving SQL requests, processing SQL-related logic, and finding the TiKV address to store the data needed for calculation through PD. It interacts with TiKV to obtain data, and finally returns the results. TiDB Server is stateless. It does not store data itself, but is only responsible for computing. It can be extended horizontally. It can provide a unified access address through load balancing components (such as LVS, HAProxy or F5).

PD Server

Placement Driver (abbreviated as PD) is the management module of the whole cluster. Its main work includes three parts: one is to store the meta-information of the cluster (which TiKV node a Key is stored in); the other is to schedule and load balance the TiKV cluster (such as data migration, Raft group leader migration, etc.); and the third is to distribute the unique and increasing transaction ID globally.

As a cluster, PD needs to deploy odd number of nodes. Generally, it is recommended to deploy at least three nodes online.

TiKV Server

TiKV Server is responsible for storing data. From the outside, TiKV is a distributed Key-Value storage engine that provides transactions. The basic unit of data storage is Region. Each Region is responsible for storing one Key Range (left-closed right-open interval from StartKey to EndKey), and each TiKV node is responsible for multiple Regions. TiKV replicates using Raft protocol to maintain data consistency and disaster tolerance. The replicas are managed in Regions, and multiple Regions on different nodes form a Raft Group, which is replicas for each other. The load balancing of data among multiple TiKVs is scheduled by PD, which is also scheduled in Regions.

Install zabbix

Environment: rhel7.2 ip: 172.25.5.4 zabbix-server zabbix-agent zabbix-web TiDB PD
rhel6.5 ip: 172.25.5.1 mariadb-server TiKV
rhel6.5 ip: 172.25.5.2 mariadb-server TiKV
rhel6.5 ip: 172.25.5.3 mariadb-server TiKV

[root@server4 pub]# ls
php-bcmath-5.4.16-36.el7_1.x86_64.rpm      
php-mbstring-5.4.16-36.el7_1.x86_64.rpm  
[root@server4 pub]# yum install php*
---
[root@server4 zibb]# ll
total 5080
-rwxrwxrwx 1 ftp  ftp    41292 Aug 14 06:13 fping-3.10-1.el7.x86_64.rpm
-rwxrwxrwx 1 ftp  ftp    50452 Aug 14 06:13 iksemel-1.4-2.el7.centos.x86_64.rpm
-rwxrwxrwx 1 ftp  ftp   369416 Aug 14 06:13 zabbix-agent-3.4.6-1.el7.x86_64.rpm
-rwxrwxrwx 1 ftp  ftp  2068572 Aug 14 06:13 zabbix-server-mysql-3.4.6-1.el7.x86_64.rpm
-rwxrwxrwx 1 ftp  ftp  2648144 Aug 14 06:13 zabbix-web-3.4.6-1.el7.noarch.rpm
-rwxrwxrwx 1 ftp  ftp     6692 Aug 14 06:13 zabbix-web-mysql-3.4.6-1.el7.noarch.rpm
[root@server4 zibb]# yum install *
---

Install the database:

[root@server1 ~]# yum install -y mariadb-server
[root@server1 ~]# systemctl start mariadb
[root@server1 ~]# mysql_secure_installation
[root@server1 ~]# mysql -uroot -pwestos
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'westos';

Install tidb:

[root@server4 tidb]# ls
tidb-ansible-master.zip  tidb-latest-linux-amd64.tar.gz
[root@server4 tidb]# tar zxf tidb-latest-linux-amd64.tar.gz 
[root@server4 tidb]# mv tidb-latest-linux-amd64 /usr/local/
[root@server4 tidb]# cd /usr/local/
[root@server4 local]# mv tidb-latest-linux-amd64/ tidb/

Start tidb:

1. Start PD
server4

./bin/pd-server --name=pd1 --data-dir=pd1 --client-urls="http://172.25.5.4:2379" --peer-urls="http://172.25.5.4:2380" --initial-cluster="pd1=http://172.125.5.4:2380" --log-file=pd.log &

2. Start TiKV
server1

./bin/tikv-server --pd="172.25.5.4:2379" --addr="172.25.5.1:20160" --data-dir=tikv1 --log-file=tikv.log &

server2

./bin/tikv-server --pd="172.25.5.4:2379" --addr="172.25.5.2:20160" --data-dir=tikv1 --log-file=tikv.log &

server3

./bin/tikv-server --pd="172.25.5.4:2379" --addr="172.25.5.3:20160" --data-dir=tikv1 --log-file=tikv.log &

3. Start TiDB

./bin/tidb-server

Connect mysql

[root@server4 tidb-latest-linux-amd64]# mysql -h 172.25.5.4 -P 4000 -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.1-TiDB-0.9.0 MySQL Community Server (Apache License 2.0)

Copyright (c) 2000, 2015, 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@'172.25.5.%' identified by 'westos';
Query OK, 1 row affected (0.01 sec)

The database imports data:

[root@server4 Desktop]# cp /usr/share/doc/zabbix-server-mysql-3.4.2/create.sql.gz ./
[root@server4 Desktop]# ls
create.sql.gz
[root@server4 Desktop]# gzip ./create.sql.gz -d
[root@server4 Desktop]# ls
create.sql
[root@server4 Desktop]# mysql -h 172.25.5.4 -P 4000 -uzabbix -p zabbix <create.sql

Modify the previous zabbix-server configuration file

[root@server11 zabbix]# vim zabbix_server.conf 
-----
125 DBPassword=westos             
133 DBSocket=/var/lib/mysql/mysql.sock
141 DBPort=4000
-----

Modifying the web (php) configuration of zabbix

[root@server4 Desktop]# vim /etc/httpd/conf.d/zabbix.conf
-----
php_value date.timezone Asia/Shanghai
-----

[root@server4 Desktop]# systemctl restart zabbix-server zabbix-agent httpd
[root@server4 Desktop]# systemctl enable zabbix-server zabbix-agent httpd

Browser access 172.25.5.4/zabbix

The above steps will be able to login normally if all OK is available (initial username password Admin/zabbix)

The successful home page of login is shown as follows:

Posted by fantic on Thu, 16 May 2019 15:57:31 -0700