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

How to install and configure ElasticSearch for Centos7

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "how to install and configure ElasticSearch in Centos7". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install and configure ElasticSearch with Centos7.

Experimental environment:

Operating system: Centos 7.5

Server ip:192.168.1.198

Running user: root

Network environment: Internet

When there are many servers in the enterprise production environment and the logs of many business modules, the operation and maintenance staff need to check the logs all the time, so there is no time to do other work. Elasticsearch is an open source distributed search engine, which has the following characteristics: open source, flexibility, distributed, zero configuration, automatic discovery, automatic index fragmentation, index copy mechanism, restful style interface. Multiple data sources, automatic search load, etc., are easy to configure and are generally used in combination with Logstash and kibana. Now all operators know that there is an ELK, which is the abbreviation of Elasticsearch, Logstash and kibana. It is widely used, powerful, and simplifies the operation steps of operation and maintenance. It can also achieve automatic alarm with error logs or faults. If there is a failure of the server, you can send an administrator by alarm. Alarm methods such as WeCom, enterprise nails and SMS are supported. You can try to deploy them. Currently, you also support docker deployment.

Elasticsearch is used to store a variety of log formats of the component; Logstash is used to collect, process, analyze logs, and store them for future use; kibana is a web visual interface log query component, it can provide Logstash and ElasticSearch log analysis friendly Web interface, can help you summarize, analyze and search important data logs displayed. These three components are open source and run on the Linux platform, so you still need some Linux foundation to deploy. Now large enterprises generally deploy ELK systems in Linux. If there is no Linux foundation, you can learn about the basic knowledge of Linux or refer to the information on the website "Linux should learn this". Enter the name of this book directly in Baidu to find the official website. The author of this book is Liu Jie. This book is more suitable for enterprise applications. This article mainly introduces how to install and deploy ElasticSearch components under the Linux operating system.

Elasticsearch is very easy to use, and Elasticsearch is an open source search engine based on Apache that provides many reasonable default values and hides complex search engine theories from beginners. It is out of the box (installation can be used), only need to know the basics of Linux and very little learning can be used in the production environment, Elasticsearch also uses Java development, and uses Lucene as its core architecture to achieve all the indexing and search functional components, but its purpose is to hide the complexity of Lucene through a simple RESTful API, thus making full-text search easier and more suitable for beginners.

I. operating environment

JDK:1.8.0_171 (JAVA_SE)

Elasticsearch-6.3.1 (JDK can only use version 1.8)

Logstash-6.3.1

Kibana-6.3.1

Second, install Java and Elasticsearch

1. Install JDK

Download JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html; this environment downloads the 64-bit tar.gz package, copy the installation package to the installation server / usr/local directory

[root@localhost ~] # cd / usr/local/

[root@localhost local] # tar-xzvf jdk-8u171-linux-x64.tar.gz

[root@localhost local] # mv jdk1.8.0_171 java

2. Configure JDK environment variables

Method 1:

[root@localhost local] # vim / etc/profile

Add the following to the end of the file (if the server requires multiple versions of JDK, you can also add the contents of the environment variable to the startup script of ELK later in order that ELK does not affect other systems)

JAVA_HOME=/usr/local/java

JRE_HOME=/usr/local/java/jre

CLASSPATH=.:$JAVA_HOME/lib:/dt.jar:$JAVA_HOME/lib/tools.jar

PATH=$PATH:$JAVA_HOME/bin

[root@localhost local] # source / etc/profile

[root@localhost local] # chmod + x / etc/rc.local

[root@localhost local] # vim / etc/rc.local

Source / etc/profile / / add this line

Method 2:

Just put the java.sh into / etc/profile.d/, and restart the system.

[root@localhost local] # vim / etc/profile.d/java.sh

Export JAVA_HOME=/usr/local/java

Export JRE_HOME=$ {JAVA_HOME} / jre

Export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

Export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH

[root@centos7 ~] # java-version / / check the java version and test whether the JDK is configured successfully

Java version "1.8.0,171"

Java (TM) SE Runtime Environment (build 1.8.0_171-b11)

Java HotSpot (TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Configure parameters related to limit

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

Add the following

* soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096

Ulimit-u 4096

[root@localhost local] vim / etc/security/limits.d/20-nproc.conf

Modify the following:

* soft nproc 1024 # modified to * soft nproc 2048 or soft nproc 4096 (minimum is 2048 according to CPU)

# vim / etc/sysctl.conf

/ / add the following configuration: v

M.max_map_count=655360

/ and execute the command:

# sysctl-p

Edit elasticsearch profile

# vim usr/local/elasticsearch-5.6.0/config/elasticsearch.yml

Cluster.name: nmtx-cluster

Node.name: node-1

Path.data: / usr/local/elk/data

Path.logs: / usr/local/elk/logs

Network.host: 192.168.3.104

Http.port: 9200

Create a user running ELK

[root@localhost local] # groupadd elk

[root@localhost local] # useradd-g elk elk

Create an ELK run directory

[root@localhost local] # mkdir-p / usr/local/elk

[root@localhost local] # chown-R elk:elk / usr/local/elk

Turn off the firewall:

[root@localhost] # iptables-F

All of the above is done by root users

3. Install ELK

The following actions are performed by elk users

Log in to the server as elk user

Download the ELK installation package: https://www.elastic.co/downloads, upload it to the server and extract it. Decompress command: tar-xzvf package name

Configure Elasticsearch

Modify the following:

Save exit

Start Elasticsearch

Check to see if the startup is successful

Visit http://192.168.10.169:9200 with a browser

Elasticsearch installation completed

Vi / etc/security/limits.conf

/ / add the following:

* soft nofile 65536

* hard nofile 131072

* soft nproc 2048

* hard nproc 4096

Question 3: max number of threads [1024] for user [lish] likely too low, increase to at least [2048]

Solution: switch to the root user and go to the limits.d directory to modify the configuration file.

Vi / etc/security/limits.d/90-nproc.conf

/ / modify the following:

* soft nproc 1024 # modified to * soft nproc 2048

Question 4: max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

Solution: switch to root user to modify configuration sysctl.conf

Vi / etc/sysctl.conf

/ / add the following configuration:

Vm.max_map_count=655360

/ and execute the command:

Sysctl-p then restart elasticsearch to start successfully.

4. Test, the following indicates that elasticsearch was started successfully.

[root@centos7 local] # curl http://127.0.0.1:9200

{

"name": "pcncnlr"

"cluster_name": "elasticsearch"

"cluster_uuid": "uCqIPKYqT_au90cjmtj1rw"

"version": {

"number": "6.3.1"

"build_flavor": "default"

"build_type": "tar"

"build_hash": "eb782d0"

"build_date": "2018-06-29T21:59:26.107521Z"

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

}

At this point, I believe you have a deeper understanding of "how Centos7 installs and configures ElasticSearch". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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