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 ES on Linux system

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "how to install ES in Linux system". In daily operation, I believe many people have doubts about how to install ES in Linux system. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to install ES in Linux system". Next, please follow the editor to study!

ES is similar to MySQL database, and it is also used to store data. ES provides more functions than MySQL, such as word segmentation search, correlation degree and so on. ES can achieve query speed of millions of data per second.

Download the installation package and go directly to the es website to download

Upload the installation package to the virtual machine and unzip it and upload it to / home/software/

Decompress the package

Tar-zxvf elasticsearch-7.5.1-linux-x86_64.tar.gz moves the extracted es folder

The mv elasticsearch-7.5.1 / usr/local/es directory introduces bin: the executable file is in it, and the command to run es is in it, which contains some script files, etc.

Config: profile directory

JDK:java environment

Lib: dependent jar, class library

Logs: log fil

Modules:es related modules

Plugins: a plug-in that can be developed by yourself

Data: this directory is not available. Create a new one yourself, followed by-> mkdir data. This is used as the index directory.

Modify the core configuration file elasticearch.yml modify the cluster name

Modify the current es node name

Modify data data save address and log data save address

Bind es Network ip

The cluster node is modified to the previous node name

Modify the jvm parameter to open the jvm.options file. Here, a virtual machine is used.

# # JVM configuration # IMPORTANT: JVM heap size # # You should always set the min and max JVM heap # # size to the same value. For example, to set # # the heap to 4 GB Set: #-Xms4g # #-Xmx4g # See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html # # for more information # # Xms represents the initial size of total heap space # Xmx represents the maximum size of total heap space # modify the configuration here-Xms128m-Xmx128m add user ES is not allowed to use root to operate es You need to add users as follows:

Useradd esuser chown-R esuser:esuser / usr/local/elasticsearch-7.5.1 su esuser launch es./elasticsearch if the following error occurs:

ERROR: [3] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] [2]: max number of threads [3795] for user [esuser] is too low, increase to at least [4096] [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] need to switch to root user to modify configuration

Modify / etc/security/limits.conf file

Add the following

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

Modify / etc/sysctl.conf to add vm.max_map_count=262145

# sysctl settings are defined through files in # / usr/lib/sysctl.d/, / run/sysctl.d/, and / etc/sysctl.d/. # # Vendors settings live in / usr/lib/sysctl.d/. # To override a whole file, create a new file with the same in # / etc/sysctl.d/ and put new settings there. To override # only specific settings, add a file with a lexically later # name in / etc/sysctl.d/ and put new settings there. # # For more information, see sysctl.conf (5) and sysctl.d (5). Refresh sysctl-p after vm.max_map_count=262145 modification

Switch to esuser again to start

Start and pause start mode 1 run. / elasticsearch see the run result

[2020-02-02T01:09:51843] [INFO] [o.e.h.AbstractHttpServerTransport] [es-node0] publish_address {192.168.247.8 o.e.h.AbstractHttpServerTransport 9200} Bound_addresses {[::]: 9200} [2020-02-02T01:09:51844] [INFO] [o.e.n.Node] [es-node0] started [2020-02-02T01:09:52199] [INFO] [o.e.l.LicenseService] [es-node0] license [9614ee2b-6350-4f99-ad43-5ec0d632f93c] mode [basic]-valid [2020-02-02T01:09:52200] [INFO] [o.e.x. S.s.SecurityStatusChangeListener] [es-node0] Active license is now [BASIC] Security is disabled [2020-02-02T01:09:52222] [INFO] [o.e.g.GatewayService] [es-node0] recovered [0] indices into cluster_state visit 192.168.247.8 es-node0 9200 here and replace it with your ip

Access result

{"name": "es-node0", "cluster_name": "kevin-elasticsearch", "cluster_uuid": "sSzLTAt-SDiCbQ57WMPqlg", "version": {"number": "7.5.1", "build_flavor": "default", "build_type": "tar", "build_hash": "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96" "build_date": "2019-12-16T22:57:37.835892Z", "build_snapshot": false, "lucene_version": "8.3.0", "minimum_wire_compatibility_version": "6.8.0", "minimum_index_compatibility_version": "6.0.0-beta1"}, "tagline": "You Know, for Search"} the front end starts in the current startup mode. If you stop the service, just ctrl+c directly.

Boot mode 2, we can start at the back end.

. / elasticsearch-d wait a moment, visit the address again, the same result

At this point, if you want to shut down the service

