In some cases you want to have a certain type of service running on your Oracle Linux instance just for testing and playing purposes. In my case am experimenting with Elasticsearch from Elastic and I need to install single node Elasticsearch instances every now and than on a new and fresh Oracle Linux instance. Even though it is not that much work it makes more sense to build a script for this.
The below script will install Elasticsearch on Oracle Linux 6 3.8.13-68.2.2.3.el6uek.x86_64 by simply running the script. Elasticsearch is a search engine based on Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License. Elasticsearch is the most popular enterprise search engine followed by Apache Solr, also based on Lucene.
The script has been tested on Oracle Linux 6 running on the Oracle Public Cloud. After completing the script you can see that Elasticsearch is running and listening on port 9200 on both IPv4 and IPv6 by executing the below command:
To test if Elasticsearch indeed is working and responding you can do a curl against port 9200 to see the default result from Elasticsearch after a vanilla installation.
The below script will install Elasticsearch on Oracle Linux 6 3.8.13-68.2.2.3.el6uek.x86_64 by simply running the script. Elasticsearch is a search engine based on Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License. Elasticsearch is the most popular enterprise search engine followed by Apache Solr, also based on Lucene.
#!/bin/bash function runMain { installJava installElasticsearch startElasticsearch } function packageInstalled () { numberOfPackages=`yum list installed | grep $1 | wc -l` if [ "$numberOfPackages" -gt "0" ]; then echo "true" else echo "false" fi } function installJava { javaInstalled=`packageInstalled java-1.8.0-openjdk` if [ "$javaInstalled" = "true" ]; then echo "java is already installed" else echo "installing java" yum -y install java-1.8.0-openjdk fi } function installElasticsearch { elasticsearcInstalled=`packageInstalled elasticsearch` if [ "$elasticsearcInstalled" = "true" ]; then echo "elasticsearch is already installed" else echo "importing elastic GPG key" rpm --import http://packages.elastic.co/GPG-KEY-elasticsearch echo "adding elastic repository to yum" echo "" >> /etc/yum.repos.d/public-yum-ol6.repo echo "[elastic]" >> /etc/yum.repos.d/public-yum-ol6.repo echo "name=Elasticsearch repository for 2.x packages" >> /etc/yum.repos.d/public-yum-ol6.repo echo "baseurl=http://packages.elastic.co/elasticsearch/2.x/centos" >> /etc/yum.repos.d/public-yum-ol6.repo echo "gpgcheck=1" >> /etc/yum.repos.d/public-yum-ol6.repo echo "gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch" >> /etc/yum.repos.d/public-yum-ol6.repo echo "enabled=1" >> /etc/yum.repos.d/public-yum-ol6.repo echo "installing elasticsearch" yum -y install elasticsearch fi } function startElasticsearch { echo "starting elasticsearch" service elasticsearch start } runMain
The script has been tested on Oracle Linux 6 running on the Oracle Public Cloud. After completing the script you can see that Elasticsearch is running and listening on port 9200 on both IPv4 and IPv6 by executing the below command:
[root@testbox08 init.d]# [root@testbox08 init.d]# netstat -ln | grep 9200 tcp 0 0 ::ffff:127.0.0.1:9200 :::* LISTEN tcp 0 0 ::1:9200 :::* LISTEN [root@testbox08 init.d]# [root@testbox08 init.d]#
To test if Elasticsearch indeed is working and responding you can do a curl against port 9200 to see the default result from Elasticsearch after a vanilla installation.
[root@testbox08 init.d]# [root@testbox08 init.d]# curl http://localhost:9200/ { "name" : "King Bedlam", "cluster_name" : "elasticsearch", "cluster_uuid" : "5fd7bOG-RP6MrTbI3denuA", "version" : { "number" : "2.4.1", "build_hash" : "c67dc32e24162035d18d6fe1e952c4cbcbe79d16", "build_timestamp" : "2016-09-27T18:57:55Z", "build_snapshot" : false, "lucene_version" : "5.5.2" }, "tagline" : "You Know, for Search" } [root@testbox08 init.d]# [root@testbox08 init.d]#
No comments:
Post a Comment