-
Notifications
You must be signed in to change notification settings - Fork 1
ElasticSearch Setup
To install and set up Elasticsearch 7.x on Ubuntu 22.04, follow these steps:
Elasticsearch 7 requires Java 11 or later. Most installations will use OpenJDK, but you can also use Oracle JDK.
To install OpenJDK 11, run:
sudo apt update
sudo apt install openjdk-11-jdk
Verify the installation:
java -version
You should see output similar to:
openjdk version "11.x.x"
Elasticsearch is not available in the default Ubuntu repositories, so you'll need to add its official repository.
- Download and install the public signing key for the Elasticsearch packages:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo tee /etc/apt/trusted.gpg.d/elasticsearch.asc
- Add the Elasticsearch APT repository:
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
Now, update your package list and install Elasticsearch:
sudo apt update
sudo apt install elasticsearch
Elasticsearch is installed but needs configuration to be properly used.
- Edit the main configuration file:
sudo nano /etc/elasticsearch/elasticsearch.yml
Here are some common settings you might want to modify:
-
Network host: If you plan to run Elasticsearch on a specific interface or IP address, change the
network.host
setting. For example, to bind to all network interfaces, set:network.host: 0.0.0.0
-
Cluster name: If you want to set a specific name for your Elasticsearch cluster (optional), set:
cluster.name: my-cluster
-
Node name: You can set a specific node name for each instance if needed:
node.name: node-1
After modifying, save the file and exit.
Enable the Elasticsearch service to start on boot, and then start the service:
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
You can check the status of Elasticsearch to ensure it's running:
sudo systemctl status elasticsearch
To verify that Elasticsearch is running correctly, use curl
to make an HTTP request:
curl -X GET "localhost:9200/"
You should see a JSON response with information about your Elasticsearch node, similar to this:
{
"name" : "node-1",
"cluster_name" : "my-cluster",
"cluster_uuid" : "exampleuuid",
"version" : {
"number" : "7.x.x",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "examplehash",
"build_date" : "2020-06-01T13:28:45.022056Z",
"build_snapshot" : false,
"lucene_version" : "8.5.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0"
},
"tagline" : "You Know, for Search"
}
If you have a firewall running on your server, you need to allow traffic on port 9200 (the default Elasticsearch HTTP port). For example, if you're using ufw
:
sudo ufw allow 9200
You can also configure Elasticsearch to automatically start on boot:
sudo systemctl enable elasticsearch
If you want a web-based interface to manage and interact with your Elasticsearch data, you can install Kibana.
- Install Kibana:
sudo apt install kibana
- Configure Kibana (if needed) by editing the
kibana.yml
configuration file:
sudo nano /etc/kibana/kibana.yml
Set the server.host
to 0.0.0.0
to allow external access (or configure it for specific IP addresses):
server.host: "0.0.0.0"
- Enable and start the Kibana service:
sudo systemctl enable kibana
sudo systemctl start kibana
-
Access Kibana in your browser:
- Default: http://localhost:5601
You now have Elasticsearch 7.x installed and running on Ubuntu 22.04. Optionally, you can install Kibana for easy management and visualization of data. Make sure to secure your Elasticsearch instance before using it in production, especially if it’s exposed to the internet.