Tuesday, December 30, 2014

Upgrade docker on CentOS 7 Fix Failed to chown socket at step GROUP: No such process

To have the latest Docker, I first start from Docker's Official Guide: https://docs.docker.com/installation/centos/


wget https://get.docker.com/builds/Linux/x86_64/docker-latest -O docker
chmod +x ./docker
cp ./docker /usr/bin/docker


install the two unit files (service and socket) from the github repository to /etc/systemd/system.


systemctl start docker.socket
service docker start


But hold on, it doesn't work!

# service docker start
Redirecting to /bin/systemctl start docker.service
A dependency job for docker.service failed. See 'journalctl -xn' for details.


Here is the error log:

# journalctl -xn
-- Logs begin at Tue 2014-12-30 13:07:53 EST, end at Tue 2014-12-30 13:25:23 EST. --
Dec 30 13:12:30 ITX kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
Dec 30 13:22:53 ITX systemd[1]: Starting Cleanup of Temporary Directories...
-- Subject: Unit systemd-tmpfiles-clean.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has begun starting up.
Dec 30 13:22:53 ITX systemd[1]: Started Cleanup of Temporary Directories.
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has finished starting up.
--
-- The start-up result is done.
Dec 30 13:25:23 ITX systemd[1]: Starting Docker Socket for the API.
-- Subject: Unit docker.socket has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has begun starting up.
Dec 30 13:25:23 ITX systemd[1868]: Failed to chown socket at step GROUP: No such process
Dec 30 13:25:23 ITX systemd[1]: docker.socket control process exited, code=exited status=216
Dec 30 13:25:23 ITX systemd[1]: Failed to listen on Docker Socket for the API.
-- Subject: Unit docker.socket has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has failed.
--
-- The result is failed.
Dec 30 13:25:23 ITX systemd[1]: Dependency failed for Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is dependency.
Dec 30 13:25:23 ITX systemd[1]: Unit docker.socket entered failed state.


My easy fix solution, install Docker from YUM first. Then replace the docker file with the latest download:

service docker stop
rm /etc/systemd/system/docker.*
cp ./docker /usr/bin/docker
service docker start


After restart it, everything works fine.
At this moment (Dec 30, 2014), the latest stable Docker is 1.4.1

To enable the service and socket in systemd:


# systemctl list-unit-files | grep docker
docker.service disabled
docker.socket disabled

# chkconfig docker on
Note: Forwarding request to 'systemctl enable docker.service'.
ln -s '/usr/lib/systemd/system/docker.service' '/etc/systemd/system/multi-user.target.wants/docker.service'

# systemctl list-unit-files|grep docker
docker.service enabled
docker.socket disabled

# systemctl enable docker.socket
ln -s '/usr/lib/systemd/system/docker.socket' '/etc/systemd/system/sockets.target.wants/docker.socket'

# systemctl list-unit-files|grep docker
docker.service enabled
docker.socket enabled


Thank you!

Saturday, December 6, 2014

Debian 8 Jessie minimal Redmine Server with SQLite3

Debian 8 Jessie is on Beta 2, it has most package you need for 99% of my works.

Here is how it setup a Minimal Redmine Server from Debian 8 Jessie Beta2:

  1. First Insall Ruby ( version 2.1 perfect for Redmine version 2.4, 2.5 and 2.6 )


  2. # apt-get install ruby ruby-dev make gcc libsqlite3-dev


  3. Download Latest Redmine Stable 2.6.0 at this time



  4. # mkdir -p /var/www
    # cd /var/www
    # wget http://www.redmine.org/releases/redmine-2.6.0.tar.gz
    # tar xzvf redmine-2.6.0.tar.gz


  5. Install Redmine follow Redmine's official Installation document


  6. http://www.redmine.org/projects/redmine/wiki/RedmineInstall

  7. my brief installation recorders

  8. Define SQLite Database in config/database.yml
    # SQLite3 configuration example
    production:
    adapter: sqlite3
    database: db/redmine.sqlite3


    install Bundler first

    # gem install bundler
    # bundle install --without development test rmagick


    Session store secret generation
    # rake generate_secret_token


    Database schema objects creation
    # RAILS_ENV=production rake db:migrate


    Database default data set
    # RAILS_ENV=production rake redmine:load_default_data


    Test the installation
    # ruby script/rails server webrick -e production


  9. Setup Redmine init script, run WEBrick service

  10. Reference: https://gist.github.com/FeroVolar/7911366
    http://www.redmine.org/boards/1/topics/9334?r=14295

    My /etc/init.d/redmine file:

    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: redmine
    # Required-Start: $all
    # Required-Stop: $all
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: redmine webrick
    # Description: redmine webrick server autostart-script
    ### END INIT INFO

    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    DESC="redmine webrick daemon"
    NAME=redmine
    PIDFILE=/var/run/redmine.pid
    SCRIPTNAME=/etc/init.d/"$NAME"

    . /lib/lsb/init-functions

    # Modify it to your configuration
    DIR=/var/www/redmine-2.6.0/

    # Start Redmine in daemon mode.
    do_start(){
    cd $DIR
    ruby script/rails server webrick -d -e production -p 80 > /var/log/redmine.log
    }

    # Stop Redmine daemon
    do_stop(){
    RUBYPID=`ps aux | grep "ruby script/rails server webrick" | grep -v grep | awk '{print $2}'`
    if [ "x$RUBYPID" != "x" ]; then
    kill -2 $RUBYPID
    fi
    }

    # Check if Redmine is running
    do_status(){
    RUBYPID=`ps aux | grep "ruby script/rails server webrick" | grep -v grep | awk '{print $2}'`
    if [ "x$RUBYPID" = "x" ]; then
    echo "* Redmine is not running"
    else
    echo "* Redmine is running"
    fi
    }


    case "$1" in
    start)
    do_start
    ;;

    stop)
    do_stop
    ;;

    status)
    do_status
    ;;

    restart|force-reload)
    do_stop
    do_start
    ;;

    *)
    echo "Usage: $0 {start|stop|restart|force-reload|status}"
    exit 1

    esac


  11. Update systemd init service:


  12. # update-rc.d redmine defaults
    # systemctl daemon-reload
    # service redmine start
    # service redmine stop




Please notice: Redmine with SQLite3 is not for multi-user production system. Webrick server is not for high traffic site as well.

But hey, I got redmine running on a 64 MB VM in 5 mintues!