DEV Community

srsagor
srsagor

Posted on

How to confige Elasticsearch in our local system

In this tutorials we have learn how to config a Elastic search in our local system. Our original Post Here

follow this step and easily configer an Elastic Search.

1) Step 1 — Installing Java :

-Before installing OpenJDK with APT, update the list of available packages for installation on your Ubuntu Droplet by running the command:

$ sudo apt-get update

-After that, you can install OpenJDK with the command:

$ sudo apt-get install openjdk-7-jre

-To verify your JRE is installed and can be used, run the command:

$ java -version

2) Step 2 — Downloading and Installing Elasticsearch :

$ wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.2.deb

-Then install it in the usual Ubuntu way with the dpkg command like this:

$ sudo dpkg -i elasticsearch-1.7.2.deb

-To make sure Elasticsearch starts and stops automatically with the Droplet, add its init script to the default runlevels with the command:

$ sudo update-rc.d elasticsearch defaults

Step 3 — Configuring Elastic :
Laravel Query Builder Where Exists Example

-To start editing the main elasticsearch.yml configuration file:

$ sudo nano /etc/elasticsearch/elasticsearch.yml

-Remove the # character at the beginning of the lines for node.name and cluster.name to uncomment them, and then change their values.

node.name: "My First Node"

cluster.name: mycluster1

-Once you make all the changes, please save and exit the file. Now you can start Elasticsearch for the first time with the command:

$ sudo service elasticsearch start

Step 4 — Securing Elastic :

-Elasticsearch has no built-in security and can be controlled by anyone who can access the HTTP API. So, the first security tweak is to prevent public access. To remove public access edit the file elasticsearch.yml:

$ sudo nano /etc/elasticsearch/elasticsearch.yml

-Find the line that contains network.bind_host, uncomment it by removing the # character at the beginning of the line, and change the value to localhost so it looks like this:

network.bind_host: localhost

-To disable custom expressions, add the following line is at the end of the /etc/elasticsearch/elasticsearch.yml file:

script.disable_dynamic: true

Step 5 — Testing :

$ curl -X GET 'http://localhost:9200' or run http://localhost:9200 in any browser.

You should see the following response:

{

"status" : 200,

"name" : "Harry Leland",

"cluster_name" : "elasticsearch",

"version" : {

"number" : "1.7.2",

"build_hash" : "e43676b1385b8125d647f593f7202acbd816e8ec",

"build_timestamp" : "2015-09-14T09:49:53Z",

"build_snapshot" : false,

"lucene_version" : "4.10.4"

},

"tagline" : "You Know, for Search"

}

Top comments (0)