Elasticsearch5 installation and elasticsearch-analysis-ik Chinese word segmentation plugin installation

Introduction to ElasticSearch

Insert picture description here

Elastic has a complete product line and solutions: Elasticsearch, Kibana, Logstash, etc. The three previously mentioned are the ELK technology stacks that everyone often talks about.
Insert picture description here

Elasticsearch has the following characteristics:

  • Distributed, no need to manually build a cluster (solr requires manual configuration, use Zookeeper as a registration center)
  • Restful style, all APIs follow Rest principles, easy to use
  • Near real-time search, data updates are almost completely synchronized in Elasticsearch.

1.elasticsearch5.x

1.1 install Java environment

yum -y search java
yum -y install java-1.8.0-openjdk*

1.2 Install ElasticSearch

  • Create installation source files
vi /etc/yum.repos.d/elasticsearch.repo
  • document content
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
  • start installation
yum install elasticsearch-5.0.1

When I installed here, I chose the elasticsearch version to be 5.0.1, mainly because the analysis-ik Chinese word segmentation plugin is slow to update, and it must match the elasticsearch version, otherwise there will be problems

  • Start elasticsearch service
service elasticsearch start
  • Test if elasticsearch is installed successfully
curl -X GET http://127.0.0.1:9200/

Insert picture description here

2.elasticsearch-analysis-i

Chinese word segmentation plugin installation

unzip elasticsearch-analysis-ik-5.0.1.zip
cd elasticsearch-analysis-ik-5.0.1
mvn package
  • If no mvn command is found
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
  • Install ik tokenizer
mkdir /usr/share/elasticsearch/plugins/ik
cp target/releases/elasticsearch-analysis-ik-5.0.1.zip /usr/share/elasticsearch/plugins/ik
unzip /usr/share/elasticsearch/plugins/ik/elasticsearch-analysis-ik-5.0.1.zip
  • Restart elasticsearch
service elasticsearch restart

3. FAQ

3.1 New user

  • For security reasons, elasticsearch is not allowed to run as root account by default.
  • Create user
useradd es
  • set password
passwd es
  • Switch users
su - es

3.2jvm.options

  • Elasticsearch is based on Lucene, and the bottom layer of Lucene is implemented in java, so we need to configure jvm parameters.
  • Edit jvm.options:
vim jvm.options
  • The default configuration is as follows:
-Xms1g
-Xmx1g
  • The memory usage is too much, let's turn it down:
-Xms512m
-Xmx512m

3.3 elasticsearch.yml

vim elasticsearch.yml
  • Modify the data and log directory:
path.data: /home/leyou/elasticsearch/data # 数据目录位置
path.logs: /home/leyou/elasticsearch/logs # 日志目录位置
  • We changed the data and logs directories to point to the installation directory of elasticsearch. But these two directories do not exist, so we need to create them.

  • Go to the root directory of elasticsearch and create:

mkdir data
mkdir logs
  • Modify the bound IP:
network.host: 0.0.0.0 # 绑定到0.0.0.0,允许任何ip来访问
  • By default, only local access is allowed, and after modification to 0.0.0.0, remote access is possible

  • At present, we are doing a stand-alone installation. If you want to do a cluster, you only need to add other node information to this configuration file.

Other configurable information of elasticsearch.yml:

Attribute name Explanation
cluster.name Configure the cluster name of elasticsearch. The default is elasticsearch. It is recommended to change to a meaningful name.
node.name Node name, es will randomly assign a name by default, it is recommended to specify a meaningful name for easy management
path.conf Set the storage path of the configuration file. The tar or zip package installation defaults to the config folder in the es root directory, and the rpm installation defaults to / etc / elasticsearch
path.data Set the storage path of the index data, the default is the data folder under the es root directory, you can set multiple storage paths, separated by commas
path.logs Set the storage path of the log file, the default is the logs folder in the es root directory
path.plugins Set the storage path of the plugin, the default is the plugins folder under the es root directory
bootstrap.memory_lock Set to true to lock the memory used by ES and avoid swapping the memory
network.host Set bind_host and publish_host, set to 0.0.0.0 to allow external network access
http.port Set the http port for external services, the default is 9200.
transport.tcp.port Communication port between cluster nodes
discovery.zen.ping.timeout Set the time for ES to automatically discover the connection timeout of the node, the default is 3 seconds, if the network delay is high, you can set a larger
discovery.zen.minimum_master_nodes The minimum value of the number of master nodes, the formula for this value is: (master_eligible_nodes / 2) + 1, for example: there are 3 master nodes that meet the requirements, so here it should be set to 2

3.4 Error: The kernel is too low

  • Modify the elasticsearch.yml file, add the following configuration at the bottom, and then restart
bootstrap.system_call_filter: false
Published 395 original articles · won 130 · 200,000 views +

Guess you like

Origin blog.csdn.net/qq_40507857/article/details/105326279