community-edition icon indicating copy to clipboard operation
community-edition copied to clipboard

Database plausible_events_db doesn't exist

Open productdevbook opened this issue 1 year ago • 5 comments

version: "3.8"
services:
  mail:
    image: bytemark/smtp:latest
    env_file:
      - plausible-conf.env
    networks:
      - internal
    labels:
      - traefik.enable=false

  plausible_db:
    image: postgres:latest
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=postgres
    networks:
      - internal
    labels:
      - traefik.enable=false

  plausible_events_db:
    image: yandex/clickhouse-server:21.3.2.5
    volumes:
      - event-data:/var/lib/clickhouse
      - ./clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
      - ./clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    networks:
      - internal
    labels:
      - traefik.enable=false

  plausible:
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - plausible_db
      - plausible_events_db
      - mail
    ports:
      - 8000
    env_file:
      - plausible-conf.env
    networks:
      - traefik-public
      - internal
    deploy:
      labels:
        - traefik.enable=true
        - traefik.constraint-label=traefik-public
        - traefik.http.routers.plausible.rule=Host(`site`)
        - traefik.http.routers.plausible.entrypoints=https
        - traefik.http.services.plausible.loadbalancer.server.port=8000
        - traefik.http.routers.plausible.tls=true
        - traefik.http.routers.plausible.tls.certresolver=le

volumes:
  db-data:
    driver: local
  event-data:
    driver: local
  geoip:
    driver: local

networks:
  traefik-public:
    external: true
  internal:
    external: false

2022.07.11 09:51:18.477067 [ 51 ] {} <Error> DynamicQueryHandler: Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist, Stack trace (when copying this message, always include the lines below):

  1. DB::DatabaseCatalog::assertDatabaseExistsUnlocked(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) const @ 0xeb0668a in /usr/bin/clickhouse
  2. DB::DatabaseCatalog::assertDatabaseExists(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) const @ 0xeb06522 in /usr/bin/clickhouse
  3. DB::Context::setCurrentDatabase(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) @ 0xeaa3cb1 in /usr/bin/clickhouse
  4. DB::HTTPHandler::processQuery(DB::Context&, DB::HTTPServerRequest&, DB::HTMLForm&, DB::HTTPServerResponse&, DB::HTTPHandler::Output&, std::__1::optionalDB::CurrentThread::QueryScope&) @ 0xf845fda in /usr/bin/clickhouse
  5. DB::HTTPHandler::handleRequest(DB::HTTPServerRequest&, DB::HTTPServerResponse&) @ 0xf84a8ee in /usr/bin/clickhouse
  6. DB::HTTPServerConnection::run() @ 0xf8d35ff in /usr/bin/clickhouse
  7. Poco::Net::TCPServerConnection::start() @ 0x11f7ccbf in /usr/bin/clickhouse
  8. Poco::Net::TCPServerDispatcher::run() @ 0x11f7e6d1 in /usr/bin/clickhouse
  9. Poco::PooledThread::run() @ 0x120b4df9 in /usr/bin/clickhouse
  10. Poco::ThreadImpl::runnableEntry(void*) @ 0x120b0c5a in /usr/bin/clickhouse
  11. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
  12. __clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so (version 21.3.2.5 (official build)) ^C * Terminal will be reused by tasks, press any key to close it.

productdevbook avatar Jul 11 '22 09:07 productdevbook

iam ubuntu 22 and docker swarm used

productdevbook avatar Jul 11 '22 11:07 productdevbook

I encountered the same error today. @productdevbook , did you get the self-hosted solution to work in some other way?

DarthMikke avatar Aug 02 '22 11:08 DarthMikke

Hi All, Today I deployed self-hosted Plausible in the docker swarm environment successfully behind Caddy Server. I used the external Postgres database because I have a Postgres database container already running in the docker swarm.

You have to create plausible_events_db in the clickhouse server container for the first time.

Run docker ps to find out the container ID of the clickhouse server

Run docker exec -it <clickhousecontainerid> clickhouse-client to log into clickhouse server

Then run create database plausible_events_db; to create plausible events database. In this case plausible_events_db

Exit from the container by entering exit

Please find docker-compose stack below

version: "3.7"

services:
  mail:
    image: bytemark/smtp
    networks:
      - caddy
    deploy:
      placement:
        constraints: [node.role == worker]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure  
  plausible_events_db:
    image: yandex/clickhouse-server:latest
    volumes:
      - /mnt/clickhouse:/var/lib/clickhouse
      - /mnt/config/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
      - /mnt/config/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    networks:
      - caddy
    deploy:
      placement:
        constraints: [node.role == worker]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure  
  plausible:
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - postgres
      - plausible_events_db
      - mail
    environment:
      - ADMIN_USER_NAME=admin
      - [email protected]
      - ADMIN_USER_PWD=password
      - DATABASE_URL=postgres://username:password@postgresservicename:5432/plausibledatabsename
      - DATABASE_NAME=plausibledatabsename
      - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/clickhousedatabsename
      - CLICKHOUSE_FLUSH_INTERVAL_MS=5000
      - CLICKHOUSE_MAX_BUFFER_SIZE=10000
      - BASE_URL=https://plausible.example.com
      - PORT=8000
      - LISTEN_IP=0.0.0.0
      - SECRET_KEY_BASE=generate one using 'openssl rand -hex 64'
      - [email protected]
      - SMTP_HOST_ADDR=smtp host name
      - SMTP_HOST_PORT=smtp port
      - SMTP_USER_NAME=smtp user name
      - SMTP_USER_PWD=smtp password
      - SMTP_HOST_SSL_ENABLED=false
      - SMTP_RETRIES=2
    networks:
      - caddy
    ports:
      - "8000:8000"
    deploy:
      placement:
        constraints: [node.role == manager]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
volumes:
  clickhouse:
    driver: "local"
  config:
    driver: "local"
networks:
  caddy:
    external: true

rajasekhar-gundala avatar Aug 27 '22 12:08 rajasekhar-gundala

@rajaseg please share /mnt/ all docs

productdevbook avatar Aug 27 '22 14:08 productdevbook

@rajaseg please share /mnt/ all docs

@productdevbook, I deployed GlusterFS as a replicated volume in my docker swarm environment for data availability throughout the cluster.

That's why I mounted clickhouse server volume and configuration files to /mnt directory

Please find the configuration files below.

/mnt/config/clickhouse-config.xml

<yandex>
    <logger>
        <level>warning</level>
        <console>true</console>
    </logger>

    <!-- Stop all the unnecessary logging -->
    <query_thread_log remove="remove"/>
    <query_log remove="remove"/>
    <text_log remove="remove"/>
    <trace_log remove="remove"/>
    <metric_log remove="remove"/>
    <asynchronous_metric_log remove="remove"/>
</yandex>

/mnt/config/clickhouse-user-config.xml

<yandex>
    <profiles>
        <default>
            <log_queries>0</log_queries>
            <log_query_threads>0</log_query_threads>
        </default>
    </profiles>
</yandex>

Link for the configuration files below.

https://github.com/plausible/hosting/tree/master/clickhouse

rajasekhar-gundala avatar Aug 28 '22 03:08 rajasekhar-gundala

Closing as docker swarm setups are not officially supported.

ruslandoga avatar Sep 14 '23 05:09 ruslandoga