Running Maxwell (MySQL Binlog Reader) As Service In Ubuntu

As Many of DBA's are already running Maxwell ( if not Let me introduce you to Maxwell. It reads MySQL binlogs and writes row updates as JSON to Kafka, Kinesis, or other streaming platforms. Maxwell is very nice tool to build pipelines from MySQL to other NoSQL DB's like (Elastic Search, AeroSpike, Cassandra etc).

A common approach which is being used widely is to run maxwell on a box which reads bin-logs from MySQL box and write it to Kafka (A Distributed Streaming Platform) Later consumer's consume data from kafka and write it to its own DB (Elastic Search, AeroSpike etc).

Now major issue is to run maxwell as service on Ubuntu VM. Which we tried to solve using Upstart Job for Ubuntu 14.x and Systemd service for Ubuntu 16.x.

Maxwell Binaries can be downloaded from

Upstart for Ubuntu 14.x (Assuming maxwell binary placed in /opt/maxwell/ directory):

Create file: /etc/init/maxwell.conf
description "Start and stop the maxwell service "

author "Ankit Kumar"

env APP_HOME=/opt/maxwell/

start on (net-device-up

          and local-filesystems

          and runlevel [2345])

stop on runlevel [016]


respawn limit 5 60

limit nofile 24000 24000

pre-start script

    test -x $APP_HOME/bin/maxwell || { stop; exit 1; }

    test -e $APP_HOME/ || { stop; exit 1; }

end script


    echo $$ > /var/run/

    chdir $APP_HOME

    exec $APP_HOME/bin/maxwell

end script

post-stop script

    rm -f /var/run/

end script 
Now maxwell can be started using command service maxwell start & can be stopped using command service maxwell stop.

Upstart for Ubuntu 16.x (Assuming maxwell binary placed in /opt/maxwell/ directory):

Create file: /etc/systemd/system/maxwell.service

Description=Maxwell service






#ExecStartPost=/bin/bash "touch /var/run/ && `echo $MAINPID` > /var/run/"

ExecStop=/bin/kill -9 $MAINPID



Enable Maxwell systemd service: systemctl enable maxwell.service

Now maxwell can be started using command systemctl start maxwell.service & can be stopped using command systemctl stop maxwell.service.

Monitoring Maxwell Service: Using /var/run/ monitoring on maxwell service can be enabled.