Ubuntu install Elasticsearch and elasticsearch-analysis-ik word segmentation

Install Elasticsearch and elasticsearch-analysis-ik on Ubuntu#

Assuming you have already installed JDK, if not, please check this article for Install JDK

Install Elasticsearch

Official document

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  

Or run as a daemon#

. /bin/elasticsearch -d -p pid

Elasticsearch will run on the default port 9200

curl localhost:9200

Possible problems:

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"}
  1. Text file busy Could not rename log file 'logs/gc.log' to 'logs/gc.log.03' (Text file busy)
    Solution:

Find out the process occupying the file:

sudo fuser filename

Kill the process occupying the file

sudo kill -9 process id

Install elasticsearch-analysis-ik word segmentation##

Official document

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

Ubuntu install Elasticsearch and elasticsearch-analysis-ik word segmentation
ubuntu install elasticsearch
How to install and configure Elasticsearch on Ubuntu 16.04
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
ubuntu install and configure GitLab
Ubuntu16.04 install SVN and configuration
Ubuntu16.04 install and uninstall VMware-Workstation 14
How to install Elasticsearch on Ubuntu 20.04
Install and configure MySQL on Ubuntu
Install and configure Docker in Ubuntu
Install and deploy Gerrit under Ubuntu
Install nodejs and npm under Ubuntu 16.04
Compile and install QEMU under Ubuntu
Install Gnome and VNC on Ubuntu Server
[Daily] Win10 open and install ubuntu subsystem
Install docker on ubuntu and basic usage
Install fonts on Ubuntu and switch default fonts
Ubuntu 18.04 source code compile and install ffmpeg4.1
Ubuntu install PHP and PHP Nginx configuration method
Install and uninstall CUDA and CUDNN on Ubuntu
Linux install Docker and run Ubuntu system
Ubuntu install ftp server and possible problems
How to install Ubuntu20.04 and install NVIDIA driver
How to install Pycharm and Ipython on Ubuntu 16.04/18.04
How to install and configure NATS on Ubuntu 16.04
Install JDK and configure environment variables on Ubuntu 16.04
How to install and configure Gogs on Ubuntu 18.04
How to install and configure Elasticsearch on CentOS 7
ubuntu18.04 install python2
How to install and configure Cyberpanel on Ubuntu 18.04
ubuntu18.04 install docker
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure ownCloud on Ubuntu 16.04
ubuntu12.04 install python3
Ubuntu install guide
How to install and use Docker on Ubuntu 20.04
How to install and configure Ansible on Ubuntu 18.04
ubuntu install nodejs
ubuntu 16 install asp.net
How to install and use Curl on Ubuntu 18.04
How to install and use Composer on Ubuntu 18.04
ubuntu install leanote
How to install and use Wine on Ubuntu 18.04
How to install and secure phpMyAdmin on Ubuntu 16.04
How to install and configure PostGIS on Ubuntu 14.04
ubuntu install Jenkins
Simple and clean install remote login for ubuntu18
How to install and use Composer on Ubuntu 20.04
How to install and use BaasBox on Ubuntu 14.04
How to install and configure VNC on Ubuntu 18.04
How to install and configure Sphinx on Ubuntu 16.04
How to install and configure OrientDB on Ubuntu 14.04
How to install and use PostgreSQL on Ubuntu 16.04
docker install ubuntu
ubuntu16.0.1 install pagoda
ubuntu18.04 install python
How to install and configure AppScale on Ubuntu 12.04
ubuntu 18.04 install teamviewer
How to install and use Docker on Ubuntu 16.04
ubuntu install sendmail