[esuser@localhost bin] $ps-ef | grep elasticsearch esuser 3318 3007 0 Feb01 pts/1 00:00:00 vi elasticsearch.yml esuser 3856 1 21 01:15 pts/0 00:00:18 / usr/local/elasticsearch-7.5.1/jdk/bin/java-Des.networkaddress.cache.ttl=60-Des.networkaddress.cache.negative.ttl=10-XX:+AlwaysPreTouch-Xss1m-Djava.awt.headless=true-Dfile.encoding=UTF-8-Djna.nosys=true-XX:-OmitStackTraceInFastThrow-Dio.netty. NoUnsafe=true-Dio.netty.noKeySetOptimization=true-Dio.netty.recycler.maxCapacityPerThread=0-Dio.netty.allocator.numDirectArenas=0-Dlog4j.shutdownHookEnabled=false-Dlog4j2.disable.jmx=true-Djava.locale.providers=COMPAT-Djava.locale.providers=COMPAT-Xms128m-XX:+UseConcMarkSweepGC-XX:CMSInitiatingOccupancyFraction=75-XX:+UseCMSInitiatingOccupancyOnly-Djava.io.tmpdir=/tmp/elasticsearch-9874251960424438570-XX:+HeapDumpOnOutOfMemoryError-XX:HeapDumpPath=data-XX:ErrorFile=logs/hs_err_pid%p.log-Xlog:gc* Gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32 Filesize=64m-XX:MaxDirectMemorySize=67108864-Des.path.home=/usr/local/elasticsearch-7.5.1-Des.path.conf=/usr/local/elasticsearch-7.5.1/config-Des.distribution.flavor=default-Des.distribution.type=tar-Des.bundled_jdk=true-cp / usr/local/elasticsearch-7.5.1/lib/* org.elasticsearch.bootstrap.Elasticsearch-d esuser 3871 3856 0 01:15 pts/0 00:00:00 / usr/local/elasticsearch-7.5.1/ Modules/x-pack-ml/platform/linux-x86_64/bin/controller esuser 3921 3521 0 01:16 pts/0 00:00:00 grep-- color=auto elasticsearch [esuser@localhost bin] $jps 3856 Elasticsearch 3922 Jps [esuser@localhost bin] $kill 3856 [esuser@localhost bin] $jps 3940 Jps [esuser@localhost bin] $II. Install head plug-in Elasticsearch Head Plugin:head plug-in is a web front-end tool for ES clusters It provides visual pages for users to view node information and perform various operations on ES, such as query, deletion, browsing index and so on.

1. Install related dependency packages

(1) install head

Since the head plug-in is essentially a nodejs project, you need to install node and use npm to install dependent packages. (npm can be understood as maven)

Wget https://nodejs.org/dist/v9.3.0/node-v9.3.0-linux-x64.tar.xz # download nodejs's latest bin package xz-d node-v9.3.0-linux-x64.tar.xz # extract package tar-xf node-v9.3.0-linux-x64.tar # extract package ln-s ~ / node-v9.3.0-linux-x64/bin/node / usr/bin/node # deployment bin file First determine the bin path of nodejs ln-s ~ / node-v9.3.0-linux-x64/bin/npm / usr/bin/npm test:

Node-v npmnpm accelerates global installation of cnpm specified source Taobao image

Npm install-g cnpm-registry= https://registry.npm.taobao.org

(2) install grunt (after installing elasticsearch-head)

Grunt is a convenient build tool for packaging, compression, testing, execution, and so on. The head plug-in in 5. 0 is started through grunt. So you need to install grunt:

Cd / usr/local/elasticsearch-head npm install-g grunt-cli / / generates a node_modules folder npm install after execution:

(1) elasticsearch-head cannot be placed in the plugins and modules directories of elasticsearch, otherwise elasticsearch startup will report an error.

(2) it doesn't matter if grunt is not installed successfully, you can start the elasticsearch-head plug-in (npm run start) in other ways.

2. Install elasticsearch-head

In addition: versions prior to 5.0 can install elasticsearch-head,5.0 through the plugin command that comes with elasticseach. It is no longer supported. You can only download the source package corresponding to elasticsearch-head to install it.

Cd / usr/local/ git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-head

Npm install

Configuration:

Vi _ site/app.js # modify this.base_uri = this.config.base_uri | | this.prefs.get ("app-base_uri") | | "http://localhost:9200";" # near line 4354 of the file # where localhost refers to the ES cluster address accessed by default when you enter the elasticsearch-head page. Change it to the address of one of the ES nodes to this.base_uri = this.config.base_uri | | this.prefs.get ("app-base_uri") | | "http://192.168.60.200:9200";" We also need to modify the Gruntfile.js under the Head home directory. Since there is no hostname attribute in the default file, we need to add it manually:

Why do you need to modify the configuration file: the head plug-in connects to elasticsearch need to pay attention to: because the head plug-in is a separate process, after startup is a separate server plus port, such as my virtual machine ip address: http://192.168.0.111:9100/ and elasticsearch after startup is also a separate process, ip address: http://192.168.0.111:9200/ such two independent processes Although the server ip address is the same, but the port is different, a cross-domain situation occurs. So the official statement is that when we start elasticsearch, we append two configuration file properties to prevent cross-domain. That is, at the end of the elasticsearch.yml file, add the following:

Http.cors.enabled: true http.cors.allow-origin: "*" is configured.

3. Start the elasticsearch cluster

Start elasticsearch on each of the three machines.

. / bin/elasticsearch4, start elasticsearch-head

Cd / usr/local/elasticsearch-head / / first jump to the head directory grunt server / / if you want to run in the background, append "&" at the end, or you can use npm run start to start 5 and visit the elasticsearch-head interface

Http://192.168.60.200:9100

As you can see, the three machines form an es cluster. The status of the cluster is green and healthy. A node with a star els-node1 is the primary node (election). You can also do some operations such as adding / deleting indexes, queries, etc.

At this point, the study on "how to install ES in Linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report