linux 装elasticsearch 6.5.4 加 kibana

环境: centos7.0

创建用户

从5.0开始,ElasticSearch 安全级别提高了,不允许采用root帐号启动,所以我们要添加一个用户

 

1 创建 elasticsearch 用户组

1

[root@localhost ~]# groupadd elasticsearch

2 创建用户 es 并设置密码为es

1

2

[root@localhost ~]# useradd es

[root@localhost ~]# passwd es

3 用户es 添加到 elasticsearch 用户组

1

[root@localhost ~]# usermod -G elasticsearch es

4 设置sudo权限

1

[root@localhost ~]# visudo

1

2

3

4

5

在root ALL=(ALL) ALL 一行下面

添加es用户 如下:

es ALL=(ALL) ALL

 

添加成功保存后切换到es用户操作

1

2

[root@localhost ~]# su es

[es@localhost root]$

  

安装:

1、下载:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.tar.gz

2、解压到:/usr/local

3、添加权限:chown -R es elasticsearch-6.5.4

4、修改配置文件(先切换到root)

  1)进入/usr/local/elasticsearch-6.5.4/config目录,使用vi编辑器:vi elasticsearch.yml(注:冒号前面不能有空格,后面必须有一个空格)
  2)取消如下注释,并修改为当前主机地址:
    cluster.name: my-application
    node.name: node-1
    bootstrap.memory_lock: false
    network.host: 192.168.40.132
    http.port: 9200
    discovery.zen.ping.unicast.hosts: ["192.168.40.132"]
    discovery.zen.minimum_master_nodes: 1 #注意,因为本人目前是单节点,这里必须为1
  3)新增如下配置:
    transport.tcp.port: 9300
    transport.tcp.compress: true
    bootstrap.system_call_filter: false
  4)使用vi编辑器,修改/etc/sysctl.conf文件,添加如下代码(若无将会出现下面常见问题2):
    vm.max_map_count=262144
  5)退出保存后执行如下命令:
    sysctl -p
  6)使用vi编辑器,修改/etc/security/limits.conf文件,在文件末尾添加如下代码(若无将会出现下面常见问题3):
    # esuser为登录服务器的用户名
    esuser soft nofile 65536
    esuser hard nofile 65536
    esuser soft nproc  4096
    esuser hard nproc  4096

5、启动Elasticsearch

  1)切换用户
    su es
  2)查看当前用户
    who am i
  3)启动服务
    elasticsearch-6.5.4/bin/elasticsearch
  4)后台启动
    elasticsearch-6.5.4/bin/elasticsearch -d
  5)测试是否启动成功
    curl -XGET 'http://192.168.40.132:9200/'

远程访问失败:关闭系统防火墙

>>>关闭防火墙

systemctl stop firewalld.service            #停止firewall
systemctl disable firewalld.service        #禁止firewall开机启动

>>>开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

-----------------------------------------------------------------------------------------------------------------------------------------------

启动的时候报错了:

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

原因是下面这一步,es用户下使用,sudo vim 编辑,保存成功了,但是启动一直报错,后来切换到root编辑保存,再切换回es用户,启动就ok了 !!!

6)使用vi编辑器,修改/etc/security/limits.conf文件,在文件末尾添加如下代码(若无将会出现下面常见问题3):
    # esuser为登录服务器的用户名
    esuser soft nofile 65536
    esuser hard nofile 65536
    esuser soft nproc  4096
    esuser hard nproc  4096

参考:https://www.cnblogs.com/fengzmh/p/9964591.html

 

------------------------------------------------------------------------------------------------------------------------

开机启动配置

切换到root:

cd /etc/init.d

创建文件:elasticsearch

#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
 
export JAVA_HOME=/usr/java/jdk1.8.0_211
export JAVA_BIN=/usr/java/jdk1.8.0_211/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
 
case "$1" in
start)
su es<<!
cd /usr/local/elasticsearch-6.5.4
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
stop)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
;;
restart)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
su zhangxing<<!
cd /usr/local/elasticsearch-6.5.4
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?

jdk 、elasticsearch 修改为本机环境

su es<<!   这里的es 是 启动用户

注:前两行必须填写,且要注释掉。

    第一行为shell前行代码,目的告诉系统使用shell。

    第二行分别代表运行级别、启动优先权、关闭优先权,且后面添加开机服务会用到。

   

保存退出,并在/etc/init.d/下赋予执行权限

chmod +x elasticsearch

添加到开机启动任务

chkconfig --add elasticsearch

reboot 开机重启,ok

 

安装ElasticSearch的Head插件

1、下载插件

cd /usr/local/elasticsearch

git clone https://github.com/mobz/elasticsearch-head.git

cd elasticsearch-head

2、安装node  npm

3、使用npm安装grunt和grunt-cli

npm install -g grunt

npm install -g grunt-cli

查看:grunt -version

4、cd elasticserch-head

      npm install

     中间报了个错: npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression

     解决方式参考:https://www.cnblogs.com/shengulong/p/6224908.html

     vi  package.json    修改 :"license": "Apache2" 为 "license": "Apache-2.0",  如下图,需要这里有版本对应

      https://spdx.org/licenses/ 

5、修改配置:

     elasticserch的config目录,修改elasticsearch.yml文件.在文件的末尾加入以下代码

    

http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true

  修改  network.host:0.0.0.0   

   \elasticsearch-head\Gruntfile.js 在对应的位置加上hostname:'*' ,主要不要漏了“,”

 

5、启动: grunt server  或者  npm run start

ok了

 

 

kibana-6.5.4-linux-x86_64安装配置

去产品官网下载https://www.elastic.co/downloads/kibana 对应的tar.gz的压缩包

解压到 /usr/local/kibana-6.5.4-linux-x86_64

cd /usr/local/kibana-6.5.4-linux-x86_64/config

vi kibana.yml

   server.port:5601
   server.host:"192.168.20.7"
   elasticsearch.url:"192.168.20.7:9200"
   kibana.index: ".kibana"

保存退出。

启动:进入bin目录启动:./kibana
          或者守护进程启动:nohup ./kibana &
验证: 远程浏览器:http://192.168.20.7:5601

 

logstash6.5.4安装配置

下载 :

wget https://artifacts.elastic.co/downloads/logstash/logstash-5.5.0.zip

解压:unzip解压到 /urs/local/logshtash

启动: cd bin
           ./logstash -e 'input { stdin { } } output { stdout {} }'

看到这个就成功了,输入个hello world 会有返回

上述脚本启动一个logstash 实例,从标准输入接收数据,不经过任何处理在标准输出打印,可以看见logstash 默认额外的补充了时间戳信息和主机信息。

小技巧
使用 -t 测试配置文件是否有错误

./bin/logstash -t -f ./conf.d/test.conf 

如果没有错误应该是这样的

Sending Logstash logs to /usr/local/logstash/logs which is now configured via log4j2.properties
[2018-11-26T09:54:53,868][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
Configuration OK
[2018-11-26T09:54:58,014][INFO ][logstash.runner          ] Using config.test_and_exit mode. Config Validation Result: OK. Exiting Logstash

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值