Linux 安装 Elasticsearch 7.5
选择需要安装的版本:https://www.elastic.co/cn/downloads/past-releases/
下载:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.7.0-linux-x86_64.tar.gz #解压 tar -xzvf elasticsearch-7.7.0-linux-x86_64.tar.gz #将解压文件夹移动到 /user/local/下,自定义 mv elasticsearch-7.7.0 /user/local/elasticsearch cd /user/local/elasticsearch
执行:
./bin/elasticsearch
这个时候可能会报错,报错信息如下
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future rel [2019-12-17T14:41:57,321][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [iZwz9h3c9q3pzycbcf5jc7Z] uncaught exception in thread org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.5.0.jar:7.5.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.5.0.jar:7.5.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.5.0.jar:7.5.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.5.0.jar:7.5.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.5.0.jar:7.5.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.5.0.jar:7.5.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.5.0.jar:7.5.0] Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.5.0.jar:7.5.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.5.0.jar:7.5.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.5.0.jar:7.5.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.5.0.jar:7.5.0] ... 6 more
修改config下的jvm.options文件
cd config/ vim jvm.options
在文件底部加上
-XX:+AssumeMP
docker参考链接:http://www.fecmall.com/topic/1171
运行:
adduser es #赋予文件夹权限 chown -R es /user/local/elasticsearch/ #切换用户 su es #需先开启防火墙对应端口,elasticsearch默认9200端口 #运行 elasticsearch /usr/local/elasticsearch/bin/elasticsearch -d #-d 在后台以守护进程模式运行
查看:
netstat -lntp
或者运行:
curl 'http://localhost:9200/?pretty'
设置开机运行 转自 https://www.csdn.net/tags/NtjaAgxsMzU1MjQtYmxvZwO0O0OO0O0O.html
vim /lib/systemd/system/elasticsearch.service [Unit] Description=elasticsearch [Service] LimitNOFILE=100000 LimitNPROC=100000 ExecStart=/usr/local/elasticsearch/bin/elasticsearch User=es Group=es [Install] WantedBy=multi-user.target
#给予执行权限 chmod +x /usr/lib/systemd/system/elasticsearch.service #重新加载systemd的守护线程 sudo systemctl daemon-reload systemctl enable elasticsearch