Introduction to ElasticSearch
What is ElasticSearch:
- ElasticSearch is an open-source search engine built on Apache Lucene
- Written in Java, it provides a simple and easy-to-use RESTFul API
- Easy scale-out to support petabyte-level structured or unstructured data processing
Application Scenarios:
- Massive data analysis engine
- On-site search engine
- As a data warehouse
Document address:The hyperlink login is visible.
Deployment Environment:
CentOS 7 x64-bit, Elasticsearch version 6.5.2, JDK 1.8.0.191
1: Install JDK 1.8.0
ElasticSearch is sensitive to the version of the JRE, and the wrong version will cause ElasticSearch to not work.
2: Download and run ElasticSearch 6.5.2
Download the address page:The hyperlink login is visible.
[root@VM_0_9_centos elasticsearch-6.5.2]# ./bin/elasticsearch OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX: ParallelGCThreads=N [2018-12-11T15:24:27,847] [WARN ] [o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.5.2.jar:6.5.2] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.5.2.jar:6.5.2] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.5.2.jar:6.5.2] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.5.2.jar:6.5.2] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.5.2.jar:6.5.2] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.5.2.jar:6.5.2] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.5.2.jar:6.5.2] Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.5.2.jar:6.5.2] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.5.2.jar:6.5.2] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.5.2.jar:6.5.2] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.5.2.jar:6.5.2] ... 6 more
Elasticsearch requires that you can't run with superuser root, so we can create an account casually, and I have to use the user as es
If there is no error, it runs successfully
Open a new terminal and access it with curl
In the case of making sure that the server port (9200) is on, elasticsearch is started (ps -ef | grep elasticsearch) can be accessed in the browser
[root@VM_0_9_centos local]# curl 'http://localhost:9200/?pretty'
{ "name" : "iUSRV4T", "cluster_name" : "elasticsearch", "cluster_uuid" : "WCbka65VTd2TnM8gQvztqg", "version" : { "number" : "6.5.2", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "9434bed", "build_date" : "2018-11-29T23:58:20.891072Z", "build_snapshot" : false, "lucene_version" : "7.5.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search"
}
3: Access Elasticsearch over the Internet
Edit the elasticsearch configuration file
Find network.host: a line, remove the # sign, and change it to:
(network.host: [_local_, 172.30.6.1] 172.30.6.1 is the specified IP address, which can be multiple IP addresses. Not tested)
Restart Elasticsearch, and then you can access the http://ip:9200 interface on the Internet.
Possible errors:
Mistake one
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] The value of max_map_count refers to the maximum memory map areas available to a process, which is used when calling malloc and is generated by mmap/mprotect.
Workaround: Increase the size of vm.max_map_count:
Mistake two
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] Solution
After the modification, log in to the ES user again and use the following command to check whether the modification is successful
Mistake 3
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12) Solution
atAli saidPossible problems on the
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk Solution: Add the following command to the elasticsearch configuration
|