ES elasticsearch installation and configuration

1 Resource download

CSDN download address: https://download.csdn.net/download/qq_15769939/15465621

2 ES service deployment

The currently installed server is elasticsearch, hereinafter referred to as abbreviated ES. Its version number is 7.4.2, the Linux operating system used is Centos7.

2.1 Upload resources to the server

To upload files to the server's /opt/module/softwaredirectory

[root@localhost ~]# cd /opt/module/software
[root@localhost software]# ll
总用量 289356
-rw-r--r--. 1 root   root   288775500 2月  22 21:45 elasticsearch-7.4.2-linux-x86_64.tar.gz.zip
[root@localhost software]# unzip elasticsearch-7.4.2-linux-x86_64.tar.gz.zip
[root@localhost software]# tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz 
[root@localhost software]# mv elasticsearch-7.4.2 /usr/local
[root@localhost local]# cd /usr/local/elasticsearch-7.4.2
[root@localhost elasticsearch-7.4.2]# mkdir data
[root@localhost elasticsearch-7.4.2]# ll
总用量 556
drwxr-xr-x.  2 esuser esuser   4096 10月 29 2019 bin
drwxr-xr-x.  2 esuser esuser    178 2月  22 23:08 config
drwxr-xr-x.  3 esuser esuser     19 2月  22 22:07 data
drwxr-xr-x.  9 esuser esuser    107 10月 29 2019 jdk
drwxr-xr-x.  3 esuser esuser   4096 10月 29 2019 lib
-rw-r--r--.  1 esuser esuser  13675 10月 29 2019 LICENSE.txt
drwxr-xr-x.  2 esuser esuser   4096 2月  24 10:39 logs
drwxr-xr-x. 37 esuser esuser   4096 10月 29 2019 modules
-rw-r--r--.  1 esuser esuser 523209 10月 29 2019 NOTICE.txt
drwxr-xr-x.  3 esuser esuser     16 2月  24 13:36 plugins
-rw-r--r--.  1 esuser esuser   8500 10月 29 2019 README.textile

2.2 Introduction to ES Catalog

  • bin: executable script file, including ES startup script
  • config: configuration file directory
  • JDK: java environment
  • lib: dependent jar, class library
  • logs: log files
  • modules: ES related modules
  • plugins: plug-in location
  • data: custom index storage directory

2.3 Modify the core configuration file

[root@localhost config]#  vi /usr/local/elasticsearch-7.4.2/config/elasticsearch.yml 
  • Modify the cluster name, the default is elasticsearch

  • Set the name for the current es node. Special settings are required in the cluster environment and cannot be repeated

    # Use a descriptive name for your cluster:
    #
    cluster.name: auskat-elasticsearch
    
    #
    # Use a descriptive name for the node:
    #
    node.name: es-node1
    
  • Modify the data save path

  • Modify the log data save path

    # ----------------------------------- Paths ------------------------------------
    #
    # Path to directory where to store the data (separate multiple locations by comma):
    #
    path.data: /usr/local/elasticsearch-7.4.2/data
    #
    # Path to log files:
    #
    path.logs: /usr/local/elasticsearch-7.4.2/logs
    
  • Bind es network ip to allow external access

  • The default port number, see if it needs to be modified

  • Port 9200: Http protocol, used for external communication

  • Port 9300: Tcp protocol, communication between ES clusters

    # ---------------------------------- Network -----------------------------------
    #
    # Set the bind address to a specific IP (IPv4 or IPv6):
    #
    network.host: 0.0.0.0
    
    #
    # Set a custom port for HTTP:
    #
    #http.port: 9200
    
  • Cluster node, the current stand-alone version, just fill in the node name above

    # Bootstrap the cluster using an initial set of master-eligible nodes:
    #
    cluster.initial_master_nodes: ["es-node1"]
    

2.4 Modify JVM parameters

Because it is the elasticsearch service installed under the linux of the virtual machine, the JVM memory setting is too large and it will be more difficult. It depends on personal needs. Here I changed the default xms and xmx 1g sizes to 514M.

[root@localhost config]#  vi /usr/local/elasticsearch-7.4.2/config/jvm.options
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
# -Xms1g
# -Xmx1g
-Xms514m
-Xmx514m

2.5 Add user

Because ES does not allow root operation es, you need to add users

[root@localhost config]# useradd esuser
[root@localhost config]# chown -R esuser:esuser /usr/local/elasticsearch-7.4.2

2.6 Start ES

2.6.1 Start-up error

root@localhost config]# su esuser
[esuser@localhost config]$ whoami
esuser
root@localhost config]# cd /usr/local/elasticsearch-7.4.2/bin
root@localhost bin]# ./elasticsearch
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 [3756] 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]

2.6.2 Modify Insert Authentication Mode

Linux PAM: Pluggable Authentication Modules

[esuser@localhost config]$ su root
密码:
[root@localhost config]# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
* Means users, * means all users
soft nproc The maximum number of processes available to a single user (a warning will be issued if it exceeds it);
hard nproc The maximum number of processes available to a single user (exceeding it will report an error);
soft nofile The maximum number of file descriptors that can be opened (a warning will be issued if it exceeds it);
hard nofile The maximum number of file descriptors that can be opened (exceeding it will report an error);

2.6.3 Modify the core configuration of the system

[root@localhost config]# vi /etc/sysctl.conf
vm.max_map_count=262145
[root@localhost bin]# sysctl -p
vm.max_map_count = 262145

2.6.4 Restart

root@localhost config]# su esuser
[esuser@localhost config]$ whoami
esuser
root@localhost config]# cd /usr/local/elasticsearch-7.4.2/bin

2.6.4.1 Foreground start

root@localhost bin]# ./elasticsearch

2.6.4.2 Background startup

root@localhost bin]# ./elasticsearch -d

2.7 Test

The IP of the virtual machine + 9200 can access the ES service

Insert picture description here

2.8 Stop ES service

2.8.1 Foreground start and stop

ctrl + c can stop the command line directly

2.8.2 Start and stop in the background

[root@localhost config]# jps
28696 Elasticsearch
29977 Jps
[root@localhost config]# kill 28696

3 Related information

  • The blog post is not easy, everyone who has worked so hard to pay attention and praise, thank you

Guess you like

Origin blog.csdn.net/qq_15769939/article/details/114249211
Recommended