Demonstration of building ElasticSearch middleware and common interfaces under centos7 in Linux system

Demonstration of building ElasticSearch middleware and common interfaces under centos7 in Linux system

1. Introduction to Middleware

1. Basic concepts

ElasticSearch is a search server based on Lucene. It provides a distributed multi-user full-text search engine based on a RESTful web interface. Elasticsearch is developed in Java and released as open source under the terms of the Apache license. It is a popular enterprise-level search engine.

2. Distributed Database

Distributed database systems usually use smaller computer systems. Each computer can be placed in a separate place. Each computer may have a complete copy of the DBMS, or a partial copy, and has its own local database. Many computers located in different locations are interconnected through a network to form a complete, global, logically centralized, and physically distributed large database.

3. Core Role

1) Nodes and clusters

Cluster represents a cluster. There are multiple nodes in the cluster, one of which is the master node. This master node can be generated through election. The master and slave nodes are within the cluster. One of the concepts of es is decentralization, which literally means no central node. This is for the outside of the cluster, because from the outside, the es cluster is logically a whole. A single Elastic instance is called a node. A group of nodes forms a cluster.

2) Shards

It stands for index sharding. Elasticsearch can divide a complete index into multiple shards. The advantage of this is that a large index can be split into multiple shards and distributed to different nodes. Constitute a distributed search. The number of shards can only be specified before the index is created and cannot be changed after the index is created.

3) Document
A single record in an Index is called a Document. Many Documents constitute an Index. Document is represented using JSON format.

4) Index

Elastic will index all fields, and when searching for data, you can directly search the index. The name of each Index (which is understood as the database name) must be lowercase.

5) Type

Document can be virtually logically grouped according to Type to filter Document, which is understood as the database table name.

2. Middleware Installation

1. Installation environment and version

Centos7
JDK1.8
elasticsearch-6.3.2

2. Download and decompress

The download path is in the folder of the current directory, or you can specify the download path. wget -P directory url.

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.zip
[root@localhost roo]# mv elasticsearch-6.3.2.zip /usr/local/mysoft/
[root@localhost mysoft]# unzip elasticsearch-6.3.2.zip

3. Start the software

[root@localhost mysoft]# cd elasticsearch-6.3.2/
[root@localhost elasticsearch-6.3.2]# ./bin/elasticsearch

1) Report an error

org.elasticsearch.bootstrap.StartupException: 
java.lang.RuntimeException: can not run elasticsearch as root

Create new user groups and users

[root@localhost]# useradd esroot
[root@localhost]# passwd esroot
[root@localhost]# groupadd esgroup
[root@localhost]# usermod -g esgroup esroot

esroot user authorization

chown esroot /usr/local/mysoft/elasticsearch-6.3.2 -R

Switch to esroot user

[root@localhost mysoft]# su - esroot
[esroot@localhost ~]$ su #Return to root user

2) Error 2

max file descriptors [4096] for elasticsearch process is too low, 
increase to at least [65536]

Execute the following command, which is performed under Root privileges.

[root@localhost roo]# vim /etc/security/limits.conf

Add content

*soft nofile 65536
* hard nofile 65536

Switch back to the esroot user

Restarted, no error message.

4. Open the command line test

curl localhost:9200
[roo@localhost ~]$ curl localhost:9200
{
 "name" : "YMS44oi",
 "cluster_name" : "elasticsearch",
 "cluster_uuid" : "2ZXjBnkJSjieV_k1IWMzrQ",
 "version" : {
 "number" : "6.3.2",
 "build_flavor" : "default",
 "build_type" : "zip",
 "build_hash" : "053779d",
 "build_date" : "2018-07-20T05:20:23.451332Z",
 "build_snapshot" : false,
 "lucene_version" : "7.3.1",
 "minimum_wire_compatibility_version" : "5.6.0",
 "minimum_index_compatibility_version" : "5.0.0"
 },
 "tagline" : "You Know, for Search"
}

In this way, the elasticsearch-6.3.2 environment is successfully built.

Request port 9200, and Elastic returns a JSON object containing information such as the current node, cluster, and version.
Press Ctrl + C and Elastic will stop running.

5. Configure external access

By default, Elastic only allows local access. If remote access is required, you can modify the config/elasticsearch.yml file in the Elastic installation directory, uncomment network.host, change its value to 0.0.0.0, and then restart Elastic.

[esroot@localhost config]$ cd /usr/local/mysoft/elasticsearch-6.3.2/config
[esroot@localhost config]$ vim elasticsearch.yml 
network.host: 0.0.0.0

6. Install IK Chinese word segmenter

Switch to root user

[root@localhost elasticsearch-6.3.2]$ ./bin/elasticsearch-plugin 
install 
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.2/elasticsearch-analysis-ik-6.3.2.zip

3. Getting Started

Index creation and deletion

1. Create an index

[esroot@localhost ~]$ curl -X PUT 'localhost:9200/esindex01'
# Return data {
 "acknowledged": true,
 "shards_acknowledged": true,
 "index": "esindex01"
}

The server returns a JSON object, and the acknowledged: true field indicates that the operation was successful.

2. Delete the index

[esroot@localhost ~]$ curl -X DELETE 'localhost:9200/esindex01'
{"acknowledged":true}

acknowledged: A true field indicates that the operation was successful.

4. Source code address

GitHub address: Cicadasmile https://github.com/cicadasmile
Code Cloud Address: Cicadasmile https://gitee.com/cicadasmile

Summarize

The above is a demonstration of building ElasticSearch middleware and common interfaces under centos7 under Linux system introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Detailed explanation of Linux DMA interface knowledge points
  • How to view available network interfaces in Linux
  • The Linux system uses Python to monitor the network interface to obtain network input and output
  • Basic Introduction to BSD Socket Development in Linux
  • Basic Introduction to BSD Socket Development in Linux Operating System
  • Linux /etc/network/interfaces configuration interface method

<<:  Detailed explanation of the execution plan explain command example in MySQL

>>:  Vue improves page response speed through lazy loading

Recommend

How to modify create-react-app's configuration without using eject

1. Why is eject not recommended? 1. What changes ...

Detailed explanation of Kubernetes pod orchestration and lifecycle

Table of contents K8S Master Basic Architecture P...

Building a selenium distributed environment based on docker

1. Download the image docker pull selenium/hub do...

VMware and CentOS system installation method to reset the root password

Today's Tasks 1. Choice of Linux distribution...

IE6/7 is going to be a mess: empty text node height issue

Preface: Use debugbar to view document code in iet...

Interpretation of the module for load balancing using nginx

Table of contents Two modules for using nginx for...

Practical MySQL + PostgreSQL batch insert update insertOrUpdate

Table of contents 1. Baidu Encyclopedia 1. MySQL ...

Basic principles for compiling a website homepage

1. The organizational structure of the hypertext d...

Detailed process of SpringBoot integrating Docker

Table of contents 1. Demo Project 1.1 Interface P...

Secondary encapsulation of element el-table table (with table height adaptation)

Preface During my internship at the company, I us...

An example of how to implement an adaptive square using CSS

The traditional method is to write a square in a ...

Zen Coding Easy and fast HTML writing

Zen Coding It is a text editor plugin. In a text ...

CentOS 6.5 i386 installation MySQL 5.7.18 detailed tutorial

Most people compile MySQL and put it in the syste...