Catalogue
Installing Kibana 4 on CentOS 7

Installing Kibana 4 on CentOS 7

🌐 日本語で読む

Prerequisites

  • Nginx already installed

Environment

  • CentOS Linux release 7.0.1406 (Core)
  • Nginx 1.9.3
  • Kibana 4.1.1

Installing Kibana

1
2
3
$ cd /usr/local/src
$ sudo wget https://download.elastic.co/kibana/kibana/kibana-4.1.1-linux-x64.tar.gz
$ sudo tar xvzf kibana-4.1.1-linux-x64.tar.gz

Editing the Kibana Configuration File

1
$ vi /usr/local/src/kibana-4.1.1-linux-x64/config/kibana.yml
  • Specifying the host

By default it is set to 0.0.0.0.
This time we build it on the same server, so we set it to localhost and save.

1
2
- host: "0.0.0.0"
+ host: "localhost"

With this setting, Kibana becomes accessible at localhost.

Creating the Kibana Runtime Path

1
2
$ sudo mkdir -p /opt/kibana
$ sudo cp -R /usr/local/src/kibana-4.1.1-linux-x64/* /opt/kibana/

With the above setup, you can run Kibana with the following command.

1
/opt/kibana/bin/kibana

The above is good enough, but Kibana stops when the machine is rebooted.
So we create a startup script and register it as a service.

Creating the Startup Script

1
$ sudo vi /etc/systemd/system/kibana4.service
  • kibana4.service
1
2
3
4
5
6
7
8
9
10
11
12
[Service]
ExecStart=/opt/kibana/bin/kibana
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=kibana4
User=root
Group=root
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

Save the above.

Starting / Registering the Service

1
2
$ sudo systemctl start kibana4
$ sudo systemctl enable kibana4

Installing Nginx

Please refer to the following.

Editing the Nginx Configuration File

Use a reverse proxy to forward to the Kibana 4 port (5601).

1
$ sudo vi /etc/nginx/conf.d/default.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 80;
server_name ec2-xx-xx-xxx-xxx.ap-northeast-1.compute.amazonaws.com;

auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;

location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

}

After saving the configuration above, restart Nginx.

1
$ sudo systemctl restart nginx

Accessing and Verifying

If it displays as shown below, everything is working fine.

That’s all.

Reference Articles

Introduction to Systemd (4) - Configuration files for service-type Units

About the Startup Script - Explanation of Each Item

About [Unit]
OptionDescription
DescriptionDescription text of the Unit
DocumentationURI of the documentation
RequiresPrerequisite Units this Unit needs
WantsPrerequisite Units this Unit needs
AfterUnits that should start before this Unit
BeforeUnits that should start after this Unit
About [Install]
OptionDescription
WantedByOn enable, creates a link in this Unit’s .wants directory
RequiredByOn enable, creates a link in this Unit’s .required directory
AlsoUnits to enable/disable simultaneously on enable/disable
AliasOn enable, provides an alias for this Unit

↓ This book was a huge help to me ♪

kenzo0107

kenzo0107