官方文档地址https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html
一步一坑!我们一点点往下看
1.打开操作系统输入以下步骤
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-linux-x86_64.tar.gz.sha512
2.输入
shasum -a 512 -c elasticsearch-7.12.1-linux-x86_64.tar.gz.sha512
可能会报错:-bash: shasum: command not found
尝试输入:yum install perl-Digest-SHA
成功
继续输入
tar -xzf elasticsearch-7.12.1-linux-x86_64.tar.gz
cd elasticsearch-7.12.1/
shasum -a 512 -c elasticsearch-7.12.1-linux-x86_64.tar.gz.sha512 这句话的目的是,比较下载的.tar.gz归档文件的SHA和发布的校验和,它们应输出elasticsearch- {version} -linux-x86_64.tar.gz是不是没问题
3.修改yml文件
在yml文件中加上一行
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*
配置为自动创建索引
尝试启动es 使用命令:
./bin/elasticsearch
报错:
usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_131/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_131/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
/root/elasticsearch-7.12.1/modules/x-pack-ml/platform/linux-x86_64/bin/controller: /lib64/libz.so.1: no version information available (required by /root/elasticsearch-7.12.1/modules/x-pack-ml/platform/linux-x86_64/bin/../lib/./libxml2.so.2)
[2021-05-18T17:32:52,297][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [iZ25uy81pzaZ] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.12.1.jar:7.12.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.12.1.jar:7.12.1]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75) ~[elasticsearch-7.12.1.jar:7.12.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116) ~[elasticsearch-cli-7.12.1.jar:7.12.1]
at org.elasticsearch.cli.Command.main(Command.java:79) ~[elasticsearch-cli-7.12.1.jar:7.12.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.12.1.jar:7.12.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81) ~[elasticsearch-7.12.1.jar:7.12.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:101) ~[elasticsearch-7.12.1.jar:7.12.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:168) ~[elasticsearch-7.12.1.jar:7.12.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:397) ~[elasticsearch-7.12.1.jar:7.12.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.12.1.jar:7.12.1]
... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:101)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:168)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:397)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116)
at org.elasticsearch.cli.Command.main(Command.java:79)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81)
For complete error details, refer to the log at /root/elasticsearch-7.12.1/logs/elasticsearch.log
2021-05-18 09:32:52,683756 UTC [25347] INFO Main.cc@106 Parent process died - ML controller exiting
我们去官方查看文档发现:
官方文档写了
https://www.elastic.co/guide/en/elasticsearch/reference/7.9/modules-scripting-security.html
永远不要以root用户身份运行Elasticsearch。哎。。。。
创建用户els
groupadd els
useradd els -g els
passwd els
chown -R els:els /root //注意我这里用户组权限设置为root 是因为root文件夹下面有es文件夹。这里看你自己的服务器配置才可以的
再次尝试启动es,
./bin/elasticsearch
这里注意,java1.8不太行了。。。。推荐java11
果然不顺利报错: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
尝试解决方案:在slasticsearch.yml文件里添加
bootstrap.system_call_filter: false
依然是一堆警告
尝试通过浏览器链接一下地址端口9200
报错:Error: Request timed out 说明启动失败
看样子是对外public_address 问题 尝试修正一下yml文件中设置一下
network:
publish_host: 0.0.0.0
启动失败
ERROR: [2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch.
bootstrap check failure [1] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
bootstrap check failure [2] of [2]: 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
重新修改配置
If you want to set this permanently, you need to edit /etc/sysctl.conf
and set vm.max_map_count
to 262144.
When the host reboots, you can verify that the setting is still correct by running sysctl vm.max_map_count
修改配置文件/etc/sysctl.conf vm.max_map_count
to 262144.
配置yml文件
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*
#相对于错误 requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in然后修改下面这句话用
bootstrap.system_call_filter: false
#设置IP访问es 暂时不限制外网访问 和单节点问题,不设置集群,不然会报错的
network:
publish_host: 0.0.0.0
discovery.type: single-node
再重启
还是超时
尝试修改一下network.host 如下配置,还是超时
最终用程序链接
程序好用了。但是浏览器依然不可以。哎……先写到这吧。。心累了。反正肯定安装成功。
后续:防火墙配置端口9200
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 9200 -j ACCEPT
就可以了之前是: