es 安装
<!doctype html>es安装
elasticsearch按照
- https://elasticsearch.cn/download/找到对应的版本
- 解压并进入到bin内编辑 elasticsearch.yml
#network.host: 192.168.0.1
改为network.host: 0.0.0.0
- 修改jvm.options
-Xms1g -Xmx1g
改为-Xms128m -Xmx128m
最大堆内存 - 编辑/etc/sysctl.conf 添加配置
vm.max_map_count=262144
sysctl -p
执行命令
然后在到bin目录下,执行下面
# 进入bin目录
cd /soft/elsearch/bin
# 后台启动
./elasticsearch -d
启动成功后,访问下面的URL
http://202.193.56.222:9200/
如果出现了下面的信息,就表示已经成功启动了
如果你在启动的时候,遇到过问题,那么请参考下面的错误分析~
错误分析
错误情况1
如果出现下面的错误信息
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /soft/elsearch/logs/elasticsearch.log
[root@e588039bc613 bin]# 2020-09-22 02:59:39,537121 UTC [536] ERROR CLogger.cc@310 Cannot log to named pipe /tmp/elasticsearch-5834501324803693929/controller_log_381 as it could not be opened for writing
2020-09-22 02:59:39,537263 UTC [536] INFO Main.cc@103 Parent process died - ML controller exiting
就说明你没有切换成 elsearch用户,因为不能使用root操作es
su - elsearch
错误情况2
[1]:max file descriptors [4096] for elasticsearch process is too low, increase to at least[65536]
解决方法:切换到root用户,编辑limits.conf添加如下内容
切记要重新登录才能配置奏效
vi /etc/security/limits.conf
# ElasticSearch添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
错误情况3
[2]: max number of threads [1024] for user [elsearch] is too low, increase to at least
[4096]
也就是最大线程数设置的太低了,需要改成4096
#解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
#修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 4096
错误情况4
[3]: system call filters failed to install; check the logs and fix your configuration
or disable system call filters at your own risk
解决:Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true
vim config/elasticsearch.yml
# 添加
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
错误情况5
[elsearch@e588039bc613 bin]$ Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.AccessDeniedException: /soft/elsearch/config/elasticsearch.keystore
Likely root cause: java.nio.file.AccessDeniedException: /soft/elsearch/config/elasticsearch.keystore
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
at java.base/java.nio.file.Files.newByteChannel(Files.java:375)
at java.base/java.nio.file.Files.newByteChannel(Files.java:426)
at org.apache.lucene.store.SimpleFSDirectory.openInput(SimpleFSDirectory.java:79)
at org.elasticsearch.common.settings.KeyStoreWrapper.load(KeyStoreWrapper.java:220)
at org.elasticsearch.bootstrap.Bootstrap.loadSecureSettings(Bootstrap.java:240)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
我们通过排查,发现是因为 /soft/elsearch/config/elasticsearch.keystore 存在问题
也就是说该文件还是所属于root用户,而我们使用elsearch用户无法操作,所以需要把它变成elsearch
chown elsearch:elsearch elasticsearch.keystore
错误情况6
[1]: 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
ERROR: Elasticsearch did not exit normally - check the logs at /soft/elsearch/logs/elasticsearch.log
继续修改配置 elasticsearch.yaml
# 取消注释,并保留一个节点
node.name: node-1
cluster.initial_master_nodes: ["node-1"]