{"id":3360,"date":"2024-03-26T23:19:15","date_gmt":"2024-03-26T15:19:15","guid":{"rendered":"https:\/\/chow.karmeng.my\/?p=3360"},"modified":"2024-03-26T23:19:15","modified_gmt":"2024-03-26T15:19:15","slug":"elasticsearch-8-12-kibana-cluster-using-vagrant-and-docker-compose","status":"publish","type":"post","link":"https:\/\/chow.karmeng.my\/?p=3360","title":{"rendered":"ElasticSearch 8.12 kibana cluster using vagrant and docker compose"},"content":{"rendered":"\n<p><strong>Pre-requisite:<\/strong><br>&#8211; VirtualBox 7.0.14<br>&#8211; Vagrant 2.4.1<br>&#8211; Windows 10 or better OS<br>&#8211; 16GB RAM (10GB RAM are required for creating ElasticSearch with kibana; 1GB and 2 x ElasticSearch node; 4GB each, rest of the RAM for VM host OS)<\/p>\n\n\n\n<p><strong>Overview:<\/strong><br>There are 2 layers of virtualization, first the Virtual Box, then the docker engine running in the Virtual Box VM running on Ubuntu 20.04 focal.<\/p>\n\n\n\n<p>Orchestration used in the host OS level; Windows 10 are the <a href=\"https:\/\/www.vagrantup.com\/\" data-type=\"link\" data-id=\"https:\/\/www.vagrantup.com\/\">hashicorp vagrant<\/a>. The vagrant is used to configure the VM Ubuntu OS to be configured to run properly configured docker and Ubuntu 20.04.<\/p>\n\n\n\n<p>Then docker compose v2 are used to create the ElasticSearch 8.12 cluster or stack.<\/p>\n\n\n\n<p>The downside of this example, vagrant up needs to be run initially to configure the VM Ubuntu 20.04 OS. I have yet to discover if Vagrant has the ability to bootstrap grub and configuring the sysctl to allow the docker engine to run properly with the ElasticSearch 8.12 stack.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Here are the <a href=\"https:\/\/bitbucket.org\/KarMeng\/docker_elasticsearch812\/src\/main\/\" data-type=\"link\" data-id=\"https:\/\/bitbucket.org\/KarMeng\/docker_elasticsearch812\/src\/main\/\">bitbucket repository<\/a> that contains the codes that is mentioned in this post.<\/p>\n\n\n\n<p>Overview of this repo is as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-5.png\" alt=\"\" class=\"wp-image-3364\"\/><figcaption class=\"wp-element-caption\">File structure of the ElasticSearch 8.12 running on docker in Ubuntu 20.04 VM<\/figcaption><\/figure>\n\n\n\n<p><strong>Steps:<\/strong><br>1. Run the vagrant up in the project localdev<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-2-1024x596.png\" alt=\"\" class=\"wp-image-3361\"\/><figcaption class=\"wp-element-caption\">Vagrant up to start creating the VBox VM that will be running ElasticSearch 8.12 in docker container<\/figcaption><\/figure>\n\n\n\n<p>2. Wait for the vagrant up to complete<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-3-1024x596.png\" alt=\"\" class=\"wp-image-3362\"\/><figcaption class=\"wp-element-caption\">Vagrant up completed, the first time running will force provision shell in Vagrantfile to run and configure the VM host Ubuntu OS to works fine with<\/figcaption><\/figure>\n\n\n\n<p>3. Confirm the provision script complete by running &#8220;vagrant status&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-6.png\" alt=\"\" class=\"wp-image-3365\"\/><figcaption class=\"wp-element-caption\">Confirm VM are powered off using &#8220;vagrant status&#8221;<\/figcaption><\/figure>\n\n\n\n<p>4. If the VM is powered off, rerun &#8220;vagrant up&#8221;, then run &#8220;vagrant ssh&#8221; to login into the VirtualBox VM.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-7-1024x595.png\" alt=\"\" class=\"wp-image-3366\"\/><figcaption class=\"wp-element-caption\">Windows command prompt indicating that the vagrant ssh are successfully logon into VM shell<\/figcaption><\/figure>\n\n\n\n<p>5. Start up the ElasticSearch 8.12 with 2 ElasticSearch nodes in docker container, cd into \/data\/docker, then run &#8220;sudo docker compose -f docker-compose-duo.yml up -d&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-8-1024x169.png\" alt=\"\" class=\"wp-image-3367\"\/><figcaption class=\"wp-element-caption\">Starting up ElasticSearch 8.12 in the VirtualBox VM<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-9-1024x544.png\" alt=\"\" class=\"wp-image-3368\"\/><figcaption class=\"wp-element-caption\">If everything is fine, and the images repo from docker hub will be downloaded for the first time, extracted before running as container in the VM.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-10-1024x589.png\" alt=\"\" class=\"wp-image-3369\"\/><figcaption class=\"wp-element-caption\">the docker compose for ElasticSearch 8.12 completed without issues<\/figcaption><\/figure>\n\n\n\n<p>6. Confirm the status of the containers, run in the terminal &#8220;sudo docker ps&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-11-1024x192.png\" alt=\"\" class=\"wp-image-3370\"\/><figcaption class=\"wp-element-caption\">Proof of containers of ElasticSearch and Kibana are running<\/figcaption><\/figure>\n\n\n\n<p>This however does not proof that the stacks are completed correctly.<\/p>\n\n\n\n<p>Use the &#8220;docker logs&#8221; to check all the containers.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-12-1024x637.png\" alt=\"\" class=\"wp-image-3371\"\/><figcaption class=\"wp-element-caption\">Check last 5 line of logs from container ElasticSearch node, es01<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-13-1024x561.png\" alt=\"\" class=\"wp-image-3372\"\/><figcaption class=\"wp-element-caption\">Check last 5 line of logs from container ElasticSearch node, es02<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-14-1024x543.png\" alt=\"\" class=\"wp-image-3373\"\/><figcaption class=\"wp-element-caption\">Check last 13 line of logs from container Kibana<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-16.png\" alt=\"\" class=\"wp-image-3375\"\/><figcaption class=\"wp-element-caption\">The official kibana template provides a setup container that are used to create certificate and assigning passwords into nodes. <\/figcaption><\/figure>\n\n\n\n<p>Other than the checking all the ElasticSearch containers, and kibana, the setup container will be stop running and provide the logs as seen to indicate the configuration of the ElasticSearch is completed.<\/p>\n\n\n\n<p>Finally, to put all into a complete conformation, use browser to visit the kibana and ElasticSearch interface.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-17-1024x343.png\" alt=\"\" class=\"wp-image-3376\"\/><figcaption class=\"wp-element-caption\">Kibana is running on http:\/\/127.0.0.1:5601<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-18-1024x550.png\" alt=\"\" class=\"wp-image-3377\"\/><figcaption class=\"wp-element-caption\">Successful login, first time into Kibana, now just call it as Elastic<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-19-1024x409.png\" alt=\"\" class=\"wp-image-3378\"\/><figcaption class=\"wp-element-caption\">The problem of self-signed certificate, just click continue<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-20-1024x335.png\" alt=\"\" class=\"wp-image-3379\"\/><figcaption class=\"wp-element-caption\">Use the default elastic username and password to logon into the ElasticSearch node at https:\/\/127.0.0.1:9200<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-21.png\" alt=\"\" class=\"wp-image-3380\"\/><figcaption class=\"wp-element-caption\">After signing on successfully into https:\/\/127.0.0.1:9200<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/chow.karmeng.my\/wp-content\/uploads\/2024\/03\/image-22-1024x352.png\" alt=\"\" class=\"wp-image-3381\"\/><figcaption class=\"wp-element-caption\">Proof that kibana (now known as Elastic) and ElasticSearch cluster are interconnected. <\/figcaption><\/figure>\n\n\n\n<p>To truly ensure that the Elastic (kibana) are working well, go into the Dev Tools -&gt; Console. Type &#8220;GET _cluster\/health&#8221;, run the console command, on the right panel of the console, you should receive similar result.<\/p>\n\n\n\n<p>Will add more post on details how to make the example from ElasticSearch 8.13 works. At the time of the post, the example provided by ElasticSearch does not work as expected.<\/p>\n\n\n\n<p>The steps that I was doing to get this ElasticSearch running is akin to Hal trying to fix the light bulb.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Hal fixing a light bulb (from Malcolm in the Middle S03E06 - Health Scare)\" width=\"584\" height=\"438\" src=\"https:\/\/www.youtube.com\/embed\/AbSehcT19u0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><strong>Reference:<\/strong><br><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/reference\/8.12\/docker.html\">Install Elasticsearch with Docker | Elasticsearch Guide [8.12] | Elastic<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pre-requisite:&#8211; VirtualBox 7.0.14&#8211; Vagrant 2.4.1&#8211; Windows 10 or better OS&#8211; 16GB RAM (10GB RAM are required for creating ElasticSearch with kibana; 1GB and 2 x ElasticSearch node; 4GB each, rest of the RAM for VM host OS) Overview:There are 2 &hellip; <a href=\"https:\/\/chow.karmeng.my\/?p=3360\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13,25,27],"tags":[133,134,148,149,238,460,462,470],"class_list":["post-3360","post","type-post","status-publish","format-standard","hentry","category-it","category-linux","category-ubuntu","category-microsoft-windows","tag-docker","tag-docker-compose","tag-elastic","tag-elasticsearch","tag-kibana","tag-vagrant","tag-vbox","tag-virtualbox"],"_links":{"self":[{"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=\/wp\/v2\/posts\/3360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3360"}],"version-history":[{"count":0,"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=\/wp\/v2\/posts\/3360\/revisions"}],"wp:attachment":[{"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chow.karmeng.my\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}