0. first need to install jdk, because elasticsearch is written in Java, Java environment is required by default, and the installation elasticsearch 7.x requires jdk 1.8 or later
1. Execute the following command to create elasticsearch warehouse (7.x version of the plan to install elasticsearch)
cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo [elasticsearch-7.x] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md EOF
2. After the establishment of elasticsearch warehouse, the index needs to be refreshed yum
sudo yum clean all sudo yum makecache
3. Install elasticsearch
sudo yum -y install elasticsearch-oss
4. Edit the file: /etc/elasticsearch/jvm.options, set the memory size:
The default is: -Xms1g -Xmx1g
It can be set to: -Xms256m -Xmx512m
5. Start elasticsearch
sudo systemctl enable --now elasticsearch.service
Use the following command can also start
/etc/init.d/elasticsearch start
6. test to see if start up
[root@localhost ~]# curl http://localhost:9200 { "name" : "localhost.localdomain", "cluster_name" : "elasticsearch", "cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ", "version" : { "number" : "7.3.2", "build_flavor" : "oss", "build_type" : "rpm", "build_hash" : "1c1faf1", "build_date" : "2019-09-06T14:40:30.409026Z", "build_snapshot" : false, "lucene_version" : "8.1.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } [root@localhost ~]# curl http://127.0.0.1:9200 { "name" : "localhost.localdomain", "cluster_name" : "elasticsearch", "cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ", "version" : { "number" : "7.3.2", "build_flavor" : "oss", "build_type" : "rpm", "build_hash" : "1c1faf1", "build_date" : "2019-09-06T14:40:30.409026Z", "build_snapshot" : false, "lucene_version" : "8.1.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } [root@localhost ~]#
7. The current can be used only with 127.0.0.1 localhost access on the server, if you need to use the public access to elasticsearch, also need to configure elasticsearch.yum add the following:
network.host: 0.0.0.0 http.port: 9200 http.cors.enabled: true http.cors.allow-origin: "*" cluster.initial_master_nodes: ["node-1"]
8. Access the results on the server:
[root@localhost elasticsearch]# curl http://192.168.1.27:9200/ { "name" : "localhost.localdomain", "cluster_name" : "elasticsearch", "cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ", "version" : { "number" : "7.3.2", "build_flavor" : "oss", "build_type" : "rpm", "build_hash" : "1c1faf1", "build_date" : "2019-09-06T14:40:30.409026Z", "build_snapshot" : false, "lucene_version" : "8.1.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
Local access results
C:\Users\YFZX-MY-1715>curl http://192.168.1.27:9200 { "name" : "localhost.localdomain", "cluster_name" : "elasticsearch", "cluster_uuid" : "Ybtkma76SSKOmXw89fMnuQ", "version" : { "number" : "7.3.2", "build_flavor" : "oss", "build_type" : "rpm", "build_hash" : "1c1faf1", "build_date" : "2019-09-06T14:40:30.409026Z", "build_snapshot" : false, "lucene_version" : "8.1.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } C:\Users\YFZX-MY-1715>
9. The configuration process, how the start elasticsearch are started up, to see the start log (log file location file are described further elasticsearch.yum), given as follows:
[localhost.localdomain] no plugins loaded [2019-09-19T02:26:21,325][INFO ][o.e.d.DiscoveryModule ] [localhost.localdomain] using discovery type [zen] and seed hosts providers [settings] [2019-09-19T02:26:22,172][INFO ][o.e.n.Node ] [localhost.localdomain] initialized [2019-09-19T02:26:22,173][INFO ][o.e.n.Node ] [localhost.localdomain] starting ... [2019-09-19T02:26:22,508][INFO ][o.e.t.TransportService ] [localhost.localdomain] publish_address {192.168.1.27:9300}, bound_addresses {[::]:9300} [2019-09-19T02:26:22,517][INFO ][o.e.b.BootstrapChecks ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks [2019-09-19T02:26:22,520][ERROR][o.e.b.Bootstrap ] [localhost.localdomain] node validation exception [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 [2019-09-19T02:26:22,549][INFO ][o.e.n.Node ] [localhost.localdomain] stopping ... [2019-09-19T02:26:22,596][INFO ][o.e.n.Node ] [localhost.localdomain] stopped [2019-09-19T02:26:22,597][INFO ][o.e.n.Node ] [localhost.localdomain] closing ... [2019-09-19T02:26:22,618][INFO ][o.e.n.Node ] [localhost.localdomain] closed
Elasticsearch.yum which added to the file:
cluster.initial_master_nodes #: [ " node-1 " , " the Node-2 " ] cluster.initial_master_nodes: [ " node-1 " ] This, then, here is a default node-1 above remember to open it