Just in case anyone else wants to install Redash (using docker), on CentOS 7 instead of Ubuntu, this is an updated version of setup.sh with the needed pieces:

#!/usr/bin/env bash
# This script sets up dockerized Redash on CentOS 7 and Ubuntu 18.04.
set -u

REDASH_BASE_PATH=/opt/redash
COMPOSE_PATH=/usr/local/bin/docker-compose

distro=unknown
install_docker(){
    # Check for CentOS vs Ubuntu, then install Docker as appropriate
    which yum >/dev/null 2>&1
    if [ $? -eq 0 ]; then
        distro=centos7
        sudo yum -y update
        sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
        sudo curl -L -o /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
        sudo chown root:root /etc/yum.repos.d/docker-ce.repo
        sudo restorecon -Fv /etc/yum.repos.d/docker-ce.repo
        sudo yum -y install docker-ce pwgen yajl
        sudo systemctl start docker
    else
        distro=ubuntu
        sudo apt-get update
        sudo apt-get -yy install apt-transport-https ca-certificates curl software-properties-common pwgen
        curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
        sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
        sudo apt-get update && sudo apt-get -y install docker-ce
    fi

    # Install Docker Compose
    sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o ${COMPOSE_PATH}
    sudo chmod +x ${COMPOSE_PATH}
    if [ "${distro}" = "centos7" ]; then
        sudo restorecon -Fv ${COMPOSE_PATH}
    fi

    # Allow current user to run Docker commands
    sudo usermod -aG docker $USER
}

create_directories() {
    if [[ ! -e $REDASH_BASE_PATH ]]; then
        sudo mkdir -p $REDASH_BASE_PATH
        sudo chown $USER:$USER $REDASH_BASE_PATH
    fi

    if [[ ! -e $REDASH_BASE_PATH/postgres-data ]]; then
        mkdir $REDASH_BASE_PATH/postgres-data
    fi
}

create_config() {
    if [[ -e $REDASH_BASE_PATH/env ]]; then
        rm $REDASH_BASE_PATH/env
        touch $REDASH_BASE_PATH/env
    fi

    COOKIE_SECRET=$(pwgen -1s 32)
    POSTGRES_PASSWORD=$(pwgen -1s 32)
    REDASH_DATABASE_URL="postgresql://postgres:${POSTGRES_PASSWORD}@postgres/postgres"

    echo "PYTHONUNBUFFERED=0" >> $REDASH_BASE_PATH/env
    echo "REDASH_LOG_LEVEL=INFO" >> $REDASH_BASE_PATH/env
    echo "REDASH_REDIS_URL=redis://redis:6379/0" >> $REDASH_BASE_PATH/env
    echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $REDASH_BASE_PATH/env
    echo "REDASH_COOKIE_SECRET=$COOKIE_SECRET" >> $REDASH_BASE_PATH/env
    echo "REDASH_DATABASE_URL=$REDASH_DATABASE_URL" >> $REDASH_BASE_PATH/env
}

setup_compose() {
    # Determine newest release of Redash
    REQUESTED_CHANNEL=stable
    if [ "${distro}" = "centos7" ]; then
        PRETTY_PRINTER=json_reformat
    else
        PRETTY_PRINTER=json_pp
    fi
    LATEST_VERSION=`curl -s "https://version.redash.io/api/releases?channel=$REQUESTED_CHANNEL"  | ${PRETTY_PRINTER} | grep "docker_image" | head -n 1 | awk 'BEGIN{FS=":"}{print $3}' | awk 'BEGIN{FS="\""}{print $1}'`

    # Update version string in the docker-compose yaml
    cd $REDASH_BASE_PATH
    REDASH_BRANCH="${REDASH_BRANCH:-master}" # Default branch/version to master if not specified in REDASH_BRANCH env var
    curl -OL https://raw.githubusercontent.com/getredash/redash/${REDASH_BRANCH}/setup/docker-compose.yml
    sed -ri "s/image: redash\/redash:([A-Za-z0-9.-]*)/image: redash\/redash:$LATEST_VERSION/" docker-compose.yml
    echo "export COMPOSE_PROJECT_NAME=redash" >> ~/.profile
    echo "export COMPOSE_FILE=${REDASH_BASE_PATH}/docker-compose.yml" >> ~/.profile
    export COMPOSE_PROJECT_NAME=redash
    export COMPOSE_FILE=${REDASH_BASE_PATH}/docker-compose.yml

    # Start the Redash containers
    sudo ${COMPOSE_PATH} run --rm server create_db
    sudo ${COMPOSE_PATH} up -d
}

