Elasticsearch - core - Download and install

Posted by lore_lanu on Sat, 15 Jan 2022 01:24:02 +0100

1, Elasticsearch installation

1.1 Linux Installation

  1. Download address
  2. Other software download pages
  3. Note that the java environment must be installed first (es7 requires JDK11 +). If it is not installed, es has its own JDK11, which can be configured before running
  4. Unzip elasticsearch and rename
tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz -C /opt
cd /opt
mv elasticsearch-7.8.0 es
  1. Create es users and user groups. Es is not allowed to run with root
group add es
useradd es -g es
passwd es
chown -R es:es es
  1. After extracting elasticsearch, modify config / elasticsearch YML file
    • If it is a stand-alone node, it does not need to be modified
    • Allow Internet access is configured below
cluster.name: elasticsearch
node.name: node-1
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
  1. Just run bin/elasticsearch directly
cd /opt/es/bin
su es
./elasticsearch -d
  1. If you want to run Elasticsearch in the background as a daemon, you can add the parameter - d later
  2. By default, ports 9200 and 9300 will be occupied after startup. If there is a firewall or security group, it needs to run through
    • 9300: communication port
    • 9200: http port
  3. es7 + requires that the JDK version be at least 11, so an error may be reported when starting, so either upgrade the JDK version or configure es to run the JDK version
  • JDK11 is already included in the ES installation directory

  • Modify bin / elasticsearch Env and configure Java in this directory_ The home path is the jdk path under ES

binExecutable script directory
configconfigure directory
jdkBuilt in JDK directory
libClass library
logsLog directory
modulesModule directory
pluginsPlug in directory

1.2 Windows installation

  1. Download the windows version of elasticsearch
  2. Unzip the package
  3. Run bin / elasticsearch Bat can be started

1.3 Docker installation

  1. Download the docker elasticsearch file
docker pull elasticsearch:7.8.0
  1. Reference documents
  2. Start es
    • If it is a single node, you must add * * -e "discovery. Type = single node" * *, otherwise you need to specify the node name
    • For details, please refer to the es official docker document
docker run -d --name es -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" <ImageId>
  1. Start result

1.4 connection test

  1. browser: http://localhost:9200/?pretty
  2. Linux:
curl http://localhost:9200/?pretty
	"name": "tianxin",
	"cluster_name": "elasticsearch",
	"cluster_uuid": "aTt3P85JRhW85BmIUJWpjw",
	"version": {
		"number": "7.8.0",
		"build_flavor": "default",
		"build_type": "tar",
		"build_hash": "757314695644ea9a1dc2fecd26d1a43856725e65",
		"build_date": "2020-06-14T19:35:50.234439Z",
		"build_snapshot": false,
		"lucene_version": "8.5.1",
		"minimum_wire_compatibility_version": "6.8.0",
		"minimum_index_compatibility_version": "6.0.0-beta1"
	"tagline": "You Know, for Search"

2, Elasticsearch Internet access

  1. After the ES installation is completed, it can only be accessed locally by default. If external access is required, external network access needs to be configured
  2. Modify config / elasticsearch. In the es directory YML file, network Set host to machine ip
    • network. Host: < IP address >
      • If you want all addresses to be accessible, you can configure
    • cluster.initial_master_nodes: ["node-1"]
      • Configure single node startup
cluster.name: elasticsearch
node.name: node-1
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
  1. After the configuration is completed, restart the ES, and then access it through the Internet

3, Elasticsearch plug-in installation

3.1 installation of head plug-in

  1. Since the elasticsearch head plug-in is written in nodejs language, nodejs and grunt need to be installed before installing elasticsearch head
  2. Download the nodejs package, extract any directory, and then configure the environment variables
    • vim /etc/profile
    • Add the following environment variables
    • source /etc/profile
export NODE_HOME=/opt/node
export PATH=$PATH:$NODE_HOME/bin
  1. View the version after node installation
[root@tianxin node]# node -v
  1. Install grunt directly using npm
npm install -g grunt-cli
[root@tianxin node]# npm install -g grunt-cli
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
/opt/node/bin/grunt -> /opt/node/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli@1.3.2
added 153 packages from 126 contributors in 31.658s
[root@tianxin node]# grunt --version
grunt-cli v1.3.2
  1. Create a new dashboard/head folder (optional) in the es installation directory, and pull elasticsearch head to the head folder
git clone https://gitee.com/tianxincoord/elasticsearch-head.git
  1. Install the head plug-in
    • Taobao image can be installed
npm install -g cnpm --registry=https://registry.npm.taobao.org
  • head plug-in installation
# npm installation
cd elasticsearch-head/
npm install
npm run start
  • Taobao installation
# cnpm installation
cd elasticsearch-head/
cnpm install
cnpm run start
  1. After installation, open port 9100 to access

  1. config/elasticsearch.yml needs to be configured to allow cross domain, otherwise it cannot connect
http.cors.enabled: true
http.cors.allow-origin: "*"

4, Elasticsearch FAQ

  1. java.lang.RuntimeException: can not run elasticsearch as root
    • You can't run es as root user. You need to use es, so you can switch su es and run it again
  2. ERROR: [1] bootstrap checks failed
    [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
    • es requires discovery seed_ hosts,discovery.seed_providers, cluster.initial_master_nodes must configure one of them
    • For example, select one of the following configurations and restart after configuration
      • cluster.initial_master_nodes: ["node-1"]
      • discovery.seed_hosts: [""]

  1. Java HotSpot™ 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
    • UseConcMarkSweepGC garbage collector is no longer recommended and will be deleted later
    • Modify config / JVM Options to modify the garbage collector
# Note UseConcMarkSweepGC
# 8-13:-XX:+UseConcMarkSweepGC
# Change to + UseG1GC

  1. max file descriptors [4096] for elasticsearch process is too low,increase to at least [65535]
    • Modify * * / etc / security / limits Conf * *, add the following configuration
    • *Indicates all users. If a single user is required, specify a specific user name
es soft nofile 65535
es hard nofile 65535
  • Modify / etc / security / limits d/20-nproc. Conf file, add the following configuration
# Add the following at the end of the document
# Limit on the number of files that can be opened per process
es soft nofile 65536
es hard nofile 65536
# Operating system level limit on the number of processes created per user
* hard nproc 4096
# Note: * all user names of Linux with table
  1. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    • The configured virtual memory is too small. It needs to be in * * / etc / sysctl Conf * * increase virtual memory
# Edit profile
vim /etc/sysctl.conf
# Add virtual memory configuration
# Reload configuration
sysctl -p

Topics: ElasticSearch