安装es7总结步骤及问题解决方案:CentOS7安装elasticsearch-7.8.1
下载、配置、启动、终止
下载elasticsearch-7.8.1安装包、解压、创建data文件夹:
[sirxy@localhost ~]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.1-linux-x86_64.tar.gz
[sirxy@localhost ~]$ tar -zxvf elasticsearch-7.8.1-linux-x86_64.tar.gz
[sirxy@localhost ~]$ cd elasticsearch-7.8.1
[sirxy@localhost elasticsearch-7.8.1]$ mkdir data
编辑配置:
[sirxy@localhost elasticsearch-7.8.1]$ vim config/elasticsearch.yml
cluster.name: my-cluster #集群名称
node.name: node-1 #节点名称
#数据和日志的存储目录
path.data: /home/sirxy/elasticsearch-7.8.1/data
path.logs: /home/sirxy/elasticsearch-7.8.1/logs
network.host: 0.0.0.0
http.port: 9200 #端口
cluster.initial_master_nodes: ["node-1"]
# elasticsearch-head连接时,防止跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
启动(注意不能用root用户启动):
[sirxy@localhost elasticsearch-7.8.1]$ ./bin/elasticsearch
查看进程号:
[sirxy@localhost elasticsearch-7.8.1]$ jps | grep Elasticsearch
终止进程号:
[sirxy@localhost elasticsearch-7.8.1]$ kill -9 进程号
启动时可能碰到的问题:
问题:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方法:
#切换到root用户修改
vim /etc/security/limits.conf
# 在最后面追加下面内容
* hard nofile 65536
* soft nofile 65536
修改后重新登录 sirxy
用户,使用如下命令查看是否修改成功
ulimit -Hn
65536
问题:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法 提高vm.max_map_count 的大小
# 切换到root用户
vim /etc/sysctl.conf
# 在最后面追加下面内容
vm.max_map_count=262144
# 使用 sysctl -p 查看修改后的结果
sysctl -p
以上。
-------------------------- 2022-03-09 补 -------------------
问题:
[sirxy@localhost elasticsearch-7.8.1]$ ./bin/elasticsearch
future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_151/jre] does not meet this requirement
future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_151/jre] does not meet this requirement
2022-03-09 09:12:45,757 main ERROR Unable to create file /home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster_server.json java.io.IOException: No space left on device
......略
2022-03-09 09:12:45,761 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@7cd5fcf4] unable to create manager for [/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster_server.json] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@19cdc217[pattern=/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster-%d{yyyy-MM-dd}-%i.json.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policsirxy=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=ESJsonLayout{patternLayout={"type": "server", "timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss,SSSZZ}", "level": "%p", "component": "%c{1.}", "cluster.name": "${sys:es.logs.cluster_name}", "node.name": "%node_name", "message": "%notEmpty{%enc{%marker}{JSON} }%enc{%.-10000m}{JSON}"%notEmpty{, %node_and_cluster_id }%exceptionAsJson }
}, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@7cd5fcf4] unable to create manager for [/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster_server.json] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@19cdc217[pattern=/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster-%d{yyyy-MM-dd}-%i.json.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policsirxy=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=ESJsonLayout{patternLayout={"type": "server", "timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss,SSSZZ}", "level": "%p", "component": "%c{1.}", "cluster.name": "${sys:es.logs.cluster_name}", "node.name": "%node_name", "message": "%notEmpty{%enc{%marker}{JSON} }%enc{%.-10000m}{JSON}"%notEmpty{, %node_and_cluster_id }%exceptionAsJson }
}, filePermissions=null, fileOwner=null]]
......略
2022-03-09 09:12:45,763 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender
......略
2022-03-09 09:12:45,817 main ERROR Unable to create file /home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster.log java.io.IOException: No space left on device
......略
2022-03-09 09:12:45,817 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@7cd5fcf4] unable to create manager for [/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@d84b3a2[pattern=/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policsirxy=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@7cd5fcf4] unable to create manager for [/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@d84b3a2[pattern=/home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster-%d{yyyy-MM-dd}-%i.log.gz, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policsirxy=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true), SizeBasedTriggeringPolicy(size=134217728)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n, filePermissions=null, fileOwner=null]]
......略
2022-03-09 09:12:45,818 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender
......略
2022-03-09 09:12:45,828 main ERROR Null object returned for RollingFile in Appenders.
2022-03-09 09:12:45,828 main ERROR Null object returned for RollingFile in Appenders.
2022-03-09 09:12:45,829 main ERROR Unable to locate appender "rolling" for logger config "root"
2022-03-09 09:12:45,829 main ERROR Unable to locate appender "rolling_old" for logger config "root"
2022-03-09 01:12:45,879941 UTC [9403] ERROR CNamedPipeFactory.cc@238 Unable to create named pipe /tmp/elasticsearch-3002009858107751420/controller_log_9227: No space left on device
2022-03-09 01:12:45,880020 UTC [9403] ERROR CLogger.cc@311 Cannot log to named pipe /tmp/elasticsearch-3002009858107751420/controller_log_9227 as it could not be opened for writing
2022-03-09 01:12:45,880032 UTC [9403] FATAL Main.cc@106 Could not reconfigure logging
[2022-03-09T09:12:45,889][WARN ][o.e.b.Natives ] [node-1] unable to load JNA native support library, native methods will be disabled.
java.lang.UnsatisfiedLinkError: Failed to create temporary file for /com/sun/jna/linux-x86-64/libjnidispatch.so library: No space left on device
......略
[2022-03-09T09:12:45,893][WARN ][o.e.b.Natives ] [node-1] cannot check if running as root because JNA is not available
[2022-03-09T09:12:45,893][WARN ][o.e.b.Natives ] [node-1] cannot install system call filter because JNA is not available
[2022-03-09T09:12:45,893][WARN ][o.e.b.Natives ] [node-1] cannot register console handler because JNA is not available
[2022-03-09T09:12:45,894][WARN ][o.e.b.Natives ] [node-1] cannot getrlimit RLIMIT_NPROC because JNA is not available
[2022-03-09T09:12:45,894][WARN ][o.e.b.Natives ] [node-1] cannot getrlimit RLIMIT_AS because JNA is not available
[2022-03-09T09:12:45,894][WARN ][o.e.b.Natives ] [node-1] cannot getrlimit RLIMIT_FSIZE because JNA is not available
[2022-03-09T09:12:46,007][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: org.elasticsearch.bootstrap.BootstrapException: java.nio.file.FileSystemException: /tmp/elasticsearch-3002009858107751420/3083273434259894.tmp: No space left on device
......略
Caused by: org.elasticsearch.bootstrap.BootstrapException: java.nio.file.FileSystemException: /tmp/elasticsearch-3002009858107751420/3083273434259894.tmp: No space left on device
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:224) ~[elasticsearch-7.8.1.jar:7.8.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.8.1.jar:7.8.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.8.1.jar:7.8.1]
... 6 more
Caused by: java.nio.file.FileSystemException: /tmp/elasticsearch-3002009858107751420/3083273434259894.tmp: No space left on device
......略
... 6 more
uncaught exception in thread [main]
org.elasticsearch.bootstrap.BootstrapException: java.nio.file.FileSystemException: /tmp/elasticsearch-3002009858107751420/3083273434259894.tmp: No space left on device
Likely root cause: java.nio.file.FileSystemException: /tmp/elasticsearch-3002009858107751420/3083273434259894.tmp: No space left on device
......略
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /home/sirxy/softbag/elasticsearch-7.8.1/logs/my-cluster.log
[sirxy@localhost elasticsearch-7.8.1]$
注意到错误主要原因是由于 /tmp
下 elasticsearch-开头的目录没剩余空间。
解决办法:
# 直接删掉
[root@IPMSS tmp]# rm -rf /tmp/elasticsearch-*
# 重启es
[sirxy@localhost elasticsearch-7.8.1]$ ./bin/elasticsearch -d
# 测试是否启动成功
[sirxy@localhost elasticsearch-7.8.1]# curl http://127.0.0.1:9200
{
"name" : "node-1",
"cluster_name" : "my-cluster",
"cluster_uuid" : "eGRSDqhDRKOW8D7X1jOleA",
"version" : {
"number" : "7.8.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "b5ca9c58fb664ca8bf9e4057fc229b3396bf3a89",
"build_date" : "2020-07-21T16:40:44.668009Z",
"build_snapshot" : false,
"lucene_version" : "8.5.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[sirxy@localhost elasticsearch-7.8.1]#