Thursday, 5 November 2020

elasticsearch Install And Setup Elasticsearch Engine On Linux

 Elasticsearch install step by step

java -v

java -version

echo $JAVA_HOME

ls /usr/lib/jvm//java-

for Result

java-1.7.0-openjdk-amd64/ java-1.8.0-openjdk-amd64/ java-7-openjdk-amd64/     java-8-openjdk-amd64/


==============================================================

for run Tab ke through check karna hai: echo /usr/lib/jvm/java-8-openjdk-amd64/

==============================================================

Set environment variable:

sudo nano /etc/environment


JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

PATH=$PATH:$HOME/bin:$JAVE_HOME/bin

export JAVE_HOME

export JRE_HOME

export PATH


============================================================


Run: echo $JAVA_HOME

For result: /usr/lib/jvm/java-8-openjdk-amd64/



===================================================================


sudo apt-get install apt-transport-https

==================================================================


wget https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -


====================================================================


sudo add-apt-repository "deb https://artifacts.elastic.co/packages/6.x/apt stable main"


==================================================================


sudo apt update


=====================================


sudo apt install elasticsearch


Getting this error: sudo apt install elasticsearch

Reading package lists... Done

Building dependency tree       

Reading state information... Done

E: Unable to locate package elasticsearch


For solve: 
On terminal: wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-archive-keyring.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list > /dev/null

sudo apt update

sudo apt-get install elasticsearch

sudo systemctl enable elasticsearch

------------------------------------------------

When getting this error:

sudo systemctl enable elasticsearch Synchronizing state of elasticsearch.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable elasticsearch


Then run this command: sudo systemctl is-enabled elasticsearch


---------------------------------------------

sudo systemctl start elasticsearch

Check the status: sudo systemctl status elasticsearch


====================================


sudo nano /etc/elasticsearch/elasticsearch.yml
is file me must nhi hai change karna, kyu ki default me port 
9200 hota hai and host 127.0.0.1 hota hai


Only for:


Uncomment line


cluster.name: my-elasticsearch


node.name: elasticsearch-1


path.data: /var/lib/elasticsearch

path.logs: /var/log/elasticsearch


http.port: 9200


=====================================


sudo systemctl start elasticsearch


======================================


Check status:


sudo systemctl status elasticsearch.service


For this resulte


elasticsearch.service - Elasticsearch

   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)

   Active: active (running) since Thu 2020-11-05 17:48:01 IST; 11s ago

     Docs: https://www.elastic.co

 Main PID: 8632 (java)

    Tasks: 63

   Memory: 1.2G

      CPU: 59.206s

   CGroup: /system.slice/elasticsearch.service

           ├─8632 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10

           └─8831 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller



======================================


curl -X GET http://127.0.0.1:9200


{

  "name" : "elasticsearch-1",

  "cluster_name" : "my-elasticsearch",

  "cluster_uuid" : "OL-ZPjVBTcG4b9HlEgnOdw",

  "version" : {

    "number" : "7.9.3",

    "build_flavor" : "default",

    "build_type" : "deb",

    "build_hash" : "c4138e51121ef06a6404866cddc601906fe5c868",

    "build_date" : "2020-10-16T10:36:16.141335Z",

    "build_snapshot" : false,

    "lucene_version" : "8.6.2",

    "minimum_wire_compatibility_version" : "6.8.0",

    "minimum_index_compatibility_version" : "6.0.0-beta1"

  },

  "tagline" : "You Know, for Search"

}


==============================================



Link: https://www.youtube.com/watch?v=63nS1Z-pIfI