Setup Elastic server in Ubuntu from scratch
Setup a new Elastic server from download and install the machine's OS to install the Elastic from package.
Introduction
The ELK stack is a collection of three open-source tools that work together to process and analyze data from multiple sources. This guide will walkthrough how to host a ELK on a Linux server.
Procedures
1. Download Ubuntu server
Download latest version of Ubuntu server that used to host ELK services. By the time of writing, the latest version was Ubuntu 24.04.1.
2. Install ubuntu server
After download the ISO file, install it into server. For this showcase, I will install it in VMware Workstation.
Video Walkthrough: Shah Rukh Install Ubuntu Server on a Local VMware Virtual Machine
Select “New Virtual Machine”
Use the ISO file downloaded on previous procedure
Give a name to your virtual machine
- Other option can use default options. Click “Next >” until last window, then click “Finish”.
Start the VM, and select “Try or Install Ubuntu Server”
Select the language
Select “Update to the new installer”
Leave other as default
Deselect the LVM
Review the storage configuration and click “Done”
Select “Continue”
Enter the server name and your username. For this lab setup, I will keep it simple to use elk as my username, server name, and password.
Skip for upgrade it to Ubuntu Pro
I want to enable remote connect into this server via SSH, so I select “Install OpenSSH server”.
Leave as default and click “Done”
Wait for the server install necessary packages and click “Reboot Now”
Press enter after you see this screen, then the server will start to reboot.
After that, the server is ready
3. Configure Ubuntu server
After installed the Ubuntu server, we need to configure the time zone of the server. Otherwise, elastic might logged in different timezone. Because the timestamp logged into ELK will be follow the time set on the server. The time zone across all the server should be same.
- Find the name of your time zone
1
timedatectl list-timezones | grep -i Singapore
- Set the time zone
1
sudo timedatectl set-timezone Asia/Singapore Verify it
4. Configure static IP address (Optional)
This need to be configure before install ELK package if you are using DHCP for you server. During installation of ELK package, it will generate certificate with the server’s IP address. If you switch the IP address in the future, you will need to reinstall the ELK or change the ELK certificate.
For this showcase, I don’t want DHCP assign IP address to this server, so I assign a static IP address to it.
- Disable cloud initiative network configuration
- Create a file in /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
- Copy the following into the file
1
network: {config: disabled}
Disable network interface if it is up, verify with
ip a1
sudo networkctl down ens33- Modify
netplan1 2 3 4 5 6 7 8 9 10 11 12 13 14
network: version: 2 ethernets: ens33: dhcp4: false addresses: - 172.16.50.2/24 routes: - to: default via: 172.16.50.1 nameservers: addresses: - 172.16.50.1
- Verify the latest netplan with
sudo netplan try - Enable network interface with
sudo networkctl up ens33
5. Install Elasticsearch
In this step, we can finally install the Elasticsearch.
Reference link: Elastic official guide
- Import Elasticsearch GPG key
1
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
- Create Elasticsearch repo file
1 2
sudo apt-get install apt-transport-https echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
- Install Elasticsearch from apt
1
sudo apt-get update && sudo apt-get install elasticsearch
During installation of Elasticsearch, it will generate password for superuser. We need to record down the password for future use.
- Enable the Elasticsearch
1 2 3
sudo systemctl daemon-reload && \ sudo systemctl enable elasticsearch.service && \ sudo systemctl start elasticsearch.service
- Verify the Elasticsearch with the superuser password generated.
1
curl -X GET -k https://elastic:{superuser password}@localhost:9200
6. Install Kibana
Kibana is a user interface for admin to interact with.
Reference link: Elastic official guide
- Install Kibana from apt
1
sudo apt-get install kibana
- Create enrollment token to connect Elasticsearch and Kibana
1
sudo /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
- Copy the token and run Kibana setup and paste the token into it
1
sudo /usr/share/kibana/bin/kibana-setup - Enable Kibana web interface by modify
server.hostin/etc/kibana/kibana.yml - Start Kibana
1 2 3
sudo systemctl daemon-reload && \ sudo systemctl enable kibana.service && \ sudo systemctl start kibana.service
7. Create API key to enable Kibana alert feature
Kibana alert feature is not enable until we generate and install the API key.
- Generate Kibana encryption key
1
sudo /usr/share/kibana/bin/kibana-encryption-keys generate It will generate 3 secret key, copy all of it into notepad
- Add these key into Kibana
1
sudo /usr/share/kibana/bin/kibana-keystore add {key name}
- Restart Kibana service
1
sudo systemctl restart kibana.service Navigate to Security > Alert to verify it. If no warning, then you’re good to go.
8. Install Logstash (Optional)
Logstash is a service that collect and aggregate data from multiple sources in real-time. Once the data is ingested, Logstash allows you to parse and transform it using a variety of filters. You can use these filters to clean, enrich, and modify the data before it is sent to the final destination.
- Install Logstash from apt
1
sudo apt-get install kibana
- Enable Logstash
1 2 3
sudo systemctl daemon-reload && \ sudo systemctl enable logstash.service && \ sudo systemctl start logstash.service
Conclusion
We had installed a blank Ubuntu server and configure the timezone and IP of the server for Elastic use. Moreover, we download and install Elastic into the server and and enable Kibana to visualize Elastic log data in web. We also enable the alert feature on the Kibana and install Logstash to collect and aggregate log data from multiple sources.































