Redash Docker安装问题:sqlalchemy.exc.OperationalError:(psycopg2.OperationalError)

时间:2020-11-05 14:19:01

标签: linux docker installation psycopg2 redash

我正在尝试在Ubuntu 20.04.1上安装Redash

  1. 我使用了以下安装方式:https://github.com/getredash/setup
  2. 我下载了文件
  3. 我进入了文件夹
  4. 我运行'sudo ./setup.sh'
  5. 我收到以下错误:
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)

显然与psycopg2有关,它试图连接到SQL Server。无法弄清楚如何解决它,谷歌搜索没有帮助。

奇怪的是,这种完全相同的方法在我第一次使用时对我来说就很好。出于某些奇怪的原因,我想要重新安装,然后使用prune清理了docker中的所有内容。但是它不起作用。

有什么建议吗?

在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

还有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

0 个答案:

没有答案