install_docker
create_directories
create_config
setup_compose

# Make the new docker user group effective, so the user doesn't need to re-login
exec sg docker newgrp `id -gn`

Apologies for doing it inline like that. The forum doesn’t seem to allow non-image file attachments. :wink:

2 Likes

Thanks, @justinclift!

As a general data point, this script is still working 100% ok on CentOS 7.

Just tried it out again (without modification), and it correctly pulled down + installed Redash v7 without issues. :slight_smile:

2 Likes

The above CentOS 7 enabled setup.sh is now on GitHub too:

Updates and improvements to it (eg newer Docker Compose version) are likely to be done there. :slight_smile:

You can grab the latest version directly from the command prompt using curl. eg:

# curl -OL https://github.com/justinclift/redash/raw/redash-centos7/setup/setup.sh
# chmod +x setup.sh
1 Like

How to add oracle data source?

Interesting question @krikil86. Haven’t tried Redash with Oracle personally, so not yet 100% sure.

Is Oracle listed in your potential Data Sources, when you use the “standard” “Add New Data Source” approach?

Step 1 here should get you started, if you’re not sure. :smile:

https://redash.io/help/user-guide/getting-started

This comment thread should help.

And this one.

1 Like

I recently ran your shell script on a fresh Centos 7 installation, no problems.
First attempt failed because corp firewall blocked the curl calls. This caused an incomplete installation and trying again died because redash’s password for postgres became out of sync. Starting from a clean instance resolved that.

1 Like

Hi Justinclift , I have installed the redash successfully on my CentOS 7 with the bash scripts. But I don’t know how to restart the redash service ? Because I must restart my sever few days ago.

In theory (!), you can start the Redash pieces again by running “docker-compose start”.

You might need to change into the /opt/redash directory first, not sure.

If it works, then “docker-compose ps” should show the status of things as running (etc).

Does that help? :smile:

2 Likes

Thank you for your reply 。And I think your way is worked。When I running “docker-compose ps”,the sever shows :


But ,when I want to visit it from web ,i failed 。
I don’t believe my server is overloaded。

Ahhh. Probably the best approach to get it working again - without losing any data (!) - is to recreate the docker containers. To do that:

  1. Change into the /opt/redash directory:
    cd /opt/redash
  1. Shut down the docker containers:
    docker-compose stop 
  1. Make a backup of your PostgreSQL data, just for safety. If this process doesn’t work, you might need the backup in order to try something else! The data is the entire contents of the /opt/redash/postgres-data directory. Copy it somewhere safe, including the user, group and file permissions (recursively).

  2. After the backup is done, destroy the existing docker containers:

    docker-compose down
  1. Recreate them again. From the /opt/redash directory, run:
    docker-compose up -d

In theory (!), the above process should backup your Redash data (it’s the PostgreSQL backup piece), then recreate things afresh in-place.

Let us know how it goes. :slight_smile:

Hi ,Justinclift , I finished five steps you suggested . I got that1572599814(1)
However ,when i visited the redash with web ,i failed .


i am sure i can connect port:5000 of my Server.

Hmmm. Ok, we’ll probably need to take a look at the logs and see what the error is.

But first… there’s one thing to try that might just work. :slight_smile:

We’ll run the database upgrade process, which (if that’s the problem) will fix things.

cd /opt/redash
docker-compose stop
docker-compose run --rm server manage db upgrade
docker-compose start

Hopefully (!) it works after that. :slight_smile: