On this topic, We are going to discuss one of the best full-text search and analytics engine and how to Install and uninstall of Elastic Search in Ubuntu.
What is Elastic Search?
- Non root user
- Minimum 4GB RAM.
Step 1 — Installing Java
Elastic search requires Java because it is built in Java. Elastic search supports higher 1.7 Java version. Below is a command to install the Java in Ubuntu.
sudo apt-get install default-jdk
echo $JAVA_HOME /usr/lib/jvm/java-8-oracle
Now check the Java version by executing below command
Step 2 — Install Elasticsearch on Ubuntu
We have configured Prerequsities for the elastic search on step 1 and 2. Now in this step, we will install the elastic search. First, we will add the official elastic apt repository, package and import GPG key in your system.
sudo apt-get install apt-transport-https
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
add-apt-repository "deb https://artifacts.elastic.co/packages/7.x/apt stable main"
we have completed the adding apt repository and required key into system. Now run below command to install the elastic search. It always installs the stable version into your system.
sudo apt-get update
sudo apt-get install elasticsearch
Step 3 — Configuration of ElasticSearch
We have installed the elastic search in your system. We can customize the elastic search by updating the elasticsearch.yml. You can edit by any of your editors. I am using vi for editing the file.
sudo vi /etc/elasticsearch/elasticsearch.yml
Update the below values.
Step 4 — SysV init to Elastic Search
To start and stop the elastic search is dependent on the SysV init or systemd. You can tell which is being used by running this command:
ps -p 1
Execute the below command to tell the system to start the elastic search on the boot-up.
sudo update-rc.d elasticsearch defaults 95
Below command to start and stop the elastic search
sudo -i service elasticsearch start
sudo -i service elasticsearch stop
Below command to see the elastic search logs.
sudo journalctl --unit elasticsearch
Below is the list of the default directory where elastic search installation and logs present in the system.
|Elastic search home directory it includes binary files||/usr/share/elasticsearch|
|Elastic search configuration files||/etc/elasticsearch|
|Elastic Search logs directory||/var/log/elasticsearch|
So we learned how to install the elastic search in ubuntu along with default directory of elastic search. In the next step, we are going to learn about the uninstall of elastic search.
Step 5 — Uninstall of ElasticSearch.
To uninstall the elastic search run below command.
sudo apt-get --purge autoremove elasticsearch
Step 6 — Clean up Elastic files.
After the uninstall remove the ElasticSearch directories.
sudo rm -rf /var/lib/elasticsearch/
sudo rm -rf /etc/elasticsearch