天天看点

elasticsearch+kibana安装,及报错处理

下载elasticsearch、kibana,elasticsearch与kibana版本必须一致

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz
https://artifacts.elastic.co/downloads/kibana/kibana-7.5.0-linux-x86_64.tar.gz      

接下来就是解压安装:

安装elasticsearch:

1、直接tar -xvzf 解压即可

2、修改配置

#vim /usr/local/elasticsearch-7.5.0/config/elasticsearch.yml
cluster.initial_master_nodes: ["node-1"]
network.host: 0.0.0.0
gateway.recover_after_nodes: 1   # 只要指定数量的节点加入集群,就开始进行恢复;默认是3,现在只有一台机器,所以改为1

#vim /usr/local/elasticsearch-7.5.0/config/jvm.options
-Xms512m
-Xmx512m      

3、创建启动用户,并启动

elasticsearch新版本安全策略提升,不允许使用root用户启动

groupadd elasticsearch
useradd elasticsearch -g elasticsearch
chown -R elasticsearch:elasticsearch elasticsearch-7.5.0/*
su elasticsearch
./elasticsearch &      
elasticsearch+kibana安装,及报错处理

报错总结:

1、内存不足

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000ca660000, 899284992, 0) failed; error='Cannot allocate memory' (errno=12)      

清理一下内存,重新配置-Xms512m 和-Xmx512m,只是测试无须太大内存,默认是1g,改成512,甚至256m也行

2、Caused by: java.lang.RuntimeException: can not run elasticsearch as root

elastic 新版本后,安全策略提升,不允许使用root用户启动

创建elastic启动用户

3、future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_333/jre] does not meet this requirement

elastic需要 java11版本的jdk,系统安装了jdk 1.8,并且配置了JAVA_HOME环境变量

elastic 7.2后,自带了jdk,不需要另外安装,如果指定了JAVA_HOME则会使用自己配置的

jdk

4、ERROR: [2] bootstrap checks failed

[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

第一个报错:elasticsearch用户拥有的内存权限太小,至少需要262144

临时修改
  切换到root用户
  执行命令:
  sysctl -w vm.max_map_count=262144
永久修改
  在/etc/sysctl.conf文件最后添加一行
  vm.max_map_count=262144      

第二个报错:elasticsearch配置中必须配置[discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] 三者中的一个,这里配置了:

cluster.initial_master_nodes: ["node-1"]      

kibana安装:

1、tar解压

2、配置

#vim /usr/local/kibana-7.5.0/config/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
server.name: "yrq"
elasticsearch.hosts: ["http://localhost:9200/"]  # elastic的地址      

3、kibana默认也不能使用root启动

但是,可以带参数,运行root启动

Kibana should not be run as root.  Use --allow-root to continue.      

创建启动用户

useradd kibana -g elasticsearch
chown -R kibana:elasticsearch kibana-7.5.0/
su kibana
./kibana &      
elasticsearch+kibana安装,及报错处理

报错总结:

1、License information could not be obtained from Elasticsearch for the [data] cluster. Error: No Living connections

[warning][migrations] Unable to connect to Elasticsearch. Error: No Living connections

[warning][admin][elasticsearch] Unable to revive connection: http://localhost:9200/

连接不上elasticsearch:

排除法:

1、是否网络策略限制

2、防火墙、selinux是否关闭

3、iptables规则

4、kibana指定elastisearch是否正确

最后几点都排除了,发现是elasticsearch有个配置没配,gateway.recover_after_nodes: 1,需要将这个字段配置为1