Elasticsearch profile
Elasticsearch is a distributed, free, open source search and analysis engine for all types of data including text, digital, geospatial, structured and unstructured data, and more. Elasticsearch is a Lucene-based search server. It provides a distributed multi – user – capable full – text search engine based on RESTful Web interface. Elasticsearch, developed in the Java language and released as open source under the Apache license, is a popular enterprise-level search engine. Elasticsearch for cloud computing is stable, reliable, fast, easy to install and use. 【 Details 】
Elasticsearch has been installed
- Linux CentOS 7.8
- JDK 11 installation and tutorials
Elasticsearch 7.12.1
Official website download address
Download and unzip:
CD/softwares wget tar at https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-linux-x86_64.tar.gz - ZXVF elasticsearch 7.12.1 - Linux - x86_64. Tar. GzCopy the code
Create a user and authorize it
# create user elasticUser userAdd elasticUser # set password passwd elasticUser # authorize user elasticUser chow-r Elasticuser /software/ ElasticSearch -7.12.1 chmod -r 777 /software/ ElasticSearch -7.12.1Copy the code
Modify the configuration
Edit config/ elasticSearch. yml, append the content to the end of the file and save it
# = = = = = = = = = = = = = = = = = = = = = = = = Elasticsearch Configuration = = = = = = = = = = = = = = = = = = = = = = = = = # configure Elasticsearch cluster name, Elasticsearch cluster.name: my-elasticsearch cluster.name: my-elasticsearch cluster.name: my-elasticsearch Node-1 #network. Host: 0.0.0.0 #Elasticsearch HTTP access port HTTP. 9200 # This configuration is required to elect master cluster.initial_master_nodes: node-1 when initializing a new clusterCopy the code
Start the Elasticsearch service
Switch to the non-root ES user created above, elasticUser
su elasticuser
Copy the code
Switch to ElasticSearch -7.12.1/bin and execute
CD/softwares/elasticsearch - 7.12.1 / bin. / elasticsearchCopy the code
If started is displayed, the startup is successful
You can visit http://IP at 9200/
Register the service and set it to boot
vim /usr/lib/systemd/system/elasticsearch.service
Copy the code
Save the following information
[Unit] Description=elasticsearch After=network.target [Service] Type=forking User=elastic ExecStart=/softwares/ ElasticSearch -7.12.1/bin/ elasticSearch -d PrivateTmp=true # Specifies the maximum number of files this process can open LimitNOFILE=65535 # LimitNPROC=65535 # Maximum virtual memory LimitAS= Infinity # Maximum file size LimitFSIZE= Infinity # Timeout set 0- Never timeout TimeoutStopSec=0 # SIGTERM is the signal to stop the Java process KillSignal=SIGTERM # The signal is only sent to the JVM KillMode=process # The Java process will not be killed SendSIGKILL=no # Normal exit status SuccessExitStatus=143 [Install] WantedBy=multi-user.targetCopy the code
Refresh the configuration
systemctl enable elasticsearch.service
Copy the code
Commands related to Elasticsearch services
Elasticsearch. service systemctl restart elasticSearch. service systemctl restart elasticsearch.service Elasticsearch. service systemctl disable ElasticSearch. service Systemctl enable elasticSearch. serviceCopy the code
Error exception and resolution
-
Error when using root user:
Switch to a non-root user and run ElasticSearch
[root@xxx bin]# su elasticuser
[elasticuser@xxx bin]$ ./elasticsearch
Copy the code
-
Insufficient memory error:
# Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
The killed service released the memory
./elasticsearch
killed
Copy the code
JVM space allocation is changed because elasticsearch7.12.1 has a default JVM space allocation of 4g
Modify jvm.options in config of elasticSearch installation directory
vim config/jvm.options
-xms1g -xmx1g #Xms512m #Xmx512m #Xms512mCopy the code
Save the configuration file and restart it
./elasticsearch
Copy the code
-
Startup error:
# max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
The maximum virtual memory is too small. Add a line at the end of /etc/sysctl.conf
vm.max_map_count=655360
Copy the code
The /sbin/sysctl -p command takes effect immediately
/sbin/sysctl -p
Copy the code
Restart ElasticSearch
./elasticsearch
Copy the code