欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

CentOS 5.9下Redis图形监控工具RedisLive的安装使用

程序员文章站 2022-04-24 22:05:37
...

一直觉得缓存这东西,一般公司用用就行了,没什么必要做监控吧。可是当有一天缓存越来越重要,缓存挂了,全线崩溃时,监控就是必须的了。 一:安装使用 1 安装,其实安装就是令人发指的简单 pip install tornadopip install redispip install python-dateuti

一直觉得缓存这东西,一般公司用用就行了,没什么必要做监控吧。可是当有一天缓存越来越重要,缓存挂了,全线崩溃时,监控就是必须的了。

一:安装使用

1 安装,其实安装就是令人发指的简单

pip install tornado
pip install redis
pip install python-dateutil
git clone https://github.com/kumarnitin/RedisLive.git

2 配置使用

a 修改redis-live.conf如下:
cd RedisLive/src/
vim redis-live.conf
{
    "RedisServers":
    [   
        {   
            "server": "127.0.0.1",
            "port" : 6379
        }   
    ],  
    "DataStoreType" : "redis",
    "RedisStatsServer":
    {   
        "server" : "127.0.0.1",
        "port" : 6379
    }   
}
b 开始监控持续120s
./redis-monitor.py --duration=120
把监控加入crontab
*/30 * * * * cd /root/src/RedisLive/src && /usr/local/python2.7/bin/python2.7 redis-monitor.py --duration=120  > /dev/null 2>&1 &
c 开启web服务器
./redis-live.py
d 请访问 http://yourip:8888/index.html

二:遇到的坑

1 使用sqlite时老是报错

ImportError: No module named _sqlite3

查资料这个应该是python 2.7.3的一个bug

先安装sqlite-devel,然后重新编译python的方法不可行,最后是下面的方法解决

在网上查了一下解决办法:编辑源码下的connection.c这个文件
vi Python-2.7.3/Modules/_sqlite/connection.c
在
#include "cache.h"
#include "module.h"
#include "connection.h"
#include "statement.h"
#include "cursor.h"
#include "prepare_protocol.h"
#include "util.h"
#include "sqlitecompat.h"
#include "pythread.h"
#define ACTION_FINALIZE 1
#define ACTION_RESET 2
#if SQLITE_VERSION_NUMBER >= 3003008
#ifndef SQLITE_OMIT_LOAD_EXTENSION
#define HAVE_LOAD_EXTENSION
#endif
#endif
下面添加
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 sqlite_int64;
typedef unsigned __int64 sqlite_uint64;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;
然后重新编译python问题解决

三:是时候结束了

自言自语:

这个监控用起来真是令人发指的简单,功能也简单。不过看到使用的技术只能独自叹息,什么时候可以去看看tornado的源码呢?

参考资料:

作者博客:http://www.nkrode.com/article/real-time-dashboard-for-redis

作者github: https://github.com/nkrode/RedisLive

sqlite问题: http://my.oschina.net/541996928/blog/159837