因为公司技术方面的需求,前一段时间折腾了一下elasticsearch,总体技术水平能够达到简历上的 “熟悉” 的程度。
有管理ES集群经验的朋友肯定都知道elasticsearch的head插件能够实现对es集群的查看,索引分片,展示数据分布等功能,但是在页面美观上有点欠缺。本文介绍一款es集群管理平台--cerebro。
cerebro算是一款"绿色"软件,只要有标准的java环境,下载解压之后即可使用。
在功能上cerebro支持节点状态监控 服务器磁盘空间,cpu,load,索引数量大小 ,数据分布位置等监控。 支持查询。
wget "https://github.com/lmenezes/cerebro/releases/download/v0.8.1/cerebro-0.8.1.tgz" tar -zxf cerebro-0.8.1.tgz
解压之后其实只有四个文件夹,我们只需要关注bin 和conf目录,bin有可执行文件 cerebo ,conf里面有需要访问es集群的配置文件。
[root# /opt/cerebro] # ls bin cerebro.db conf lib logs README.md
vim conf/application.conf
hosts = [
{
host = "http://localhost:9200"
name = "es-test"
}
# Example of host with authentication
#{
# host = "http://some-authenticated-host:9200"
# name = "Secured Cluster"
# auth = {
# username = "username"
# password = "secret-password"
# }
#}
]
这里我们选择不带用户权限校验的方式。
cd /opt/cerebro nohup ./bin/cerebro -Dhttp.port=8800 -Dhttp.address=0.0.0.0 &
能满足我们对es集群的日常管理维护 ,还是直接上图比较直观。支持索引创建删除,修改集群配置参数 等等,其他功能有需要的可以多研究研究。 需要注意的是 delete index 命令在生产环境切勿乱执行,要慎重。
因为现在公司已经在正式环境中使用cerebro,为了标准化程序管理,我写了一个小脚本支持启动关闭查看状态。该工具默认 cerebro 是安装在/opt/cerebro 目录 。当然也推荐把cerebro的程序交给supervisor管理。
#!/bin/sh
#
# chkconfig: 2345 86 14
# description: cerebro agent daemon
# processname: cerebro
#
# nohup ./bin/cerebro -Dhttp.port=9000 -Dhttp.address=0.0.0.0 >> /tmp/cerebro.log &
# Source function library.
. /etc/rc.d/init.d/functions
if [ -x /opt/cerebro ]; then
exec=/opt/cerebro/bin/cerebro
else
exit 5
fi
prog=${exec##*/}
cerebro="/opt/cerebro/bin/cerebro"
conf_file="/opt/cerebro/conf/application.conf"
pidfile="/var/run/cerebro.pid"
timeout=2
lockfile=/var/lock/subsys/$prog
logdir="/data/logs/cerebro.log"
## "cd /opt/yz-falcon-agent/; $exec -c $conf >>$logdir/stdout.log 2>>$logdir/stderr.log &"
start()
{
echo "Starting cerebro: "
daemon --user root --pidfile $pidfile " $cerebro -Dhttp.port=9000 -Dhttp.address=0.0.0.0 >>/data/logs/cerebro.log 2>/dev/null &"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $lockfile
[ $RETVAL -eq 0 -a ! -f $pidfile ] && pidof java > $pidfile
pid=`cat $pidfile`
echo "start $prog, pid is $pid"
return $RETVAL
}
stop()
{
echo -n $"Shutting down cerebro: "
killproc -p $pidfile -d $timeout $prog
rv=$?
echo
[ $rv -eq 0 ] && rm -f $lockfile
return $rv
}
restart()
{
stop
start
}
case "$1" in
start|stop|restart)
$1
;;
status)
status -p $pidfile $prog
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
;;
esac
启动
查看状态
关闭
https://mp.weixin.qq.com/s/BE8LrpviJNXGV41bhzGFTw
supervisor 工具介绍