lepus是什么?
Lepus数据库监控系统是简洁、直观、强大的开源数据库监控产品,支持MySQL/Oracle/MongoDB/Redis一站式性能监控,让数据库监控更加简单和专业。远程云中监控、实时邮件告警、丰富的指标和图表、MySQL慢查询分析和AWR性能报告。
二进制安装(最新v5.1)
1.基础环境
服务 | 版本 | 必须 | 备注 |
Golang | 1.4-1.8 | 否 | 源码编译运行必须安装/使用二进制方式无需安装 (直接 yum install golang) |
MySQL | 5.6 | 是 | 用于存储基础数据和事件数据(本文安装教程略)(yum -y install mysql-server mysql-devel) |
InfluxDB | 1.x | 否 | 事件数据默认存储MySQL,支持存储到InfluxDB,如有使用InfluxDB需求则必须需要部署(笔者未安装) |
Redis | 5.x | 是 | 用于报警系统限流(本文安装教程略)(yum -y install redis) |
systemctl start mysqld
systemctl start redis
2.安装NSQ
mkdir -p /data/NSQ
cd /data/NSQ
wget http://js.funet8.com/centos_software/nsq-1.2.1.linux-amd64.go1.16.6.tar.gz # 备用下载地址
tar -zxvf nsq-1.2.1.linux-amd64.go1.16.6.tar.gz
cd nsq-1.2.1.linux-amd64.go1.16.6/bin
1. 启动nsqlookupd(nohup 后台启动):
nohup ./nsqlookupd &
2. 启动nsqd(nohup 后台启动)
nohup ./nsqd --lookupd-tcp-address=192.168.2.1:4160 &
3. 启动nsqadmin(nohup 后台启动)
nohup ./nsqadmin --lookupd-http-address=192.168.2.1:4161 &
4. 启动日志查看:bin目录会自动生成nohup日志,查看命令如下:
tail -f nohup.out
3.NSQ消息测试
nohup ./nsq_to_file --topic=test --output-dir=/tmp --lookupd-http-address=192.168.2.1:4161 &
# curl -d 'hello world' 'http://192.168.1.3:4151/pub?topic=test'
OK
浏览器访问:192.168.2.1:4171
4.安装lepus
1.下载并修改
cd /data/
wget http://js.funet8.com/centos_software/lepus.5.1.linux-amd64.tar.gz # 备用下载地址
tar -zxvf lepus.5.1.linux-amd64.tar.gz
mv lepus.5.1.linux-amd64 lepus.5.1
5.初始化数据库
[root@localhost data]# mysql -uroot -p1234.Com
mysql> create database lepus default character set utf8;
mysql> grant all on lepus.* to 'lepus_user'@'localhost' identified by '1234.Com';
mysql> exit
[root@localhost sql]# cd lepus.5.1/sql
[root@localhost sql]# mysql -ulepus_user -P'3306' -p'1234.Com' lepus < init_table.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost sql]# mysql -ulepus_user -P'3306' -p'1234.Com' lepus < init_data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
6.修改配置文件
[root@localhost sql]# cd ..
[root@localhost lepus.5.1]# cp etc/proxy.example.ini etc/proxy.ini
[root@localhost lepus.5.1]# cp etc/alarm.example.ini etc/alarm.ini
[root@localhost lepus.5.1]# cp etc/config.example.ini etc/config.ini
由于数据库不是本机,所以需要修改配置
# vim etc/proxy.ini
修改如下
[main]
port = 8800
log = /tmp/lepus_proxy.log
debug=1
enable_influxdb=0
[nsq]
nsq_server = 127.0.0.1:4150
[mysql]
mysql_host = 127.0.0.1
mysql_port = 3306
mysql_user = lepus_user
mysql_password = 1234.Com
mysql_database = lepus
[influxdb]
influx_host = 127.0.0.1
influx_port = 8086
influx_user = root
influx_password = 123456
influx_database = lepus_db
-------------------------------------------------------------------------------------------------------
# vim etc/alarm.ini
修改如下
[main]
debug=1
log = /tmp/lepus_alarm.log
[nsq]
nsq_server = 127.0.0.1:4150
[mysql]
mysql_host = 127.0.0.1
mysql_port = 3306
mysql_user = lepus_user
mysql_password = 1234.Com
mysql_database = lepus
[redis]
redis_host = 127.0.0.1
redis_port = 6379
redis_pass =
[mail]
mail_host = smtp.163.com
mail_port = 465
mail_user = alarm@163.com
mail_pass = password
mail_from = alarm@163.com
-------------------------------------------------------------------------------------------------------
# vim etc/config.ini
修改配置
[main]
log_dir = /tmp/
debug = 1
interval = 10
proxy = http://127.0.0.1:8800
db_pass_key = L1e2p3u4s5Abc321
[mysql]
mysql_host = 127.0.0.1
mysql_port = 3306
mysql_user = lepus_user
mysql_password = 1234.Com
mysql_database = lepus
7.启动服务组件
启动Proxy模块
cd /data/lepus.5.1/bin/
./lepus_proxy --config=../etc/proxy.ini &
启动Task模块
./lepus_task --config=../etc/config.ini&
启动Alarm模块
./lepus_alarm --config=../etc/alarm.ini &
启动后可以查看进程
ps -ef|grep lepus
8.安装lepus-console
下载lepus-console安装包
mkdir /data/lepus-console
cd /data/lepus-console
wget http://js.funet8.com/centos_software/lepus-console.5.1.linux-amd64.tar.gz # 备用下载地址
tar -zxvf lepus-console.5.1.linux-amd64.tar.gz
mv lepus-console.5.1.linux-amd64 lepus-console.5.1
修改配置文件
cd lepus-console.5.1
cp setting.example.yml setting.yml
#修改配置文件
vim setting.yml
#填写以下,只修改mysql的配置:
log:
path: "/tmp/lepus_api.log"
level: "debug"
debug: true
dataSource:
eventStorageEngine: mysql
host: 127.0.0.1
port: 3306
user: lepus
password: 1234.Com
database: lepus
influxHost: 127.0.0.1
influxPort: 8086
influxUser: admin
influxPassword:
influxDatabase: lepus_db
token:
storage: "mysql"
key: "S9p2+dsfM1CzLF=="
name: "lepus-pro"
expired: "3d"
decrypt:
signKey: "1234567890abcdef"
dbPassKey: "L1e2p3u4s5Abc321"
9.运行和访问控制台
[root@localhost lepus-console.5.1]# ./lepus_console &
[GIN-debug] Listening and serving HTTP on :8080
默认管理密码为:admin/lepusadmin