Steps to Install Elasticsearch on centos 7

Prerequisites:

Install OpenJDK 8 version

sudo yum install java-1.8.0-openjdk.x86_64

Validate the installation

java -version

If you are installing jdk manually from tar file then make sure if you have configure the JAVA_HOME path correctly.

Install Elasticsearch Latest version using Yum.

Import the Elasticsearch GPG Key

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch 

Create elasticsearch.repo inside /etc/yum.repos.d/

Add this content in elasticsearch.repo

[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

Run below command to enable the repo and installation

yum install --enablerepo=elasticsearch elasticsearch

Update Cluster Name, Node Name and Network Host details in /etc/elasticsearch/elasticsearch.yml

Run Elasticsearch using systemctl command

systemctl start elasticsearch.service

Validate the installation


[root@techieroop elasticsearch]# curl -XGET 'localhost:9200'
{
"name" : "log-analysis",
"cluster_name" : "TECHIEROOP",
"cluster_uuid" : "QGPfOKqPRXSCrDt6XddAMg",
"version" : {
"number" : "7.14.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1",
"build_date" : "2021-07-29T20:49:32.864135063Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

In case of timeout issue , update TimeoutStartSec value in below file and restart the service

 /usr/lib/systemd/system/elasticsearch.service
[root@techieroop ~]# systemctl start elasticsearch.service
Job for elasticsearch.service failed because a timeout was exceeded. See "systemctl status elasticsearch.service" and "journalctl -xe" for details.
[root@techieroop ~]# systemctl start elasticsearch.service

Job for elasticsearch.service failed because a timeout was exceeded. See "systemctl status elasticsearch.service" and "journalctl -xe" for details.



[root@techieroop ~]# journalctl -f

Aug 24 14:57:46 techieroop polkitd[864]: Registered Authentication Agent for unix-process:5283:268604 (system bus name :1.149 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
Aug 24 14:57:46 techieroop systemd[1]: Starting Elasticsearch...
Aug 24 14:59:01 techieroop systemd[1]: elasticsearch.service start operation timed out. Terminating.
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: fatal error in thread [main], exiting
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: java.lang.ExceptionInInitializerError
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.node.Node.<init>(Node.java:460)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.node.Node.<init>(Node.java:281)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:219)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:219)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:399)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.cli.Command.main(Command.java:79)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at java.base/java.security.AccessController.checkPermission(AccessController.java:1036)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:408)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at java.base/java.lang.ClassLoader.checkClassLoaderPermission(ClassLoader.java:2049)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at java.base/java.lang.ClassLoader.getParent(ClassLoader.java:1799)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:114)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: at org.elasticsearch.ingest.IngestService.<clinit>(IngestService.java:78)
Aug 24 14:59:01 techieroop systemd-entrypoint[5289]: ... 12 more
Aug 24 14:59:02 techieroop systemd[1]: Failed to start Elasticsearch.
Aug 24 14:59:02 techieroop systemd[1]: Unit elasticsearch.service entered failed state.
Aug 24 14:59:02 techieroop systemd[1]: elasticsearch.service failed.
Aug 24 14:59:02 techieroop polkitd[864]: Unregistered Authentication Agent for unix-process:5283:268604 (system bus name :1.149, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Aug 24 15:00:01 techieroop systemd[1]: Created slice User Slice of root.
Aug 24 15:00:01 techieroop systemd[1]: Started Session 6 of user root.
Aug 24 15:00:01 techieroop CROND[5498]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Aug 24 15:00:01 techieroop systemd[1]: Removed slice User Slice of root.
Aug 24 15:01:01 techieroop systemd[1]: Created slice User Slice of root.
Aug 24 15:01:01 techieroop systemd[1]: Started Session 7 of user root.
Aug 24 15:01:02 techieroop CROND[5521]: (root) CMD (run-parts /etc/cron.hourly)
Aug 24 15:01:02 techieroop run-parts(/etc/cron.hourly)[5526]: starting 0anacron
Aug 24 15:01:02 techieroop run-parts(/etc/cron.hourly)[5536]: finished 0anacron
Aug 24 15:01:02 techieroop systemd[1]: Removed slice User Slice of root.
Install Elasticsearch on Centos 7

More detail about Elasticsearch you can find here. https://www.elastic.co/guide/en/elastic-stack/current/index.html

(Visited 1,298 times, 48 visits today)