Assuming you have already installed
JDK
, if not, please check this article for Install JDK
1、 Download Elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz
2、 Unzip
tar -xzf elasticsearch-6.4.0.tar.gz
3.、 start up
cd elasticsearch-6.4.0/./bin/elasticsearch
. /bin/elasticsearch -d -p pid
Elasticsearch
will run on the default port 9200
curl localhost:9200
1、 Use a non-root user to start ES, and the user's file permissions are insufficient and the execution is refused
Java HotSpot(TM)64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.[2018-09-01T08:41:24,515][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler][] 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:140)~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127)~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)~[elasticsearch-cli-6.4.0.jar:6.4.0]
at org.elasticsearch.cli.Command.main(Command.java:90)~[elasticsearch-cli-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93)~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86)~[elasticsearch-6.4.0.jar:6.4.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104)~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171)~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326)~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136)~[elasticsearch-6.4.0.jar:6.4.0]...6 more
Solution:
sudo chown -R vagrant:vagrant /var/elasticsearch-6.4.0
Restart
. /bin/elasticsearch -d
Check if it is activated
curl localhost:9200
If the following format is returned, the installation has started successfully
{" name":"iK2w1Zv","cluster_name":"elasticsearch","cluster_uuid":"u8XYlB1ZQACw0b1W0MA0Pw","version":{"number":"6.4.0","build_flavor":"default","build_type":"tar","build_hash":"595516e","build_date":"2018-08-17T23:18:47.308994Z","build_snapshot":false,"lucene_version":"7.4.0","minimum_wire_compatibility_version":"5.6.0","minimum_index_compatibility_version":"5.0.0"},"tagline":"You Know, for Search"}
Find out the process occupying the file:
sudo fuser filename
Kill the process occupying the file
sudo kill -9 process id
The version of
Elasticsearch
we installed is 6.4.0, and the matching version number of this version is also 6.4.0. If you copy the document address, the following error may be reported:
Exception in thread "main" java.lang.IllegalArgumentException: Plugin [analysis-ik] was built for Elasticsearch version 6.3.0 but version 6.4.0 is running
at org.elasticsearch.plugins.PluginsService.verifyCompatibility(PluginsService.java:339)
at org.elasticsearch.plugins.InstallPluginCommand.loadPluginInfo(InstallPluginCommand.java:717)
at org.elasticsearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:792)
at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:775)
at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:231)
at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:216)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:77)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:47)
So go to here to copy the link address of 6.4.0
installation
. /bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.0/elasticsearch-analysis-ik-6.4.0.zip
Restart elasticsearch
. /bin/elasticsearch -d
Check the effect:
curl -H 'Content-Type: application/json'-XGET 'localhost:9200/_analyze?
pretty' -d '{"analyzer":"ik_max_word","text":"He Deqiang"}'
If it is normal, the following content will be returned:
{" tokens":[{"token":"Congratulate","start_offset":0,"end_offset":1,"type":"CN_CHAR","position":0},{"token":"Morality","start_offset":1,"end_offset":2,"type":"CN_CHAR","position":1},{"token":"Strong","start_offset":2,"end_offset":3,"type":"CN_CHAR","position":2}]}
Recommended Posts