下载内容
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
安装最新版es报错
报错内容如下:
01 解析地址错误centos8
wget: 无法解析主机地址 “artifacts.elastic.co
解决办法,添加解析的,修改resolv.conf
[root@localhost etc]# cat resolv.conf
# Generated by NetworkManager
[root@localhost etc]# vi resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4
02 权限报错,不能使用root用户
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
创建用户,赋权限,并切换用户
[root@localhost bin]# useradd es
[root@localhost bin]# passwd es
授权
[root@localhost bin]# chmod -R 777 /usr/local/apps/elasticsearch-7.6.2
输入自己的密码,切换用户
[root@localhost bin]# su es
启动报错,权限问题(jdk版本,问题可以看要求的jdk版本:https://www.elastic.co/cn/support/matrix#matrix_jvm )product and jvm 说明部分
[es@localhost bin]$ ./elasticsearch
future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/apps/jdk1.8.0_231/jre] does not meet this requirement
Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/apps/elasticsearch-7.6.2/config/jvm.options
xpack.ml.enabled: false 未设置【报错内容告诉你了】
[2020-04-03T11:46:40,903][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [localhost.localdomain] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: ElasticsearchException[Failure running machine learning native code. This could be due to running on an unsupported OS or distribution, missing OS libraries, or a problem with the temp directory. To bypass this problem by running Elasticsearch without machine learning functionality set [xpack.ml.enabled: false].]
编辑config 下的文件
[es@localhost bin]$ cd ../config
[es@localhost config]$ vi elasticsearch.yml
xpack.ml.enabled: false
顺便修改一下端口,网络主机,服务发现地址,服务名称什么的
http.port: 9200
network.host: 192.168.23.13
discovery.seed_hosts: ["192.168.23.13"]
cluster.name: es_search
如果没注意,把空格去掉了就会报错 cluster.name:es_search 【报错】 cluster.name: es_search 【正确】
意思是说没找到value (空格bug哈)
SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but found [VALUE_STRING]];
没完,接着报错,按照推荐的数据修改配置文件
[2020-04-03T12:11:53,705][INFO ][o.e.b.BootstrapChecks ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3069] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
参考博文:https://www.cnblogs.com/zhi-leaf/p/8484337.html
切回到root用户
[es@localhost bin]$ su root
修改配置文件(/etc/security/limits.conf 和 /etc/sysctl.conf)
添加limits.conf【是有星号的】
[root@localhost bin]# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
[root@localhost bin]# vi /etc/sysctl.conf
vm.max_map_count=262144
生效
[root@localhost bin]# sysctl -p
切回新增加的用户启动
[root@localhost bin]# su es
[es@localhost bin]$ ./elasticsearch
访问是否成功
集群版修改一下 discovery.seed_hosts,列出其他虚拟机上的ip地址
discovery.seed_hosts: ["192.168.23.12","192.168.23.13","192.168.23.14"]
#discovery.seed_hosts: ["192.168.23.12"]