Build lepus monitoring


1. First introduce the server configuration

Centos7
MySQL5.6 installed on the server
lepus using docker operation

2. The installation of the database will not be introduced here

3. The basics of docker are not introduced anymore

Pull the image: docker pull georce/lepus
starts the container:

docker run  -p 9001:80 -p 9002:3306 --restart=always --name=lepus -v /docker/lepus/mysql:/var/lib/mysql -v /etc/localtime:/etc/localtime -d georce/lepus
 -v /docker/lepus/mysql:/var/lib/mysql: 
 这个也是必须的,在我们不小心将容器删除了,镜像也删除了,可以通过我们挂载的文件进行快速恢复。这里多解释一下,如果我们把镜像也删除了,在重新拉取这个镜像,将我们本地的 /docker/lepus/mysql在挂载到/var/lib/mysql,会发现我们的配置还是存在的,相当于是一个备份的意思
-v /etc/localtime:/etc/localtime: 
这个是必须的,不然lepus会发现时间会对不上
--restart=always:
当进程停止时,会不受Exit Code的影响,总是重启

4. Server IP+9001

HTTP: // 106 . . * .24: 9001
Username Password:
ADMIN
Lepusadmin

5. Configuration steps

Insert picture description here
Fill in the label at will and save it. Wait a moment, smoke a cigarette, and then you can check in the MySQL monitor. All
Insert picture description here
four of the red boxes have values.

6. Redis configuration

Redis configuration is the same, just smoke and wait for a while

7. Host monitoring

This follow-up supplement,
Insert picture description here

8. Configure MySQL slow query

There are not many tutorials based on lepus. It is really full of pitfalls. At the beginning, MySQL was also deployed by docker. I found that I couldn't go on at all. But now you can try it. It should be possible. The
first point is that we use mirrored lepus and enter the container.

docker exec -it lepus bash
lepus :容器名

The second input: mysql -ulepus_user -p
hahaha! ! ! ! !
Username: lepus_user Password: password
Now we have figured out a lot at this step, he actually created another database for us
<------------------- ----------------->
Now enter the topic:
first look at this: http://www.lepus.cc/post/53
The location of the file in the container:

/usr/local/lepus/client/mysql/lepus_slowquery.sh

I don’t want to describe this too much on the official website. It’s simple, let me briefly explain some of the things in the middle.

#config lepus database server

lepus_db_host="服务器IP"

# docker启动lepus容器中的指向外部端口
lepus_db_port=9002

lepus_db_user=" lepus_user"

lepus_db_password="password"

# 这个可以固定
lepus_db_database=" lepus"
#config mysql server
# 以下是我们自己的数据库相关配置
# 不知道这个路径在哪的话,可以执行 which mysql。如果报错了话,就直接百度,第一个第二个就是
mysql_client="/data/mysql/bin/mysql"

mysql_host="127.0.0.1"

mysql_port=3306

mysql_user="roaaaaaaaaaaaaaaaaot"

mysql_password=" roaaaaaaaaaaaaaaaot"
#config slowqury
# 慢查询日志保存地址,/ 
slowquery_dir="/data/mysql/slowlog/"

# 慢查询时间
slowquery_long_time=0.5

# 看这个 http://www.lepus.cc/post/53,然后可以在自己的路径下面找寻
pt_query_digest="/usr/bin/pt-query-digest"

#config server_id

# 看这个 http://www.lepus.cc/post/53
lepus_server_id=131

Now, after the configuration, we first execute it manually,

sh ./lepus_slowquery.sh

There may be many mistakes in the middle, don't be impatient, take your time, Baidu one by one, and solve them in minutes. Since I have already processed it and can’t reproduce it, I won’t elaborate on it. If you have any questions, please ask me

In the end, it’s
Insert picture description here
like this, then it’s better to query slowly, then smoke a cigarette and so on,
Insert picture description here

9. Configure replication monitoring

As long as the server is configured with master, master and slave, it can be automatically identified

10. Configuration table space analysis

Enter the container

vim /usr/local/lepus/lepus.py
// 添加如下
job = Process(target = job_run, args = ('check_mysql_bigtable',int(frequency_monitor)*120))
joblist.append(job)
job.start()

Insert picture description here
The red box is the point of attention, about 43 lines, pay attention to the Python syntax, and suffer a little loss (spaces are not tabs)

Enter the container's database

SELECT id,HOST,PORT,username,PASSWORD,tags,bigtable_size FROM db_servers_mysql WHERE is_delete=0 AND monitor=1 AND bigtable_monitor=1;

bigtable_size: It is the size of the table that needs to be queried. We are currently testing to modify the value to 0 to see the effect
Insert picture description here
and then restart the container to see if the data is available

SELECT * FROM mysql_bigtable

Enter the page, just refresh it, the data is there




11, notes

When linking the service database, you need: mysql -uroot -h 127.0.0.1 -p (Because the socket is duplicated, 127.0.0.1 will cause permission problems)

As long as you follow the operation, there will be no problem, but you have to read it carefully, because the writing is very simple, and the key points need to be paid attention




to. Goodbye!
By the way,
thanks to the following address:
Lepus official website: http://www.lepus.cc/post/53 Xiaoqi
: https://blog.52itstyle.vip/archives/3472/Mirror
: https://github.com /Georce/lepus

I am well aware that the tutorials provided above are still not complete, and there will still be problems in some places.
Provide a group: 807770565, welcome everyone to come in and chat
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_38637558/article/details/97918458