容器化部署redis监控工具redis-stat

       redis-stat是一个比较有名的redis指标可视化的监控工具,采用ruby开发,基于redis的info命令来统计,不影响redis性能。下面给大家介绍如何在容器中安装部署redis-stat。

(1)安装docker

1)下载docker源

# curl https://download.docker.com/linux/centos/docker-ce.repo -o  /etc/yum.repos.d/docker.repo
# ls /etc/yum.repos.d/docker.repo 
/etc/yum.repos.d/docker.repo
# cat /etc/yum.repos.d/docker.repo 
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://download.docker.com/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

2)查看docker-ce

 

 

容器化部署redis监控工具redis-stat_第1张图片

3)安装docker-ce

# yum install -y docker-ce

4)启动docker

docker启动后默认开启的防火墙规则

容器化部署redis监控工具redis-stat_第2张图片

注意:防火墙规则即使清空了,但在重启docker后,规则回自动生成。

(2)下载centos7镜像

# docker pull centos

下载速度很慢,可以配置docker加速器

# vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://dhq9bx4f.mirror.aliyuncs.com"]
}

说明:url为加速器地址,需要自行到阿里云申请,配置完加速器,重启docker服务,再次docker pull centos会快很多。

(3)查看本地镜像

]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos7             latest              27bf0bcdae76        3 weeks ago         369MB

(4)把镜像启动为容器

# docker run -itd -h redis-stat --name redis-stat -p 63790:63790  centos7

说明:-h表示启动后容器的主机名,--name表示启动容器的名字,-p表示映射的端口,左边表示宿主机的端口,右边表示容器端口

(5)安装 redis-stat

1)准备环境

# ruby环境相关
# yum install -y ruby
# yum install -y ruby-devel
# yum install  -y rubygems

# 基本环境
yum install -y gcc gcc-c++

2)编译安装

# gem install redis-stat

安装报错,提示make命令不存在

容器化部署redis监控工具redis-stat_第3张图片

安装make,然后重新编译安装

# yum install -y make
# gem install redis-stat

(6)使用

1)控制台使用

# redis-stat   172.17.0.3:6379 1 10 

说明:172.17.0.3:6379为需要监控的redis的IP和端口,1表示1s采集一次,10表示总共采集10次

容器化部署redis监控工具redis-stat_第4张图片

2)web浏览器

# redis-stat   172.17.0.3:6379  --server=63790    --verbose 5 > /dev/null  &
[1] 645

--server表示启动的端口,5表示每隔5s采集一次

web界面查看

容器化部署redis监控工具redis-stat_第5张图片

你可能感兴趣的:(redis-stat)