分享

Redis监控工具—Redis-stat、RedisLive

fc013 发表于 2016-4-2 17:43:40 [显示全部楼层] 只看大图 回帖奖励 阅读模式 关闭右栏 1 12271
本帖最后由 fc013 于 2016-4-2 17:53 编辑
问题导读:

1.怎样安装与配置Redis-stat?
2.怎样安装与配置Redis Live




Redis-stat(Ruby)和Redis Live(python)是两款Redis监控工具,下面将介绍如何安装部署这两个工具,监控Redis运行情况
[mw_shl_code=text,true]1
测试环境:
  Ubuntu 14.04 LTS x64
  Redis redis-3.0.7.tar.gz
  Ruby ruby 1.9.3
  Python 2.7.6[/mw_shl_code]

Redis 安装
Redis安装请参照:Redis安装与配置

Redis-stat 安装部署
redis-stat is a simple Redis monitoring tool written in Ruby.
It is based on INFO command of Redis, and thus generally won’t affect the performance of the Redis instance unlike the other monitoring tools based on MONITOR command.
redis-stat allows you to monitor Redis instances
  • either with vmstat-like output from the terminal
  • or with the dashboard page served by its embedded web server.

通常来说,不会像基于MONITOR命令的监控工具一样,对Redis本身有性能上的影响


卸载原有Ruby

[mw_shl_code=shell,true]sudo apt-get autoremove --purge ruby*
[/mw_shl_code]

安装Ruby
[mw_shl_code=shell,true]
sudo apt-get install ruby-full
[/mw_shl_code]

安装Redis-stat

[mw_shl_code=shell,true]
gem install redis-stat
[/mw_shl_code]

基本使用
  • redis-stat命令参数
[mw_shl_code=text,true]usage: redis-stat [HOST[:PORT] ...] [INTERVAL [COUNT]]

    -a, --auth=PASSWORD             设置密码
    -v, --verbose                   显示更多信息
        --style=STYLE               输出编码类型: unicode|ascii
        --no-color                  取消ANSI颜色编码
        --csv=OUTPUT_CSV_FILE_PATH  以CSV格式存储结果
        --es=ELASTICSEARCH_URL      把结果发送到 ElasticSearch: [http://]HOST[:PORT][/INDEX]

        --server[=PORT]             运行redis-stat的web server (默认端口号: 63790)
        --daemon                    使得redis-stat成为进程。必须使用 --server 选项
        
        --version                   显示版本号
        --help                      显示帮助信息[/mw_shl_code]

  • redis-stat运行命令行监控
[mw_shl_code= text,true]
redis-stat
redis-stat 1
redis-stat 1 10
redis-stat --verbose
redis-stat localhost:6380 1 10
redis-stat localhost localhost:6380 localhost:6381 5
redis-stat localhost localhost:6380 1 10 --csv=/tmp/outpu.csv --verbose
[/mw_shl_code]

  • Server端运行界面

redis-stat-0.3.0.png

  • Web界面中的redis-stat

当设置–server选项之后,redis-stat会在后台启动一个嵌入式的web server(默认端口号:63790),可以让你在浏览器中监控Redis

[mw_shl_code=shell,true]
redis-stat --server
redis-stat --verbose --server=8080 5

# redis-stat server can be daemonized
redis-stat --server --daemon

# Kill the daemon
killall -9 redis-stat-daemon[/mw_shl_code]

  • Web端运行界面

然后在你的浏览器中输入:

[mw_shl_code=text,true]
http://你的Redis IP:63790
[/mw_shl_code]

redis-stat-web.png

RedisLive 安装部署
Redis Live is a dashboard application with a number of useful widgets. At it’s heart is a monitoring script that periodically issues INFO and MONITOR command to the redis instances and stores the data for analytics.

长时间运行对Redis性能有所影响


安装运行依赖
  • tornado

[mw_shl_code=shell,true]
pip install tornado
[/mw_shl_code]

  • redis.py

[mw_shl_code=shell,true]
pip install redis
[/mw_shl_code]

  • python-dateutil

[mw_shl_code=shell,true]pip install python-dateutil
[/mw_shl_code]

下载RedisLive
[mw_shl_code=shell,true]git clone https://github.com/kumarnitin/RedisLive.git
[/mw_shl_code]

conf配置
进入src目录

[mw_shl_code=shell,true]
cp redis-live.conf.example ./redis-live.conf
[/mw_shl_code]
[mw_shl_code=shell,true]vim redis-live.conf
[/mw_shl_code]
[mw_shl_code=text,true]{  
        "RedisServers":  
        [   
                {  
                  "server" : "你的Redis IP地址",  
                  "port"  : 6379  
                }
                ........
                可以多个
        ],  
         

        "DataStoreType" : "redis",  

        "RedisStatsServer":  
        {  
                "server" : "你的Redis 监控IP地址",  
                "port" : 6379  
        },
        
        "SqliteStatsStore" :
        {
                "path":  "to your sql lite file"
        }
}[/mw_shl_code]

  • 其中RedisServers为你要监控的redis实例,可以添加多个,RedisStatsServer是存储RedisLive监控数据的实例,如果redis有密码,可以在实例配置中加入password选项;如果没有存储RedisLive数据的实例,需要将DataStoreType改成”DataStoreType” : “sqlite”这种设置

启动RedisLive

  • 启动监控脚本,监控120秒,duration参数是以秒为单位

[mw_shl_code=shell,true]sudo ./redis-monitor.py --duration=120
[/mw_shl_code]

  • 启动webserver。
    RedisLive使用tornado作为web服务器,所以不需要单独安装服务器
    Tornado web server 是使用Python编写出來的一个极轻量级、高可伸缩性和非阻塞IO的Web服务器软件

[mw_shl_code=shell,true]
sudo ./redis-live.py
[/mw_shl_code]

Web运行界面
然后在你的浏览器中输入:

[mw_shl_code=text,true]
http://你的Redis IP:8888/index.html
[/mw_shl_code]


redis-live.png



已有(1)人评论

跳转到指定楼层
xuliang123789 发表于 2016-4-2 22:56:24
感谢楼主,学习一下,赞~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条