Install Elasticsearch on Centos 7 and configure

ToInstall Elasticsearch on Centos 7, you can follow these steps. Note that software versions may have changed since my last update, so it’s always a good idea to check the official Elasticsearch documentation for the latest instructions.

1. Install Java:

Elasticsearch requires Java to run. You can install OpenJDK with the following command:

bash
sudo yum install java-1.8.0-openjdk

2. Import the Elasticsearch GPG Key:

bash
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

3. Add Elasticsearch Repository:

Create a new repository file for Elasticsearch:

bash
sudo nano /etc/yum.repos.d/elasticsearch.repo

Add the following lines to the file:

ini
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

Save and exit the text editor.

4. Install Elasticsearch:

bash
sudo yum install elasticsearch

5. Configure Elasticsearch:

Open the Elasticsearch configuration file:

bash
sudo nano /etc/elasticsearch/elasticsearch.yml

Find and configure the following settings:

yaml
# Set the cluster name
cluster.name: my-cluster

# Set the node name
node.name: my-node

# Set the network host to bind to a specific IP address
network.host: 127.0.0.1

# Set the discovery type to single-node
discovery.type: single-node

Save and exit the text editor.

6. Start and Enable Elasticsearch:

bash
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch

7. Test Elasticsearch:

You can test if Elasticsearch is running by accessing its RESTful API. Open your web browser and navigate to:

arduino
http://localhost:9200

You should see a JSON response indicating that Elasticsearch is up and running.

That’s it! Elasticsearch should now be installed and configured on your CentOS 7 server. Remember to check the official Elasticsearch documentation for any updates or changes to the installation process.

Leave a Reply