1,在root用户下
groupadd es useradd es -g es #将创建的用户放到用户组里 mkdir -p /usr/local/es chomn -Rf es:es /usr/local/es [root@web01 es]# ls elasticsearch-7.4.2-linux-x86_64.tar.gz [root@web01 es]# tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz [root@web01 es]# ll total 276M drwxr-xr-x. 3 es es 80 Oct 19 10:11 . drwxr-xr-x. 28 root root 4.0K Oct 19 03:46 .. drwxr-xr-x. 9 root root 154 Oct 29 2019 elasticsearch-7.4.2 -rw-r--r--. 1 root root 276M Oct 19 03:27 elasticsearch-7.4.2-linux-x86_64.tar.gz [root@web01 es]# cd /usr/local/es/elasticsearch-7.4.2/bin/ [root@web01 bin]# ./elasticsearch future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk/jdk1.8.0_231/jre] does not meet this requirement [2021-10-19T10:13:07,510][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [web01] 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.4.2.jar:7.4.2] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.4.2.jar:7.4.2] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.4.2.jar:7.4.2] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.4.2.jar:7.4.2] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.4.2.jar:7.4.2] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.4.2.jar:7.4.2] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.4.2.jar:7.4.2] Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.4.2.jar:7.4.2] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.4.2.jar:7.4.2] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.4.2.jar:7.4.2] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.4.2.jar:7.4.2] ... 6 more [root@web01 bin]# cd .. [root@web01 elasticsearch-7.4.2]# ll total 556K drwxr-xr-x. 9 root root 154 Oct 29 2019 . drwxr-xr-x. 3 es es 80 Oct 19 10:11 .. drwxr-xr-x. 2 root root 4.0K Oct 29 2019 bin drwxr-xr-x. 2 root root 178 Oct 19 10:13 config drwxr-xr-x. 9 root root 107 Oct 29 2019 jdk drwxr-xr-x. 3 root root 4.0K Oct 29 2019 lib -rw-r--r--. 1 root root 14K Oct 29 2019 LICENSE.txt drwxr-xr-x. 2 root root 4.0K Oct 19 10:13 logs drwxr-xr-x. 37 root root 4.0K Oct 29 2019 modules -rw-r--r--. 1 root root 511K Oct 29 2019 NOTICE.txt drwxr-xr-x. 2 root root 6 Oct 29 2019 plugins -rw-r--r--. 1 root root 8.4K Oct 29 2019 README.textile [root@web01 elasticsearch-7.4.2]# cd jdk/ [root@web01 jdk]# pwd /usr/local/es/elasticsearch-7.4.2/jdk #复制下来 [root@web01 jdk]# cd ../bin/ [root@web01 bin]# vim elasticsearch-env
: 保存退出
[root@web01 es]# curl http://127.0.0.1:9200
{
"name" : "web01",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "_na_",
"version" : {
"number" : "7.4.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
"build_date" : "2019-10-28T20:40:44.881551Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[root@web01 config]# pwd /usr/local/es/elasticsearch-7.4.2/config [root@web01 config]# vim /etc/security/limits.conf
[root@web01 config]# vi /etc/sysctl.conf
[root@web01 config]# sysctl -p vm.max_map_count = 262144
:
[root@web01 config]# vi elasticsearch.yml
[root@web01 elasticsearch-7.4.2]# cd /usr/local/es/ [root@web01 es]# chown -Rf es:es /usr/local/es [es@web01 bin]$ ./elasticsearch -d OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.



