0

I'm trying to install Redash on Ubuntu 20.04.1

  1. I used this method of installing: https://github.com/getredash/setup
  2. I downloaded the files
  3. I cd in to the folder
  4. I run 'sudo ./setup.sh'
  5. I get the following error:
Traceback (most recent call last):
File “/app/manage.py”, line 9, in
manager()
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/flask/cli.py”, line 380, in main
return AppGroup.main(self, *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/flask/cli.py”, line 257, in decorator
return __ctx.invoke(f, *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/app/redash/cli/database.py”, line 31, in create_tables
db.create_all()
File “/usr/local/lib/python2.7/site-packages/flask_sqlalchemy/init.py”, line 963, in create_all
self._execute_for_all_tables(app, bind, ‘create_all’)
File “/usr/local/lib/python2.7/site-packages/flask_sqlalchemy/init.py”, line 955, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py”, line 4005, in create_all
tables=tables)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1939, in _run_visitor
with self._optional_conn_ctx_manager(connection) as conn:
File “/usr/local/lib/python2.7/contextlib.py”, line 17, in enter
return self.gen.next()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1932, in _optional_conn_ctx_manager
with self.contextual_connect() as conn:
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 2123, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 2162, in _wrap_pool_connect
e, dialect, self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1476, in _handle_dbapi_exception_noconnection
exc_info
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py”, line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 2158, in _wrap_pool_connect
return fn()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 400, in connect
return _ConnectionFairy._checkout(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 788, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 529, in checkout
rec = pool._do_get()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 1193, in _do_get
self._dec_overflow()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py”, line 66, in exit
compat.reraise(exc_type, exc_value, exc_tb)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 1190, in _do_get
return self._create_connection()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 347, in _create_connection
return _ConnectionRecord(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 474, in init
self.__connect(first_connect_check=True)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py”, line 671, in __connect
connection = pool._invoke_creator(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py”, line 106, in connect
return dialect.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py”, line 412, in connect
return self.dbapi.connect(*cargs, **cparams)
File “/usr/local/lib/python2.7/site-packages/psycopg2/init.py”, line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: password authentication failed for user “postgres”
(Background on this error at: http://sqlalche.me/e/e3q8)

So apparently something to do with psycopg2 and it trying to connect to the SQL server. Can't figure out how to fix it sand googling hasn't helped.

The weird part is that this exact same method worked just fine for me the first time I did it. For some weird reason I wanted a fresh install and I cleaned everything in docker with prune. However it doesn't work.

Any suggestions?

Below the code from setup.sh

#!/usr/bin/env bash
# This script setups dockerized Redash on Ubuntu 18.04.
set -eu

REDASH_BASE_PATH=/opt/redash

install_docker(){
    # Install Docker
    export DEBIAN_FRONTEND=noninteractive
    sudo apt-get -qqy update
    DEBIAN_FRONTEND=noninteractive sudo -E apt-get -qqy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade 
    sudo apt-get -yy install apt-transport-https ca-certificates curl software-properties-common wget 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

    # Install Docker Compose
    sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose

    # 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)
    SECRET_KEY=$(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_SECRET_KEY=$SECRET_KEY" >> $REDASH_BASE_PATH/env
    echo "REDASH_DATABASE_URL=$REDASH_DATABASE_URL" >> $REDASH_BASE_PATH/env
}

setup_compose() {
    REQUESTED_CHANNEL=stable
    LATEST_VERSION=`curl -s "https://version.redash.io/api/releases?channel=$REQUESTED_CHANNEL"  | json_pp  | grep "docker_image" | head -n 1 | awk 'BEGIN{FS=":"}{print $3}' | awk 'BEGIN{FS="\""}{print $1}'`

    cd $REDASH_BASE_PATH
    GIT_BRANCH="${REDASH_BRANCH:-master}" # Default branch/version to master if not specified in REDASH_BRANCH env var
    wget https://raw.githubusercontent.com/getredash/setup/${GIT_BRANCH}/data/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=/opt/redash/docker-compose.yml" >> ~/.profile
    export COMPOSE_PROJECT_NAME=redash
    export COMPOSE_FILE=/opt/redash/docker-compose.yml
    sudo docker-compose run --rm server create_db
    sudo docker-compose up -d
}

install_docker
create_directories
create_config
setup_compose

And docker-compose.yml

version: "2"
x-redash-service: &redash-service
  image: redash/redash:8.0.0.b32245
  depends_on:
    - postgres
    - redis
  env_file: /opt/redash/env
  restart: always
services:
  server:
    <<: *redash-service
    command: server
    ports:
      - "5000:5000"
    environment:
      REDASH_WEB_WORKERS: 4
  scheduler:
    <<: *redash-service
    command: scheduler
    environment:
      QUEUES: "celery"
      WORKERS_COUNT: 1
  scheduled_worker:
    <<: *redash-service
    command: worker
    environment:
      QUEUES: "scheduled_queries,schemas"
      WORKERS_COUNT: 1
  adhoc_worker:
    <<: *redash-service
    command: worker
    environment:
      QUEUES: "queries"
      WORKERS_COUNT: 2
  redis:
    image: redis:5.0-alpine
    restart: always
  postgres:
    image: postgres:9.6-alpine
    env_file: /opt/redash/env
    volumes:
      - /opt/redash/postgres-data:/var/lib/postgresql/data
    restart: always
  nginx:
    image: redash/nginx:latest
    ports:
      - "80:80"
    depends_on:
      - server
    links:
      - server:redash
    restart: always
Joka
  • 55
  • 9

2 Answers2

0

Try docker-compose run --rm server create_db after you run docker-compose up -d.

redash % docker-compose up -d
Docker Compose is now in the Docker CLI, try `docker compose up`

Creating network "redash_default" with the default driver
Creating redash_postgres_1 ... done
Creating redash_redis_1    ... done
Creating redash_server_1   ... done
Creating redash_worker_1    ... done
Creating redash_scheduler_1 ... done
redash % docker-compose run --rm server create_db
Creating redash_server_run ... done
[2021-11-03 14:49:12,282][PID:1][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2021-11-03 14:49:12,282][PID:1][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2021-11-03 14:49:12,353][PID:1][INFO][alembic.runtime.migration] Running stamp_revision  -> 89bc7873a3e0
redash % 

The following curl result is showing the set-up web page:

% curl --verbose http://localhost:5000/setup
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 5000 (#0)
> GET /setup HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.64.1
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Type: text/html; charset=utf-8
< Content-Length: 2808
< X-Frame-Options: deny
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval'; font-src 'self' data:; img-src 'self' http: https: data: blob:; object-src 'none'; frame-ancestors 'none'; frame-src redash.io;  
< X-Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval'; font-src 'self' data:; img-src 'self' http: https: data: blob:; object-src 'none'; frame-ancestors 'none'; frame-src redash.io;  
< Referrer-Policy: strict-origin-when-cross-origin
< Set-Cookie: csrf_token=IjMxMWFlZWNjYTMwNDQ1YjA4MmM2MGVmZmU4OGYzZjhhNWUyNDNjYTQi.YYK1Cg.gcRo-T2uBFdn2SicRGZbjlA5nEw; Path=/
< Vary: Cookie
< Set-Cookie: session=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiMzExYWVlY2NhMzA0NDViMDgyYzYwZWZmZTg4ZjNmOGE1ZTI0M2NhNCJ9.YYK1Cg.7EuH8tslclwcW5nvW8_0k0xi4Aw; Expires=Wed, 03-Nov-2021 22:12:58 GMT; HttpOnly; Path=/
< Server: Werkzeug/0.16.1 Python/3.7.12
< Date: Wed, 03 Nov 2021 16:12:58 GMT
< 
<!DOCTYPE html>
<html class="no-js">
<head>
  <title>Redash Initial Setup</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <link rel="stylesheet" href="/static/server.css">

  <link rel="icon" type="image/png" sizes="32x32" href="/static/images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="96x96" href="/static/images/favicon-96x96.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/static/images/favicon-16x16.png">
  
</head>
<body class="d-flex flex-column justify-content-center align-items-center signed-out">

  <div>
    <div class="header">
      <div class="text-center m-b-15">
        <a href="/"><img src="/static/images/redash_icon_small.png"></a>
      </div>
      
        <h3 class="text-center m-t-0 m-b-25">Redash Initial Setup</h3>
      
    </div>
    
<div class="fixed-width-page">
  <div class="bg-white tiled">
    <h4 class="m-t-0">Welcome to Redash!</h4>
    <div>Before you can use your instance, you need to do a quick setup.</div>


    <form role="form" method="post" name="create_account">
      <input type="hidden" name="csrf_token" value="IjMxMWFlZWNjYTMwNDQ1YjA4MmM2MGVmZmU4OGYzZjhhNWUyNDNjYTQi.YYK1Cg.gcRo-T2uBFdn2SicRGZbjlA5nEw"/>
      <h4 class="m-t-25">Admin User</h4>
      <div class="form-group ">
    <label for="name">Name</label>
    <input class="form-control" id="name" name="name" required type="text" value="">
    
    
  </div>
      <div class="form-group ">
    <label for="email">Email Address</label>
    <input class="form-control" id="email" name="email" type="email" value="">
    
    
  </div>
      <div class="form-group ">
    <label for="password">Password</label>
    <input class="form-control" id="password" name="password" type="password" value="">
    
    
  </div>

      <div class="checkbox">
        <label>
          <input checked id="security_notifications" name="security_notifications" type="checkbox" value="y">
          Subscribe to Security Notifications
        </label>
      </div>

      <div class="checkbox">
        <label>
          <input checked id="newsletter" name="newsletter" type="checkbox" value="y">
          Subscribe to newsletter (version updates, no more than once a month)
        </label>
      </div>

      <h4 class="m-t-25">General</h4>

      <div class="form-group ">
    <label for="org_name">Organization Name</label>
    <input class="form-control" id="org_name" name="org_name" required type="text" value="">
    
        <p class="help-block">Used in email notifications and the UI.</p>
    
    
  </div>

      <button type="submit" class="btn btn-primary btn-block m-t-25">Setup</button>
    </form>
  </div>
</div>

  </div>





</body>
* Closing connection 0
</html>
netthing
  • 47
  • 1
  • 8
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 30 '21 at 10:27
0

In my case it was because i rerun the setup more than once.At least in that case, you can try:

switch to the redash-dir

cd /opt/redash/

shut down the current running stuff

docker-compose down
docker-compose rm -sfv postgres

remove postgres-data and config (should be no problem as the app did not run yet)

rm -r postgres-data/

reinit the start:

docker-compose up -d
docker-compose run --rm  server create_db

should finally bring you to

[+] Creating 2/0
 ✔ Container redash-redis-1     Running                                                                                                                                                                                                                                                0.0s 
 ✔ Container redash-postgres-1  Running                                                                                                                                                                                                                                                0.0s 
[2023-08-09 10:05:26,891][PID:1][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2023-08-09 10:05:26,892][PID:1][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2023-08-09 10:05:26,951][PID:1][INFO][alembic.runtime.migration] Running stamp_revision  -> e5c7a4e2df4d

you can check your current config-parameter with

cat /opt/redash/env
gratinierer
  • 1,748
  • 1
  • 10
  • 10