🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Elastic Tutorial: Elasticsearch 8.X Installation & CRUD in Linux


Terminal#1
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.9.1-linux-x86_64.tar.gz
$ tar -zxvf elasticsearch-8.9.1-linux-x86_64.tar.gz
$ cd elasticsearch-8.9.1
$ ls config/
$ cd bin
$ ./elasticsearch

Terminal#2
$ curl --cacert /home/ubuntu/elasticsearch-8.9.1/config/certs/http_ca.crt -u elastic https://localhost:9200
Enter host password for user 'elastic':
{
  "name" : "ip-172-31-58-60",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "dvbfb_NLS6qy1iuhc4yvKA",
  "version" : {
    "number" : "8.9.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "a813d015ef1826148d9d389bd1c0d781c6e349f0",
    "build_date" : "2023-08-10T05:02:32.517455352Z",
    "build_snapshot" : false,
    "lucene_version" : "9.7.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

Elasticsearch 8.X in Centos 7
-------------------------------
192.168.1.8
https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html
$ yum install wget unzip -y
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.4.2-linux-x86_64.tar.gz
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.4.2-linux-x86_64.tar.gz.sha512
$ shasum -a 512 -c elasticsearch-8.4.2-linux-x86_64.tar.gz.sha512
$ tar -xzf elasticsearch-8.4.2-linux-x86_64.tar.gz
$ cd elasticsearch-8.4.2/
----------------------------------------
elasticsearch can not with user called "root"
$ useradd elastic
$ passwd elastic
$ su elastic
Elasticsearch security features have been automatically configured!
Authentication is enabled and cluster connections are encrypted.
Password for the elastic user
===========================================
Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
YrfJHfoQtniJqzyD4pM3
HTTP CA certificate SHA-256 fingerprint:
===========================================
dc31d8f9d6d6f6223743e13a04fc0c107c1c253a37ef25d2a99b2733235b1e5e
Configure Kibana to use this cluster:
===========================================
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjQuMiIsImFkciI6WyIxOTIuMTY4LjEuODo5MjAwIl0sImZnciI6ImRjMzFkOGY5ZDZkNmY2MjIzNzQzZTEzYTA0ZmMwYzEwN2MxYzI1M2EzN2VmMjVkMmE5OWIyNzMzMjM1YjFlNWUiLCJrZXkiOiJxMTlyWG9NQnNQMjdDeDNIUEFIZDp5bVJ4S1ZPWFM0ZWt4SS1RNzFicjJRIn0=
Configure other nodes to join this cluster:
===========================================
• On this node:
⁃ Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
⁃ Uncomment the transport.host setting at the end of config/elasticsearch.yml.
⁃ Restart Elasticsearch.
• On other nodes:
⁃ Start Elasticsearch with `bin/elasticsearch --enrollment-token <token>`, using the enrollment token that you generated.
=======================================
curl http://localhost:9200
curl --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic https://localhost:9200
Enter host password for user 'elastic':
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "DwtXLUGKSB2Oy5piLMeArw",
"version" : {
"number" : "8.4.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "89f8c6d8429db93b816403ee75e5c270b43a940a",
"build_date" : "2022-09-14T16:26:04.382547801Z",
"build_snapshot" : false,
"lucene_version" : "9.3.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
curl --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 https://localhost:9200
curl -XPUT --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products?&pretty'
curl -XGET --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/_cat/indices?v&pretty'
------------ NOT WORKING FOR 8.X -------------------------
curl -XPUT --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products/mobiles/1?pretty' -H 'Content-Type: application/json' -d'
{
"name": "iPhone 7",
"camera": "12MP",
"storage": "256GB",
"display": "4.7inch",
"battery": "1,960mAh",
"reviews": ["Incredibly happy after having used it for one week", "Best iPhone so far", "Very expensive, stick to Android"]
}
'
------------ WORKING FOR 8.X -------------------------
curl -XPUT --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products/_doc/1' -H 'Content-Type: application/json' -d'
{
"name": "iPhone 7",
"camera": "12MP",
"storage": "256GB",
"display": "4.7inch",
"battery": "1,960mAh",
"reviews": ["Incredibly happy after having used it for one week", "Best iPhone so far", "Very expensive, stick to Android"]
}
'
curl -XPUT --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products/_doc/3' -H 'Content-Type: application/json' -d'
{
"name": "iPhone 7",
"camera": "12MP",
"storage": "256GB",
"display": "4.7inch",
"battery": "1,960mAh",
"reviews": ["Incredibly happy after having used it for one week", "Best iPhone so far", "Very expensive, stick to Android"]
}
'
curl -XPUT --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products/_doc/4' -H 'Content-Type: application/json' -d'
{
"name": "iPhone 7",
"camera": "12MP",
"storage": "256GB",
"display": "4.7inch",
"battery": "1,960mAh",
"reviews": ["Incredibly happy after having used it for one week", "Best iPhone so far", "Very expensive, stick to Android"]
}
'
curl -XPOST --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products/_doc' -H 'Content-Type: application/json' -d'
{
"name": "iPhone 7",
"camera": "12MP",
"storage": "256GB",
"display": "4.7inch",
"battery": "1,960mAh",
"reviews": ["Incredibly happy after having used it for one week", "Best iPhone so far", "Very expensive, stick to Android"]
}
'
curl -XGET --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products'
curl -XGET --cacert /home/elastic/elasticsearch-8.4.2/config/certs/http_ca.crt -u elastic:YrfJHfoQtniJqzyD4pM3 'https://localhost:9200/products/_search?pretty=true&q=*:*'
Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x