Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Building ElasticSearch Middleware and Common Interface demonstration under centos7 under Linux system

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

I. Introduction to middleware

1. Basic concepts

ElasticSearch is a Lucene-based search server. It provides a full-text search engine with distributed multi-user capabilities, based on RESTful web interfaces. Elasticsearch, developed in Java and distributed as open source under the Apache license, is the current popular enterprise 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 of the DBMS, and has its own local database, many computers located in different locations are connected to each other through the network, together to form a complete, global logically centralized, 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 elected. The master-slave node is internal to the cluster. One concept of es is decentralization, literally no central node, which is external to 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 fragmentation

Represents index fragmentation, es can divide a complete index into multiple fragments, so the advantage is that a large index can be divided into multiple fragments 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 form an Index. Document is represented in JSON format.

4) Index

Elastic indexes all fields, and when looking up data, look up the index directly. The name of each Index must be lowercase.

5) Type

Documents can be grouped virtually logically according to Type, which is used to filter Documents, that is, understood as database table names.

II. Middleware installation

1. Installation environment and version

Centos7

JDK1.8

elasticsearch-6.3.2

2. Download and decompress

Download path, under the folder of the current directory, you can also 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) Error 1

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

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

2) Error 2

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

Perform the following named operation, which operates under Root privileges.

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

add content

* soft nofile 65536* hard nofile 65536

Switch back to esroot

Start again, no error message reported.

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"}

Elasticsearch-6.3.2 environment was successfully built.

When requesting port 9200, Elastic returns a JSON object containing information about the current node, cluster, version, and so on.

Press Ctrl + C and Elastic stops running.

5. Configure external access

By default, Elastic only allows local access, if you need remote access, you can modify the config/elasticsearch.yml file in the Elastic installation directory, remove the network.host comment, 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 Separator

su 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

III. Entry Operation

Index creation and deletion

1. Create an index

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

The server returns a JSON object with the acknowledged: true field indicating success.

2. Delete index

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

acknowledged: The true field indicates success.

IV. Source Code Address

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

summary

The above is a demonstration of ElasticSearch middleware and common interfaces built under centos7 under Linux system introduced by Xiaobian. I hope it will help you. If you have any questions, please leave a message to me. Xiaobian will reply to you in time. Thank you very much for your support!

If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report