I have setup the ElasticSearch on my ubuntu but when i try to run sudo systemctl start elasticsearch.service i got an error - elasticsearch

Error:
Job for elasticsearch.service failed because the control process exited with error code.
sudo systemctl status elasticsearch.service:
elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-10-14 02:30:18 PKT; 4min 51s ago
/var/log/elasticsearch/elasticsearch.log:
org.elasticsearch.ElasticsearchSecurityException: invalid configuration for xpack.security.transport.ssl - [xpack.security.transport.ssl.enabled] is >
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:67) ~[elasticsearch-8.4.3.jar:?]
etc/elasticsearch/elasticsearch.yml:
======================== Elasticsearch Configuration =========================
NOTE: Elasticsearch comes with reasonable defaults for most settings.
Before you set out to tweak and tune the configuration, make sure you
understand what are you trying to accomplish and the consequences.
The primary way of configuring a node is via this file. This template lists
the most important settings you may want to configure for a production cluster.
Please consult the documentation for further information on configuration options:
https://www.elastic.co/guide/en/elasticsearch/reference/index.html
---------------------------------- Cluster ----------------------------------
Use a descriptive name for your cluster:
cluster.name: my-application
------------------------------------ Node ------------------------------------
Use a descriptive name for the node:
node.name: node-1
Add custom attributes to the node:
node.attr.rack: r1
----------------------------------- Paths ------------------------------------
Path to directory where to store the data (separate multiple locations by comma):
path.data: /var/lib/elasticsearch
Path to log files:
path.logs: /var/log/elasticsearch
----------------------------------- Memory -----------------------------------
Lock the memory on startup:
bootstrap.memory_lock: true
Make sure that the heap size is set to about half the memory available
on the system and that the owner of the process is allowed to use this
limit.
Elasticsearch performs poorly when the system is swapping the memory.
---------------------------------- Network -----------------------------------
By default Elasticsearch is only accessible on localhost. Set a different
address here to expose this node on the network:
network.host: localhost
By default Elasticsearch listens for HTTP traffic on the first free port it
finds starting at 9200. Set a specific HTTP port here:
http.port: 9200
For more information, consult the network module documentation.
--------------------------------- Discovery ----------------------------------
Pass an initial list of hosts to perform discovery when this node is started:
The default list of hosts is ["127.0.0.1", "[::1]"]
discovery.seed_hosts: ["host1", "host2"]
Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["node-1", "node-2"]
For more information, consult the discovery and cluster formation module documentation.
--------------------------------- Readiness ----------------------------------
Enable an unauthenticated TCP readiness endpoint on localhost
readiness.port: 9399
---------------------------------- Various -----------------------------------
Allow wildcard deletion of indices:
action.destructive_requires_name: false

Related

Elastic Search “master_not_discovered_exception” centos

