Installing metabase on ec2 linux server as a service file.

 

 Metabase installation 

 log in with root user
# sudo su 

Install the java on linux server

# sudo amazon-linux-extras install java-openjdk11

 Creating a directory 

# mkdir ~/metabase

Download a metabase.jar file and move to directory

to download metabase.jar

# wget https://downloads.metabase.com/v0.44.4/metabase.jar   

# mv /home/ec2-user/metabase.jar ~/metabase

Change directory to metabase

# cd ~/metabase

Now Run the cammand to run the jar file

java -jar metabase.jar


Do the setup part with http://localhost:3000/setup

To make the jar file into service, these are the following steps  

# sudo groupadd -r metabase

# sudo useradd -r -s /bin/false -g metabase metabase

# pwd

# sudo chown -R metabase:metabase /home/ec2-user/metabase/directory

# sudo touch /var/log/metabase.log

 # sudo chown syslog:adm /var/log/metabase.log

 # sudo touch /etc/default/metabase

 # sudo chmod 640 /etc/default/metabase

Once the folder and file is made just copy and past the folloing steps in the file 

vi /etc/systemd/system/metabase.service

[Unit]

Description=Metabase server


[Service]

Type=simple

WorkingDirectory=/home/ec2-user/metabase

#User=metabase

User=ec2-user

Group=metabase

ExecStart=/bin/java -jar /home/ec2-user/metabase/metabase.jar

EnvironmentFile=/etc/default/metabase

Restart=on-failure

RestartSec=10

StandardOutput=syslog

StandardError=syslog

SyslogIdentifier=metabase

[Install]

WantedBy=multi-user.target


Now enable the metabase file using following cammand

# systemctl enable  metabase

  Place the following sentence in the config file.

# sudo vi /etc/rsyslog.d/metabase.conf

if $programname == 'metabase' then /var/log/metabase.log

& stop

Now restart the rsyslog servive

# sudo systemctl restart rsyslog.service

# sudo systemctl status rsyslog.service

Now install ngnix  

# sudo amazon-linux-extras install epel

# sudo yum install yum install nginx

# cd /etc/nginx/

Now insert the following config to ngnix

# sudo vi nginx.conf

user  nginx;

worker_processes  auto;

error_log  /var/log/nginx/error.log notice;

pid        /var/run/nginx.pid;


events {

    worker_connections  1024;

}



http {

    include       /etc/nginx/mime.types;

    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';


    access_log  /var/log/nginx/access.log  main;


    sendfile        on;

    #tcp_nopush     on;


    keepalive_timeout  65;


    #gzip  on;


    include /etc/nginx/conf.d/*.conf;

}

# sample nginx.conf

# proxy requests to Metabase instance

#server {

# listen 80;

#  listen [::]:80;

#  server_name your.domain.com;

#  location / {

#    proxy_pass http://0.0.0.0:3000;

#  }

#}

Now the change the ngnix repo file
# vi /etc/yum.repos.d/nginx.repo

[nginx-stable]

name=nginx stable repo

baseurl=http://nginx.org/packages/amzn2/$releasever/$basearch/

gpgcheck=1

enabled=1

gpgkey=https://nginx.org/keys/nginx_signing.key

module_hotfixes=true


[nginx-mainline]

name=nginx mainline repo

baseurl=http://nginx.org/packages/mainline/amzn2/$releasever/$basearch/

gpgcheck=1

enabled=1

gpgkey=https://nginx.org/keys/nginx_signing.key

module_hotfixes=true


Now install psql on the Linux server   

# wget https://yum.postgresql.org/11/redhat/rhel-6.9-x86_64/postgresql11-libs-11.8-1PGDG.rhel6.x86_64.rpm

# wget https://yum.postgresql.org/11/redhat/rhel-6.9-x86_64/postgresql11-11.8-1PGDG.rhel6.x86_64.rpm

# sudo rpm -ivh postgresql11-libs-11.8-1PGDG.rhel6.x86_64.rpm

# sudo rpm -ivh postgresql11-11.8-1PGDG.rhel6.x86_64.rpm

Now install Mysql

# sudo wget https://downloads.mysql.com/archives/get/p/10/file/mysql-connector-odbc-5.3.13-1.el7.i686.rpm

sudo yum install mysql-connector-odbc-5.3.13-1.el7.i686.rpm

# sudo yum install mysql

Now go with the folloing steps.

# systemctl daemon-reload

# rm -rf postgresql11-libs-11.8-1PGDG.rhel6.x86_64.rpm

# sudo systemctl restart metabase.service

#  service nginx enable

# service nginx start

# systemctl start nginx.service

# systemctl status nginx.service

#  sudo systemctl daemon-reload

# sudo systemctl start metabase.service

# sudo systemctl restart metabase.service

# sudo systemctl status metabase.service


Here is some of the main part need to do 

* open the 3000 port in security group

* Create a sub-domine for the metabase in route 53

* Create a load balancer and attach the sub-domine in the listners

* whitelist your metabase server ip in  mysql and psql RDS instance




Comments

Popular posts from this blog

List Of Kubernetes Most Useful Commands

How to install Kubernetes Cluster on AWS EC2 instances