搭建单机版es
1.如何安装Elasticsearch ?
贴上下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch
es的安装需要在非root用户下进行,这也是es为了提高安全。
2. 创建非root用户及对应的用户组:
# 以root用户来创建新的用户组和用户,
# groupadd 添加一个用户组
[root@localhost home]# groupadd elk
# 添加一个用户,-g是在用户组下 -p是密码
[root@localhost home]# useradd elk -g elk -p elk
备注:
- 只有在root用户下,才有权限创建其他用户,并授权
- 切换用户:su root 或 su elk然后为了方便管理数据与日志我们可以在es的上一级目录下建立俩个文件夹来管理es的日志与数据
mkdir esdata
mkdir eslogs
3.然后为了方便管理数据与日志我们可以在es的上一级目录下建立俩个文件夹来管理es的日志与数据
建立后的目录位置为:
/usr/local/program/elasticsearch/esdata
/usr/local/program/elasticsearch/eslogs
4.然后再es的配置文件目录下 找到Elasticsearch.yml vim进行编辑 修改如下信息
bootstrap的那俩个配置如若不存在请自行填写
node.name: xjc-es-node-1
path.data: /usr/local/program/elasticsearch-7.4.2/esdata
path.logs: /usr/local/program/elasticsearch-7.4.2/eslogs
network.host: 0.0.0.0
http.port: 9200
#cluster.initial_master_nodes: ["node-1"]
discovery.type: single-node
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
备注:
- 如果是单机版必须加discovery.type: single-node,集群则是cluster.initial_master_nodes: [“node-1”],不然会报错
- xpack是加密的,如果不需要则删除
5.在启动前我们讲es的安装目录以及创建的存储目录及日志目录 全部改为我们创建的用户组 ,命令
chmod —R
创建的用户组:创建的用户组 要改变的目录
示例: chmod -R elk:elk elasticsearch
- 正常启动(非后台,为看当时报错信息或日志):
./elasticsearch
- 后台启动
./elasticsearch -d
- nohup 启动(会生成nohup.out也可以查看报错信息佛日志)
nohup ./elasticsearch &
-----------------------------------------------------------部署报错区域---------------------------------------------------------
接下来我们一一解决报错信息:
报错:
ERROR: bootstrap checks failed
system call filters failed to inour configuration or disabstall; check the logs and fix yle system call filters at your own risk
原因:
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。
解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
报错:
[WARN ][o.e.b.JNANatives ] unable to install syscall filter:
原因:
报了一大串错误,大家不必惊慌,其实只是一个警告,主要是因为你Linux版本过低造成的
解决:
1、重新安装新版本的Linux系统
2、警告不影响使用,可以忽略
报错:
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
原因:
无法创建本地文件问题,用户最大可创建文件数太小
解决:
切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
备注:* 代表Linux所有用户名称(比如 hadoop)
保存、退出、重新登录才可生效
报错:
max number of threads [1024] for user [es] likely too low, increase to at least [2048]
原因:
无法创建本地线程问题,用户最大可创建线程数太小
解决:
切换到root用户,进入limits.d目录下,修改90-nproc.conf 配置文件。
vi /etc/security/limits.d/90-nproc.conf
找到如下内容:
* soft nproc 1024
修改为
* soft nproc 2048
报错:
max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因:
最大虚拟内存太小
解决:
切换到root用户下,修改配置文件sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后重新启动elasticsearch,即可启动成功。
报错:
org.elasticsearch.transport.RemoteTransportException: Failed to deserialize exception response from stream
原因:
ElasticSearch节点之间的jdk版本不一致
解决:
ElasticSearch集群统一jdk环境 es5.4的jdk必须是8
报错:
Unsupported major.minor version 52.0
原因:
jdk版本问题太低
解决:
更换jdk版本,ElasticSearch5.0.0支持jdk1.8.0
报错:
bin/elasticsearch-plugin install license
ERROR: Unknown plugin license
原因:
ElasticSearch5.0.0以后插件命令已经改变
解决:
使用最新命令安装所有插件
bin/elasticsearch-plugin install x-pack
报错:
ElasticSearch启动找不到主机或路由
原因:
ElasticSearch 单播配置有问题
解决:
检查ElasticSearch中的配置文件
vi config/elasticsearch.yml
找到如下配置:
discovery.zen.ping.unicast.hosts:["192.168.**.**:9300","192.168.**.**:9300"]
一般情况下,是这里配置有问题,注意书写格式
一部分借鉴于浪老猫
原地址:https://blog.csdn.net/ProGram_BlackCat/article/details/80446616?spm=1001.2014.3001.5501
以上内容都由网络学习而来,如有侵权,请及时联系