One, foreword
1. Main contents of this paper
- Procedure For installing Elasticsearch in CentOS
- Visualization tool Elasticsearch-head installation
3. Environmental information of this article
- The server
The operating system | The hardware configuration | IP | instructions |
---|---|---|---|
CentOS 7 | 4C16G | 192.168.0.11 | Elasticsearch deployment |
- software
Tools/Environment | version |
---|---|
Elasticsearch | 7.12.1 |
Second, preparation
Elasticsearch can be installed using installation packages, docker, and yum. You can install Elasticsearch using basic installation packages.
1. Download the installation package
The latest edition of the official download address: www.elastic.co/cn/download…
History version download address: www.elastic.co/cn/download…
#Download the installation package, in this case version 7.12.1
$Wget HTTP: / / https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-linux-x86_64.tar.gz
#Unpack the
$Tar - ZXVF elasticsearch 7.12.1 - Linux - x86_64. Tar. Gz
#Move the directory, typically installing such software at /usr/localdirectory
$The mv elasticsearch - 7.12.1 / usr /local
Copy the code
2. Configure elasticSearch.xml
This configuration file is the core of the Elasticsearch configuration file, in Elasticsearch – 7.12.1 / config/Elasticsearch. XML directory
-
Changing the cluster Name
Es also has a cluster name by default, which can be changed to suit your needs. Although we are on a standalone deployment, we will also have the cluster name by default.
cluster.name: es-cluster Copy the code
-
Changing the Node Name
node.name: es-node-1 Copy the code
-
Modify data and log storage addresses
#Create a data directory to store data $ pwd/ usr/local/elasticsearch - 7.12.1$ mkdir data #To modify the configuration file, find the following two options and modify themPath. The data: / usr/local/elasticsearch - 7.12.1 / data path. The logs: / usr/local/elasticsearch - 7.12.1 / logsCopy the code
-
Modify es network information to make it accessible to external machines
Network. The host: 0.0.0.0Copy the code
-
You can also change the cluster node name
cluster.initial_master_nodes: ["es-node0"] Copy the code
Modify JVM parameters for Elasticsearch
If you install it yourself, adjust it according to the configuration of your machine, and configure the production environment as required.
Modify the configuration file path: / usr/local/elasticsearch 7.12.1 / config/JVM options
#Find the -xms-xmx option, I set it to 512MB
-Xms512m
-Xmx512m
Copy the code
4. Other modifications
If these configurations are not modified, an error will be reported when starting ES. Such as:
[4] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3818] for user [admin] 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]
Copy the code
Modify the limits. The conf:
#This requires administrator privileges
$ vim /etc/security/limits.conf
#Add the following
* soft nofile 65535
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
Copy the code
Modify the sysctl. Conf:
#This requires administrator privileges
$ vim /etc/sysctl.conf
vm.max_map_count=262144
#refresh
$ sysctl -p
Copy the code
5. Start user instructions
Elasticsearch does not allow you to use root to start Elasticsearch. If you are playing on a VM, you may use root to start Elasticsearch.
#Example Create the esuser user
$ useradd esuser
#Grant all permissions on elasticSearch -7.12.1 to esuser
$ chown -R esuser:esuser /usr/local/ elasticsearch - 7.12.1
#Switch the user
$ su esuser
Copy the code
6. Open port number
Elasticsearch requires two default port numbers: 9200 and 9300
9200: Uses HTTP protocol, used to provide external interaction;
9300: TCP is used for intra-cluster communication.
# open port 9200, 9300,root if your firewall is enabled, or disable the firewall (on your own vm)
$ firewall-cmd --zone=public --add-port=9200/tcp --permanent
$ firewall-cmd --zone=public --add-port=9300/tcp --permanent
# override firewall rules
sudo firewall-cmd --reload
Copy the code
Three, start and test
1, start,
#Go to the directory with the startup command
$ cd /usr/local/ elasticsearch - 7.12.1 / bin
#Start foreground mode, you can see the startup log information, press CTRL + C to stop
$ ./elasticsearch
#Background Startup
$ ./elasticsearch -d
#Stop mode, find the corresponding process number,killOff to
$ ps -ef|grep elasticsearch
Copy the code
2, test,
Visit http://ip:9200. If the following information is displayed, the startup is successful
Install the Elasticsearch-head visualization tool
Elasticsearch-head is a tool for browsing and interacting with Elasticsearch clusters.
Github open Source: github.com/mobz/elasti…
Supports multiple installation methods
- How source code is compiled;
- Install using Docker image;
- Install the plugin in Chrome.
- Install as Elasticsearch plugin (officially not recommended)
Without a doubt, adding a plugin to your browser is the easiest way to do it. If you’re interested in other ways, go to Github and browse.
If you can scientifically surf the Web, just go to Google’s Plugin marketplace and do a search.
If you can’t, you can download the Elasticsearch package by clicking “Elasticsearch-head”.
How to manually add plug-ins not to say, should be all, not the private letter I.
Once installed, it looks like this:
Ps: If you use compiled source partners, after installation, there may be cross-domain problems. For elasticSearch, add elasticSearch. yml to the config folder of elasticSearch.
http.cors.enabled: true
http.cors.allow-origin: "*"
Copy the code
Finally, if you have any questions, please follow the official account “Hugh’s Whiteboard” and send me a private message to discuss and learn together. Come on!