Brief introduction
ElasticSearch is a search server based on Lucene. It provides a distributed multi-user capabilities of full-text search engine, based on RESTful
Web interface. Elasticsearch is a Java language development, and as open source under the Apache license terms published, is a popular enterprise-class search engine. ElasticSearch for cloud computing, it is possible to achieve real-time search, stable, reliable, fast and easy to install. The official client in the Java, the .NET (C #), PHP, Python, the Apache
Groovy, Ruby and many other languages are available. According to DB-Engines rankings show, Elasticsearch enterprise search engine is the most popular, followed by the Apache
Solr, also based on Lucene.
Official Address:
Well, we go directly to the topic, centos installation tutorial Welcome to see my previous article hair, I am not here to explain too much, and we start today following my tutorial
1, by installing elasticsearch docker
docker pull elasticsearch:7.3.2
1.1 look at the pull down through elasticsearch
1.2, execute the command to start elasticsearch
docker run -d --name es -p 9200:9200 -p 9300:9300 -p 5601:5601 -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -e "discovery.type=single-node" elasticsearch:7.3.2
1.3 browser access to verify the installation, this is my native address: http://192.168.177.132:9200/
Well, see the data in the browser, it shows elasticsearch successful installation.
Let us come back to install another tool that kibana tools to manage elasticsearch
2, docker mounted visual interface kibana
2.1 pull mirroring
docker pull kibana:7.3.2
2.2, the command to start kibana
docker run -d --name kb -e ELASTICSEARCH_HOSTS=http:127.0.0.1/9200 --network=container:es kibana:7.3.2
After executing the above command and there is no longer the same map, and here need to wait a minute or so, to see the effect in the browser
2.3 browser whether the test was successful
http://192.168.177.132:5601/app/kibana
2.4 First, let's add a document
2.5 View data added by the query
2.6 Frequently used commands
#创建指定文档
PUT /demo/_doc/2
{
"name":"Somnus_小凯",
"job":"Java研发",
"age":25
}
#查询指定ID的文档
GET /demo/_doc/2
#查询指定索引下的为所有文档
GET /demo/_search
#精确匹配查询
GET /demo/_search?q=age:25
#查询区间
GET /demo/_search?q=age[24 TO 26]
3, docker achieve elasticsearch Chinese ik container and generating image segmenter
3.1, the first to enter the container
docker exec -it es bash
3.2 After entering the container needs to install wget to download the plug-ik word
yum -y install wget
After the installation is completed the next 3.3 download plug-ik
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.3.2/elasticsearch-analysis-ik-7.3.2.zip
3.4 Creating directory directory to unzip the downloaded file to the plugins directory can be
unzip -d ./plugins/ik/ elasticsearch-analysis-ik-7.3.2.zip
So far ik word breaker installation is complete, the following is our focus today
4, ElasticSearch set up my side of the cluster configuration environment as follows
Since we want to build clusters with an odd suggestion here, I used three machines here, a friend will ask here why use three, two not it? The problem I believe you still ask Baidu big God now.
192.168.177.132 es-node01
192.168.177.133 es-node02
192.168.177.134 es-node03
4.1 first need to create data and configuration files on the three machines
[root@localhost somnus]# tree
.
└── es #创建es目录
├── config #创建es配置相关目录
│ └── elasticsearch.yml #创建es配置文件
└── data #创建es数据文件目录
4.2 directory is created, the next configuration elasticsearch.yml
In the remaining two machines also do the appropriate configuration information, here's what I do not do too much description, the above operation is complete continue with the installation elasticsearch cluster
4.3 First node configuration
docker run -d --name es -p 9200:9200 -p 9300:9300 -p 5601:5601 -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" -v /home/somnus/es/data:/usr/share/elasticsearch -v /home/somnus/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml --privileged=true elasticsearch:7.3.2
The other two nodes is the same here, where we can execute the script by xshell quantities, can be related back to start a script
Cluster state visit after 4.4 facie start address: http://192.168.177.134:9200/_cat/nodes
4.5 cluster deployment elasticsearch
Modify the value of vm.max_map_count
Use docker elasticsearch operation, the host system requires m.max_map_count value is not less than 262144, not run or elasticsearch mirror.
Edit "/etc/sysctl.conf" file, which add a line:
vm.max_map_count=262144