Centos7 安装Elasticsearch 7.1.1
环境
Centos7
JDK1.8
Elasticsearch 7.1.1
准备工作
Elasticsearch 需要JDK环境,需要首先安装JDK
Elasticsearch7.1.1下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz
可以自行去elasticsearch官网下载
下面开始安装
我是去官网下载的,服务器实在太慢:
你也可以使用:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz
下载
解压:tar -xzvf elasticsearch-7.1.1-linux-x86_64.tar.gz
新建用户
elasticsearch 不允许以 root 权限来运行!所以需要创建一个非root用户,以非root用户来起es
#创建用户组es
groupadd es
#创建新用户es,设置用户组为es,密码es
useradd es -g es -p es
#授权,更改elasticsearch-7.1.1文件夹所属用户及用户组为es:es
chown -R es:es elasticsearch-7.1.1
#切换用户es
su es
修改配置
1、调整jvm内存大小(机器内存够也可不调整)
vi elasticsearch-7.1.1/config/jvm.options
#修改如下配置
-Xms512m
-Xmx512m
2、修改network配置,支持通过ip访问
vi elasticsearch-7.1.1/config/elasticsearch.yml
#修改如下配置
network.host: 0.0.0.0
http.port: 9200
3、修改初始主节点
vi elasticsearch-7.1.1/config/elasticsearch.yml
#修改如下配置
cluster.initial_master_nodes: ["node-1"]
启动
#启动命令
.elasticsearch-7.1.1/bin/elasticsearch
#后台启动命令
.elasticsearch-7.1.1/bin/elasticsearch -d
#设置开机自启动
systemctl enable elasticsearch.service
至此 普通的安装过程就完成了,然而现实非常残酷:启动失败了
先解决
第一个问题:
[2019-12-19T10:42:38,574][WARN ][o.e.b.Natives ] unable to load JNA native support library, native methods will be disabled.
解决:
在elasticsearch的安装目录的lib下直接下载需要的JNA jar包
Wget http://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar
网上又说在bin目录下下载,事实证明错误的。
第二个问题:
ElasticsearchException[X-Pack is not supported and Machine Learning is not available for [windows-x86]; you can use the other X-Pack features (unsupported) by setting xpack.ml.enabled: false in elasticsearch.yml]
解决:在config/elasticsearch.yml添加一条配置:xpack.ml.enabled: false
第三个问题(具体错误信息找不到了,这是我在网上搜的解决办法,有效哦):
ES6在centOS系统启动,报错:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
原因: 因为Centos6不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动解决:修改elasticsearch.yml 添加一下内容 :
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
第四个问题:
- : max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
切换到root用户,编辑limits.conf添加如下内容
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
Limits.conf 修改后需要重启服务才能生效,重启:shutdown -r now 立刻重启(root用户使用)
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144
vi /etc/sysctl.conf
sysctl -p
更多的类似错误 可以参考:https://www.jianshu.com/p/2285f1f8ec21
curl http://127.0.0.1:9200
{
"name" : "localhost",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "_na_",
"version" : {
"number" : "7.1.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "7a013de",
"build_date" : "2019-05-23T14:04:00.380842Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
看到以上信息表示安装成功
接下在看一下外网,如果外网不行可以考虑一下防火墙问题(因为我们在elasticsearch.yml中已经配置了外网)。
外网访问测试在浏览器中防火墙开启9200端口命令
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload
还是不行的话就关闭防火墙吧!
systemctl stop firewalld.service
这里贴出我 安装得elasticsearch 得配置文件:
cluster.name: my-application
node.name: node-1
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
xpack.ml.enabled: false
这里得每项配置 几乎都是必要得
Filebeat
下面我在讲一下filebeat得安装过程即遇到得问题:
下载并解压:
地址:https://www.elastic.co/cn/downloads/beats/filebeat
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.0-linux-x86_64.tar.gz
tar zxvf filebeat-7.3.0-linux-x86_64.tar.gz
整个过程并无波澜,这里贴出我得配置文件:
filebeat.inputs:
- type: log
enabled: true
paths:
- /home/webuser/logs/lavion.com/*.log
setup.kibana:
host: "localhost:5601"
output.elasticsearch:
hosts: ["localhost:9200"]
enabled: true
Kibana
# 下载 wget https://artifacts.elastic.co/downloads/kibana/kibana-7.1.1-linux-x86_64.tar.gz
# 解压 tar xvf kibana-7.1.1-linux-x86_64.tar.gz
kibana得安装过程中并无明显错误:
配置文件如下:
server.port: 5601
server.host: "10.1.4.182"/*如果是云主机,server.host改为内网的ip,或者0.0.0.0,就能正常运行*/
server.name: "kibana-test"
elasticsearch.hosts: ["http://localhost:9200"]
kibana.index: ".kibana"
i18n.locale: "zh-CN"