码迷,mamicode.com
首页 > 其他好文 > 详细

ELK----安装脚本

时间:2020-11-16 13:05:56      阅读:5      评论:0      收藏:0      [点我收藏+]

标签:tst   elk   rpm -ivh   插件   添加   reload   app   开启   pre   

ELK----安装

#!/bin/bash
######部署elasticsearch软件####
yum install -y expect
mkdir /abc
/usr/bin/expect<<-EOF
 spawn mount.cifs //192.168.1.150/redhat7 /abc
 expect "*redhat7*" {send "123456\r"}
expect eof
EOF
#1.安装elasticsearch—rpm包
cd /abc/elk
rpm -ivh elasticsearch-5.5.0.rpm

#2加载系统服务
systemctl daemon-reload    
systemctl enable elasticsearch.service

#3.更改elasticsearch主配置文件
cp -p /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.bak

sed -i -e ‘17s/my-application/my-elk-cluster/g‘ -e ‘17s/^#//g‘ /etc/elasticsearch/elasticsearch.yml
sed -i -e ‘23s/node-1/node1/g‘ -e ‘23s/^#//g‘ /etc/elasticsearch/elasticsearch.yml
sed -i -e ‘33s#/path/to/data#/data/elk_data/#g‘ -e ‘33s/^#//g‘  /etc/elasticsearch/elasticsearch.yml
sed -i -e ‘37s#/path/to/logs#/var/log/elasticsearch/#g‘ -e ‘37s/^#//g‘ /etc/elasticsearch/elasticsearch.yml
sed -i -e ‘43s#true#false#g‘ -e ‘43s/^#//g‘ /etc/elasticsearch/elasticsearch.yml
sed -i -e ‘55s#192.168.0.1#0.0.0.0#g‘ -e ‘55s/^#//g‘ /etc/elasticsearch/elasticsearch.yml
sed -i -e ‘59s/#//‘ /etc/elasticsearch/elasticsearch.yml
sed -i -e ‘68s#host1#node1#g‘  -e ‘68s#host2#node2#g‘ -e ‘68s/^#//g‘ /etc/elasticsearch/elasticsearch.yml

#4.创建数据存放路径并授权
mkdir -p /data/elk_data
chown elasticsearch:elasticsearch /data/elk_data/

#5.启动elasticsearch是否成功开启
systemctl start elasticsearch.service
systemctl enable elasticsearch.service 
netstat -natp | grep 9200    

#####部署elasticsearch-head插件(node1和node2都需要安装)#
#安装编译工具
yum install gcc gcc-c++ make -y
cd /abc/elk
tar xzvf node-v8.2.1.tar.gz -C /opt
cd /opt/node-v8.2.1/
./configure 
make -j4
make install

#安装phantomjs(前段框架显示)#
cd /abc/elk
tar xjvf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/src
cd /usr/local/src
cd phantomjs-2.1.1-linux-x86_64/bin
cp phantomjs /usr/local/bin

#安装elasticsearch-head(支持插件视图化管理集群)###
cd /abc/elk
tar xzvf elasticsearch-head.tar.gz -C /usr/local/src
cd /usr/local/src/
cd elasticsearch-head/
npm install

#修改主配置文件,添加两行
sed -i ‘$ahttp.cors.enabled: true\nhttp.cors.allow-origin: "*"‘ /etc/elasticsearch/elasticsearch.yml
#启动elasticsearch-head
cd /usr/local/src/elasticsearch-head/
echo "

" | npm run start &
sleep 5
netstat -lnupt | grep 9100
netstat -lnupt | grep 9200

ELK----安装脚本

标签:tst   elk   rpm -ivh   插件   添加   reload   app   开启   pre   

原文地址:https://blog.51cto.com/14625831/2547722

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!