Linux: Elastic and Kibana Install
This guide walks you through setting up a single node Elasticsearch cluster and Kibana instance. It should take around 2 hours to complete the Elastic and Kibana install.
If you are setting up a production environment, you will want to set up an Elasticsearch cluster. Please use the Elasticsearch website for more information on how to do this.
The Elastic token used to configure Kibana is only valid for 30 minutes. Once you have extracted Elastic you have 30 minutes to Install and Configure Kibana. It is not a long process but please ensure you have that time to complete these steps.
Installing Elasticsearch
Ubuntu
Downloading Elastic 8.19.7 & Kibana 8.19.7. To download Elasticsearch and Kibana using a Debian package:
cd /data wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo yum add - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.19.7-amd64.deb wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.19.7-amd64.deb.sha512 wget https://artifacts.elastic.co/downloads/kibana/kibana-8.19.7-amd64.deb wget https://artifacts.elastic.co/downloads/kibana/kibana-8.19.7-amd64.deb.sha512To navigate to where your Elasticsearch files are stored:
cd/dataTo compare the SHA of the downloaded Debian package with the published checksum:
shasum -a 512 -c elasticsearch-8.19.7-amd64.deb.sha512To install Elasticsearch:
sudo dpkg -i elasticsearch-8.19.7-amd64.debTo confirm that Elasticsearch is installed:
sudo systemctl status elasticsearch.serviceRed Hat
Importing the Elasticsearch PGP Key
Download and install the public signing key:
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearchDownloading and installing the RPM manually
The RPM for Elasticsearch v8.19.7 can be downloaded from the website and installed as follows, this will autoconfigure default security settings unless a pre-existing elasticsearch.yml config file is present in /etc/elasticsearch:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.19.7-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.19.7-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-8.19.7-x86_64.rpm.sha512
sudo rpm --install elasticsearch-8.19.7-x86_64.rpmConfiguring Elasticsearch
Edit the Elasticsearch.yml file with the editor of your choice (nano, vim, emacs etc.):
sudo nano /etc/elasticsearch/elasticsearch.ymlA text editor is displayed in the terminal. To provide custom values for settings (remove the # before a line to ensure the setting is used).
Set a name for the Elastic cluster: The name must be unique, descriptive of the server, and distinctive to other clusters to prevent auto joining.
cluster.name: im-elasticclusterSet the Elastic node name: The node name must be unique to the environment to prevent clusters auto joining.
node.name: esnode1Set the network host: This binds Elastic to all IP addresses assigned to this machine, so that remote access is possible.
network.host: 0.0.0.0Set the discovery.seed_hosts: These addresses can be given as hostnames or IP addresses. Hosts specified as hostnames are resolved to IP addresses during each round of discovery.
discovery.seed_hosts: [“127.0.0.1”] Set the cluster.initial_master_nodes: Specifying the host name determines the set of master-eligible nodes whose votes are counted in the very first election. You must explicitly list the master-eligible nodes whose votes will be counted in the very first election.
cluster.initial_master_nodes: [“esnode1”]Set the Elasticsearch data path. Elasticsearch stores the node data across all provided paths but keeps each shard’s data on the same path.
To use a custom path for data:
sudo mkdir /data/elasticsearchdataTo exit the editor, press Ctrl+x, then enter Y when prompted. Press the Enter key to save your changes.
To update permissions of all Elasticsearch directories:
sudo chown elasticsearch:elasticsearch -R /usr/share/elasticsearch
/var/log/elasticsearch /var/lib/elasticsearch /etc/sysconfig/elasticsearch
/etc/elasticsearch /data/elasticsearchdataOpen the /etc/sysconfig/elasticsearch file:
sudo nano /etc/sysconfig/elasticsearchAdd the following two entries at the bottom of the file:
ES_USER=elasticsearch
ES_GROUP=elasticsearchPress Ctrl+x to exit the editor. When prompted enter Y, then press Enter to save your changes.
You may need to run:
sudo systemctl daemon-reloadManually starting up elasticsearch can cause some complications with ownership of files (logs / data etc.), so I would suggest running via systemd from the start unless unavoidable for debugging purposes. The process described further on in the guide can be used to set the elastic account password and generate an enrolment token for kibana.
Running Elasticsearch with systemd
To configure Elasticsearch to start automatically when the system boots up:
This guide assumes that the RHEL version is using systemd.
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.serviceElasticsearch can be started and stopped as follows:
sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.serviceTo confirm that Elasticsearch was started successfully, check the log files located in /var/log/elasticsearch/.
By default the Elasticsearch service doesn’t log information in the systemd journal. To enable journalctl logging, the --quiet option must be removed from the ExecStart command line in the elasticsearch.service file.
When systemd logging is enabled, the logging information are available using the journalctl commands:
To tail the journal:
sudo journalctl -fTo list journal entries for the Elasticsearch service:
sudo journalctl --unit elasticsearchTo list journal entries for the Elasticsearch service starting from a given time:
sudo journalctl --unit elasticsearch --since "2016-10-30 18:17:16"Password and Token Administration
By default, Elasticsearch will autogenerate an elastic user password and Kibana enrollment token at startup. If you didn’t make a note of these or prefer to use your own password, reset the elastic password with this command:
If the Kibana enrollment token has expired (after 30 minutes) or you don’t have it to hand, you can generate a new one with the following command:
Checking that Elasticsearch is running
To test that your Elasticsearch node is running by sending an HTTP request to port 9200 on localhost, you will need to know the password for the elastic account to try this. If you don’t have this to hand it is not a problem as we will be resetting it later:
Which should return something akin to the following:
Installing Kibana
If installing on multiple servers, this should be done on the same server as the apache web server, to allow for outside communication, not on the elasticsearch server, unless you have an ability to reach :5601 on there from your browser. It is preferable to proxy requests via apache.
Red Hat
Download and install the public signing key:
Download and install the RPM manually. The RPM for Kibana v7.9.3 can be downloaded from the website and installed:
Configuring Kibana
Change the directory to the /etc/kibana location:
Open kibana.yml in a text editor:
Apply the following config:
Press Ctrl+x to exit the editor. When prompted enter Y, then press Enter to save your changes.
Apply the Kibana enrollment token, see previous section for generating this if required
Enable the Kibana service:
Ensure Elasticsearch service is running, then start the Kibana service to check for any issues:
Check the logs for any further issues.
Once the service has started, open a browser and navigate to http://[insert-ip-address-or-host-name]:5601 to log in to Kibana.
Open Kibana and apply the Elasticsearch license: click Stack Management > License Management > Update License.
Upload your Elasticsearch license.
If the kibana.yml file is installed in a location that cannot be accessed by the service, copy the file from the etc/kibana folder to the usr/share/kibana folder.
Configuring JAVA_HOME environment variable
If the AIE components are on separate server to Elasticsearch, or the client has a preferred JDK, you should be able to install via the appropriate package manager. If not, you can use the bundled one present in Elasticsearch, though note that this will not receive any updates until you update Elasticsearch itself.
There have also been instances where the below configuration does not work properly with the forked processes tika generates, causing the tika service to fail. In that scenario, some additional configuration may be required.
To set the permanent environment variable for JAVA_HOME, do the following:
Change directory to /etc:
Open the profile file in nano:
Add the following values to the bottom of the file:
Press Ctrl+x to exit nano.
Enter Y to save changes, N to discard, then click Enter.
Change directory to the elasticsearch jdk folder and run the following two commands to ensure the folders are accessible:
Restart your server.
Once logged back in, check that JAVA_HOME has been set correctly and is running the correct version:
This will return the path that you specified above.
Enabling firewalls & allowing HTTP/HTTPS
Ubuntu
Check the current status of the firewall
Turn the firewall on:
When prompted to proceed, enter Y, then click Enter.
Verify the firewall is now active:
Open firewall ports for HTTP, HTTPS, SSH, Elastic and Kibana:
Note: Only open ports 9200/tcp and 5601/tcp to access Elastic and Kibana remotely. If you are not installing AIE on the same server, you can skip http / https
If these firewall ports aren’t opened you won’t be able to connect through ssh after reboot.
To verify updates:
Red Hat
Check the current status of the firewall:
If listed as inactive, turn it on. Whether firewall is present at all by default varies between cloud providers. It can be installed via dnf if required.
Turn the firewall on:
When prompted enter Y, then press Enter to save your changes.
Verify the firewall is now active:
Open the firewall ports for http, https, Elastic and Kibana:
Note: If you are not installing AIE on this same server, http (80) / https (443) will not be required
Add as a service
Alternatively add specific ports. This will work if the OS doesn’t have the service definitions above. Note 9300 will also be required if more than one elastic node is present.
Important: If these firewall ports aren’t opened you won’t be able to connect through ssh after reboot.
Reload the firewall service:
Reload the firewall service:
Setting up Elastic Transport Layer Security (TLS)
Generate the certificates from /usr/share/elasticsearch/bin
When prompted, leave the file name blank then press Enter.
Enter your secure CA password.
Enter your secure CA password as the CA password.
When prompted, leave the file name blank then press Enter.
Enter your secure cert password as the password.
Create a certs folder in /etc/elasticsearch:
Copy the certificates to the new certs directory:
Edit the elasticsearch.yml file with the editor of your choice:
Change the autoconfigured section at the bottom to the following:
When prompted enter Y, then press Enter to save your changes.
Update the certificate credentials in the Elasticsearch keystore:
If security autoconfiguration has run, there will be some existing entries present in the keystore file we will need to remove.
You may encounter an error around changing the owner of the keystore file, this is because it is owned by the elastic user but you are trying to update it as (probably if you’re using sudo) root, to work around this, temporarily change the ownership of the file:
Enter the cert password as the password 1/2:
You can use ‘list’ and ‘show’ with a specific key to validate the current state of the keystore file
If you had to change the owner of the keystore earlier, change it back:
Ensure permissions are updated for the certs in the new directory:
Start the Elasticsearch service.
Elastic has now been secured and the self-signed certificate is applied. Run a curl command to check that the output is correct:
You are prompted to enter the elastic user password.
You can also check the output in a browser: navigate to https://[insert-ip-address-or-host-name]:9200. You are prompted to enter a secure password.
Update the kibana.yml file to include https:
Press Ctrl+x to exit the editor. When prompted enter Y, then press Enter to save your changes.
Restart Kibana:
Last updated