Ubuntu 14.04 中 安装elasticsearch2.*+logstash2.*+kibana
在Ubuntu 14.04 上安装单机版ELK 2.*(脚本化)
1.判断是否为root权限
if [ "${UID}" -ne 0 ];
then
echo "You must be root to run this program." >&2
exit 3
fi
2.记录脚本运行日志(可以在ubuntu日志中找到对应的运行信息)
log()
{
echo "$1"
logger "$1"
}
3.设置脚本运行参数
# Set the VM name for the elasticsearch network.host
# Set the host name instead of internal ip
while getopts n:e: optname; do
log "Option $optname set with value ${OPTARG}"
case $optname in
n) #set the encoded configuration string
log "Setting the VM Name"
VMNAME=${OPTARG}
;;
e) #set the encoded configuration string
log "Setting the encoded configuration string"
CONF_FILE_ENCODED_STRING=${OPTARG}
;;
\?) #unrecognized option - show help
echo -e \\n"Option -${BOLD}$OPTARG${NORM} not allowed."
help
exit 2
;;
esac
done
4.安装java 8
#install java8
install_java()
{
log "begin install java8"
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get -y update > /dev/null
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo apt-get -y install oracle-java8-installer > /dev/null
log "java8 has been installed"
}
5.安装Elasticsearch,配置Elasticsearch的主要参数
install_config_elasticsearch()
{
log "begin install elasticsearch"
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
sudo apt-get update
sudo apt-get -y install elasticsearch
# configure the elasticsearch
sudo echo "bootstrap.mlockall: true" >> /etc/elasticsearch/elasticsearch.yml
sudo echo "network.host: $VMNAME" >> /etc/elasticsearch/elasticsearch.yml
sudo echo "http.port: 9200" >> /etc/elasticsearch/elasticsearch.yml
# configure elasticsearch heap
log "elasticsearch.yml has been configured . The elasticsearch heap begin to configure"
es_heap_size=$(free -m |grep Mem | awk '{if ($2/2 >31744) print 31744;else print $2/2;}')
sudo printf "\nES_HEAP_SIZE=%sm\n" $es_heap_size >> /etc/default/elasticsearch
sudo printf "MAX_LOCKED_MEMORY=unlimited\n" >> /etc/default/elasticsearch
sudo echo "elasticsearch - nofile 65536" >> /etc/security/limits.conf
sudo echo "elasticsearch - memlock unlimited" >> /etc/security/limits.conf
log "es heap has been set"
sudo service elasticsearch restart
sudo update-rc.d elasticsearch defaults 95 10
log "elasticsearch has been installed"
}
6.安装主要插件,可选。
install_plugin()
{
cd /usr/share/elasticsearch/
sudo bin/plugin install lmenezes/elasticsearch-kopf
sudo bin/plugin install mobz/elasticsearch-head
sudo bin/plugin install license
sudo bin/plugin install watcher
#install marvel part0
sudo bin/plugin install marvel-agent
cd
}
7.安装配置kibana
install_config_kibana()
{
#install kibana
log "begin to install kibana"
echo "deb http://packages.elastic.co/kibana/4.4/debian stable main" | sudo tee -a /etc/apt/sources.list.d/kibana-4.4.x.list
sudo apt-get update
sudo apt-get -y install kibana
#configure kibana
# take care of the server.host name
sudo echo "server.host: '$VMNAME'" >> /opt/kibana/config/kibana.yml
sudo echo "elasticsearch.url: 'http://$VMNAME:9200'" >> /opt/kibana/config/kibana.yml
sudo update-rc.d kibana defaults 96 9
sudo service kibana start
#install marvel part1 . marvel need to be installed after kibana was done.
sudo bin/kibana plugin --install elasticsearch/marvel/2.1.0
log "kibana has been installed"
}
8.安装配置logstash
install_logstash()
{
# Install Logstash
# The Logstash package is available from the same repository as Elasticsearch . Install the public key.
# Create the logstash source list
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
log "begin to install logstash"
echo 'deb http://packages.elastic.co/logstash/2.2/debian stable main' | sudo tee /etc/apt/sources.list.d/logstash-2.2.x.list
sudo apt-get update
sudo apt-get install logstash
#configure
log "Decoding configuration string"
log "$CONF_FILE_ENCODED_STRING"
echo $CONF_FILE_ENCODED_STRING > logstash.conf.encoded
DECODED_STRING=$(base64 -d logstash.conf.encoded)
log "$DECODED_STRING"
echo $DECODED_STRING > ~/logstash.conf
#log "Installing user configuration file"
log "Installing user configuration named logstash.conf"
sudo \cp -f ~/logstash.conf /etc/logstash/conf.d/
# Configure Start
log "Configure start up service"
sudo update-rc.d logstash defaults 96 9
sudo service logstash start
}
9.运行方式
- 如果你不太熟悉,可以分段或分句复制,type到命令行然后运行。
- 如果你较为熟悉,可以复制整理所有的函数到一个elk.sh脚本中并调用,如下:
sudo bash elk.sh -n {parameter1} -e {parameter2}
#parameter1 是hostname
#parameter2 是logstash的配置文件,此处你可以简单带入如下:
"aW5wdXQgIHsgICBzdGRpbiB7fSB9IG91dHB1dCB7ICAgc3Rkb3V0IHsgY29kZWMgPT4gcnVieWRlYnVnIH0gfQ=="
#该字符串解码后为input { stdin {} } output { stdout { codec => rubydebug } }
#logstash无默认的配置文件,无法启动服务。因此需要导入一个简单的配置。然后根据后续进行修改
Ubuntu 14.04 中 安装elasticsearch2.*+logstash2.*+kibana的更多相关文章
- Ubuntu 14.04中安装最新版Eclipse
Ubuntu 14.04中安装最新版Eclipse 来源:Linux社区 作者:Linux 1.安装OpenJDK Java 7 如果你的系统中没有安装Java,我们需要按照如下步骤事先安装好 ...
- 怎样在Ubuntu 14.04中安装Java(转)
想知道如何在Ubuntu 14.04中安装Java?安装Java肯定是安装Ubuntu 14.04后首先要做的几件事情之一(见http://www.linuxidc.com/Linux/2014-04 ...
- 如何在Ubuntu 14.04中安装最新版Eclipse
想必很多开发人员都知道,Ubuntu 软件源中提供的并不是最新版本的 Eclipse,本教程就教大家如何在 Ubuntu 14.04 中快速安装 Eclipse 官方发布的最新版本. 到目前为止,Ec ...
- 转:如何在Ubuntu 14.04中安装最新版Eclipse
想必很多开发人员都知道,Ubuntu 软件源中提供的并不是最新版本的 Eclipse,本教程就教大家如何在 Ubuntu 14.04 中快速安装 Eclipse 官方发布的最新版本. 到目前为止,Ec ...
- ubuntu 14.04中安装 ruby on rails 环境
环境:在win7 上Vmware虚拟机环境中安装的ubuntu 14.04 1. bundle install 时,报json错误可以看出是在安装nokogiri时遇到了问题,此时执行 sudo ap ...
- ubuntu 14.04中安装 ruby on rails 环境(填坑版) 呕血推荐
环境:在win7 上Vmware虚拟机环境中安装的ubuntu 14.04 开发相关: ruby 2.2.0 rails 4.2.0 sublime text 3 本文说明:所有的命令均在$ 之后,若 ...
- Ubuntu 14.04 中安装 VMware10 Tools工具
Run: apt-get install dkms linux-headers-$(uname -r) build-essential psmisc2 - Run: git clone https:/ ...
- ubuntu 14.04中安装phpmyadmin即mysql图形管理界面
由于学习的需要,我将网站开发环境从windows转移到了ubuntu,ubuntu下之前并没有发现什么难的地方,只要百度一般都有解决方案.但是总所周知ubuntu是一系列开源软件的集合,由于版本的问题 ...
- ubuntu 14.04 中安装R和Rstudio
1. 安装R 1.1 首先添加镜像源 sudo gedit /etc/apt/sources.list # 加入新镜像源: deb http://cran.rstudio.com/bin/linux/ ...
随机推荐
- Recurrent Neural Network系列1--RNN(循环神经网络)概述
作者:zhbzz2007 出处:http://www.cnblogs.com/zhbzz2007 欢迎转载,也请保留这段声明.谢谢! 本文翻译自 RECURRENT NEURAL NETWORKS T ...
- 在PowerShell中使用curl(Invoke-WebRequest)
前言 习惯了windows的界面模式就很难转去命令行,甚至以命令行发家的git也涌现出各种界面tool.然而命令行真的会比界面快的多,如果你是一个码农. situation:接到需求分析bug,需要访 ...
- 如何一步一步用DDD设计一个电商网站(二)—— 项目架构
阅读目录 前言 六边形架构 终于开始建项目了 DDD中的3个臭皮匠 CQRS(Command Query Responsibility Segregation) 结语 一.前言 上一篇我们讲了DDD的 ...
- “.Net 社区虚拟大会”(dotnetConf) 2016 Day 2 Keynote: Miguel de Icaza
美国时间 6月7日--9日,为期三天的微软.NET社区虚拟大会正式在 Channel9 上召开,美国时间6.8 是第二天, Miguel de Icaza 做Keynote,Miguel 在波士顿Xa ...
- AFNetworking 3.0 源码解读(八)之 AFImageDownloader
AFImageDownloader 这个类对写DownloadManager有很大的借鉴意义.在平时的开发中,当我们使用UIImageView加载一个网络上的图片时,其原理就是把图片下载下来,然后再赋 ...
- .Net Core上用于代替System.Drawing的类库
目前.Net Core上没有System.Drawing这个类库,想要在.Net Core上处理图片得另辟蹊径. 微软给出了将来取代System.Drawing的方案,偏向于使用一个单独的服务端进行各 ...
- Web安全相关(四):过多发布(Over Posting)
简介 过多发布的内容相对比较简单,因此,我只打算把原文中的一些关键信息翻译一下.原文链接如下: http://www.asp.net/mvc/overview/getting-started/gett ...
- iOS有关横向TableView的东西
之前看到Apple store里面有横向的tableview,当然也有可能是collectionview啦. 尤其是项目中只有一条那么需要横向滑动的东西,就没有必要使用庞大的collectionvie ...
- CSS知识总结(九)
CSS常用样式 10.自定义动画 1)关键帧(keyframes) 被称为关键帧,其类似于Flash中的关键帧. 在CSS3中其主要以“@keyframes”开头,后面紧跟着是动画名称加上一对花括号“ ...
- BPM体系文件管理解决方案分享
一.方案概述 企业管理在很大程度上是通过文件化的形式表现出来,体系文件管理是管理体系存在的基础和证据,是规范企业管理活动和全体人员行为,达到管理目标的管理依据.对与公司质量.环境.职业健康安全等体系有 ...