After deleting /var/lib/elasticseach: Corrected here
I had to delete it because I had some error when trying to search from an index and some stackoverflow answer stated that it was preferable to delete data path and restart elasticsearch.
I'm on centos, and Im trying to configure it for laravel scout.
When I try to do anything such as PUT /index or GET /_cluster/health?pretty I get
{
"error": {
"root_cause": [
{
"type": "master_not_discovered_exception",
"reason": null
}
],
"type": "master_not_discovered_exception",
"reason": null
},
"status": 503
}
Here's my elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: myCluster
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: myNode
node.roles: [master]
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#transport.host: localhost
network.host: 0.0.0.0
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
cluster log
[2020-11-07T13:03:59,571][WARN ][r.suppressed ] [NODE] path: /products, params: {index=products}
org.elasticsearch.discovery.MasterNotDiscoveredException: null
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$2.onTimeout(TransportMasterNodeAction.java:220) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cluster.ClusterStateObserver$ContextPreservingListener.onTimeout(ClusterStateObserver.java:325) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cluster.ClusterStateObserver$ObserverClusterStateListener.onTimeout(ClusterStateObserver.java:252) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.cluster.service.ClusterApplierService$NotifyTimeout.run(ClusterApplierService.java:605) [elasticsearch-7.9.2.jar:7.9.2]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:678) [elasticsearch-7.9.2.jar:7.9.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
at java.lang.Thread.run(Thread.java:832) [?:?]
[2020-11-07T13:04:05,597][WARN ][o.e.c.c.ClusterFormationFailureHelper] [NODE] master not discovered yet, this node has not previously joined a bootstrapped (v7+) cluster, and [cluster.initial_master_nodes] is empty on this node: have discovered [{NODE}{2hEi19WjSn2EsdfsdfYZmmbf158Q}{ZeP6OSGJTa24ggregerghaNOMlYOng}{SERVER_IP}{SERVER_IP:9300}{m}{xpack.installed=true, transform.node=false}]; discovery will continue using [127.0.0.1:9300, [::1]:9300] from hosts providers and [{NODE}{2hazEi19WjSnergza2EYgZmmbfr158Q}{ZeP6OSGJTa24haNOddMlYOng}{SERVER_IP}{SERVER_IP:9300}{m}{xpack.installed=true, transform.node=false}] from last-known cluster state; node term 0, last-accepted version 0 in term 0
I'm fairly new to elastic and for what I'm trying to achieve it's way too complicated.
Since you deleted the data directory, your node never joined a cluster or was bootstrapped before, this is what it is saying in the log line.
You need to set the option cluster.initial_master_nodes so your node will know which nodes are the initial masters.
Uncomment the line for the cluster.initial_master_nodes and add the name of your node.
cluster.initial_master_nodes: ["myNode"]
This will make your node bootstrap itself as the master.
Also, you are setting the option network.host, this will make elasticsearch assumes that you are running into production mode and will force a series of checks, you need to check if you did everything in the important system configurations part of the documentation or your node won't start and give you some exceptions.
If you are accessing your node through localhost, you can comment the network.host option and use it in the development mode.

how to enable Elasticsearch on LAN

I just installed Elasticsarch 7.5.0 on my ubuntu server. I can get elasticsearch from the localhost and I want to be able to access it from another computer, but this is not working. I tried config from the official site: network.host: 0.0.0.0, network.host: 192.168.1.2, but when I restart elasticseach after changing my config, I get this:
Job for elasticsearch.service failed because the control process exited with error code.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.
I have also tried network.host: global, but nothing seem to be working. Any Idea what is the issue here?
my elasticsearch.yml file looks like this:
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#network.host: 0.0.0.0
#network.bind_host: 0.0.0.0
#network.publish_host: 0.0.0.0
#
#
#network.host: 192.168.0.1
#network.host: 10.10.10.16
#network.host: 0.0.0.0
network.host: '_global_'
#
# Set a custom porti for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["127.0.0.1", "0.0.0.0"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
I finally found the issue:
network.host: _enp0s3_
discovery.seed_hosts: 0.0.0.0
after setting these parameters it worked find.

Elasticsearch 7.4 Multi Clustering configuration

I am trying to make an Elasticsearch cluster with two nodes. Most of the documents in Google are about lower version clustering since they talk about discover.zen.ping.unicast.hosts which 7.4 doesn't have.
Two nodes are AWS EC2 instances.
Each Elasticservice is running fine but I don't think they are clustered. ( _cluster/health , _nodes API).
I made changes in /etc/hosts.
elasticsearch.yml for node-1 :
# ---------------------------------- Cluster -----------------------------------
cluster.name: dsm-001
# ------------------------------------ Node ------------------------------------
node.name: node-1
# ----------------------------------- Paths ------------------------------------
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
# ---------------------------------- Network -----------------------------------
#network.host: 192.168.0.1
http.port: 9200
# --------------------------------- Discovery ----------------------------------
discovery.seed_hosts: ["node-1","node-2"]
cluster.initial_master_nodes: ["node-1","node-2"]
elasticsearch.yaml for node-2 :
# ---------------------------------- Cluster -----------------------------------
cluster.name: dsm-001
# ------------------------------------ Node ------------------------------------
node.name: node-2
# ----------------------------------- Paths ------------------------------------
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
# ---------------------------------- Network -----------------------------------
#network.host: 192.168.0.1
http.port: 9200
# --------------------------------- Discovery ----------------------------------
discovery.seed_hosts: ["node-1","node-2"]
cluster.initial_master_nodes: ["node-1","node-2"]
While the cluster.initial_master_nodes property requires names that match actual elasticsearch node names ("node-1" and "node-2"), the discovery.seed_hosts property expects host names or addresses (e.g. "server1", 192.168.1.12") and not Elasticsearch node names. This is what you need to fix first.
But as you run your nodes in AWS, you are expected to install the EC2 Discovery Plugin to help you locating
the seed addresses of your Elasticsearch nodes (see the Elasticsearch Reference Documentation: EC2 Discovery Plugin)
With Elasticsearch 7 the cluster coordination layer has been rewritten, making your cluster much more robust, but also making the first start-up of a node extremely important. The cluster.initial_master_nodes property is only used when starting up a node for the very first time. If you did so, and your node did not join the expected cluster (and most likely created its own cluster), you need to stop your node, delete the data directory (to clear the cluster state) and restart it.
For Additional Help
Finally, I figured it out.
If Daniel's answer doesn't work for you, add the following.
---------------------------Network-----------------------------------
network.host: Your Public DNS (IPv4) // For example, ec2-1-1-1-1.ap-northeast-1.compute.amazonaws.com
----------------------------Discovery------------------------------------
discovery.seed_hosts : [" ip" , "ip" ] // like Daniel said.
discovery.seed_providers: ec2

Elasticsearch Error "bootstrap checks failed" (Binding non-loopback address)

Recently, after installation of Elasticsearch 7.3.2, I found out that the server is working fine when bound to the localhost or 127.0.0.1.
But I made it available for external use, that is on particular IP or 0.0.0.0, it raised me error and stopped the server:
bound or publishing to a non-loopback address, enforcing
bootstrap checks
[2019-09-19T18:21:43,962][ERROR][o.e.b.Bootstrap ] [MARFEEN] node validation exception
[1] bootstrap checks failed
Could not get any answer on this solution, most of them were related to max opened file limits. But it was solved when I enabled a config property discovery.seed_hosts in elasticsearch.yml file:
# ---------------------------------- 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
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["127.0.0.1"]
After enabling the above property, it worked fine on non-loopback host also.
Most of the users don't know that setting network.host: 0.0.0.0 will cause the production bootstrap check and this is the cause of failure as mentioned in the below line of the error message.
[o.e.b.Bootstrap ] [MARFEEN] node validation exception [1] bootstrap
checks failed
In order, to resolve the issue when you are running Elasticsearch in development mode or with a single node, please add below config in (Elasticsearch.config) to avoid above mentioned checks.
discovery.type: single-node --> In case of single node Elasticsearch cluser
es.enforce.bootstrap.checks=false. --> Explicitly disable these checks in Non-production env.
Your answer is correct. This is set this way so that the health check forces your configuration to be presenting an external address before the node comes online.
The way you have configured it will work, so long as you do not require any special cluster conditions. At that point, you will need to set network.host: to an external IP/hostname.

why Elasticsearch still complains about bootstrap checks failed

Installed ElasticSearch 7.3.0 on Ubuntu 18.04. Was able to start it in development mode. Now I want to connect to ES remotely from another machine, so I changed the configuration in elasticsearch.yml and tried to start it in production mode (although there's still only one ES machine). Below is my elasticsearch.yml file:
However, everytime after I run the 'sudo systemctl start elasticsearch.service' command, the elasticsearch gave me this warning "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".
As you can see in the first image, I do configure the cluster.initial_master_nodes correctly. So what did I miss here?
---Updates-------------------------------------------------------------------------------------------------------------------
I just realized that no matter how many times I tried to restart the elasticsearch service, for some reason it is not updating the log file. As you can see the timestamp for the last log is 2019-08-10, which is yesterday. I am pretty sure I restarted the service this morning several times and today is 2019-08-11. P.S. I am in UTC-8 timezone.
I fixe the issue.
Edit elasticsearch.yml
Make following changes / updates:
Cluster Section - uncomment cluster.name:
Give the cluster a name. I named mine ELK, but you can use whatever you want to name the cluster.
Note: you don't have to technically run a cluster for this to work...
Node Section - uncomment node.name: & cluster.initial_master_nodes:
Give the node a name. I named mine ES1, but you can use whatever you want to name the node.
Discovery Host Section - uncomment discovery.seed_hosts:
Enter the node.name. I entered ["ES1"] for both line items.
Save the config file
Start elasticsearch.service
The answer by user1496433 works. Here's the full yml file in case it's helpful to anyone:
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: dev-logs
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: dev-logs-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- 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: 9400
#
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With,X-Auth-Token,Content-Type, Content-Length, Authorization"
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["dev-logs-1"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["dev-logs-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

Resources