Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] initdb: error: directory "/var/lib/postgresql/data" exists but is not empty If you want to create a new database system, either remove or empty the directory "/var/lib/postgresql/data" or run initdb with an argument other than "/var/lib/postgresql/data" #1

Closed
AlanPadi95 opened this issue Feb 17, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@AlanPadi95
Copy link
Owner

Problem description

On CentOS, when the stack is going to be deployed, the PostgreSQL service is always stopped because of an error creating the DB os using an existing DB.

Extra information

On MacOs, when I type docker stack deploy -c docker-compose.yml awx all services are up & running.

MacOS Docker version: Docker version 19.03.5, build 633a0ea
MacOS Docker Compose version: docker-compose version 1.25.4, build 8d51620a

Stack configuration

version: '3.7'
services:

  web:
    image: ansible/awx_web:9.1.0
    depends_on:
      - rabbitmq
      - memcached
      - postgres
    ports:
      - "8052:8052"
    hostname: awxweb
    user: root
    deploy:
      mode: replicated
      replicas: 1
    volumes:
      - "./config/SECRET_KEY.txt:/etc/tower/SECRET_KEY"
      - "./config/environment.sh:/etc/tower/conf.d/environment.sh"
      - "./config/credentials.py:/etc/tower/conf.d/credentials.py"
      - "./config/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "./projects:/var/lib/awx/projects:rw"
      - "./inventories:/var/lib/awx/inventories:rw"
      # - "/etc/pki/ca-trust/source/anchors:/etc/pki/ca-trust/source/anchors:ro' }}"
      # - "ssl_certificate:/etc/nginx/awxweb.pem:ro"
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  task:
    image: ansible/awx_task:9.1.0
    depends_on:
      - rabbitmq
      - memcached
      - web
      - postgres
    hostname: awx
    user: root
    deploy:
      mode: replicated
      replicas: 1
    volumes:
      - "./config/SECRET_KEY.txt:/etc/tower/SECRET_KEY"
      - "./config/environment.sh:/etc/tower/conf.d/environment.sh"
      - "./config/credentials.py:/etc/tower/conf.d/credentials.py"
      - "./projects:/var/lib/awx/projects:rw"
      # - "/etc/pki/ca-trust/source/anchors:/etc/pki/ca-trust/source/anchors:ro"
      # - "ssl_certificate:/etc/nginx/awxweb.pem:ro"
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  rabbitmq:
    image: ansible/awx_rabbitmq
    ports:
      - "5672:5672"
      - "15672:15672"
    deploy:
      mode: replicated
      replicas: 1
    environment:
      RABBITMQ_DEFAULT_VHOST: "awx"
      RABBITMQ_DEFAULT_USER: "guest"
      RABBITMQ_DEFAULT_PASS: "changeme"
      RABBITMQ_ERLANG_COOKIE: "cookiemonster"
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  memcached:
    image: "memcached"
    ports:
      - "11211:11211"
    deploy:
      mode: replicated
      replicas: 1
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  postgres:
    image: postgres
    user: root
    ports:
      - "5432:5432"
    deploy:
      mode: replicated
      replicas: 1
    volumes:
      - ./postgres/data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: awx
      POSTGRES_PASSWORD: changeme
      POSTGRES_DB: awx
      PGDATA: /var/lib/postgresql/data/pgdata
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''
  
  metricbeat:
    image: docker.elastic.co/beats/metricbeat:${ELASTIC_VERSION:-7.5.2}
    user: root
    environment:
      - KIBANA_HOST='${KIBANA_HOST}:5601'
      - ELASTIC_HOST='${ELASTIC_HOST}:9200'
      - ELASTICSEARCH_USERNAME=${ELASTICSEARCH_USERNAME-elastic}
      - ELASTICSEARCH_PASSWORD=${ELASTICSEARCH_PASSWORD-changeme}
      - AWX_DB_USER=${AWX_DB_USER:-awx}
      - AWX_DB_PASS=${AWX_DB_PASS:-changeme}
      - AWX_RABBITMQ_USER=${AWX_RABBITMQ_USER:-guest}
      - AWX_RABBITMQ_PASS=${AWX_RABBITMQ_PASS:-changeme}
    configs:
      - source: metricbeat_config
        target: /usr/share/metricbeat/metricbeat.yml
    command: -system.hostfs=/hostfs
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
      - /proc:/hostfs/proc:ro
      - /:/hostfs:ro
      - ./metricbeat/dashboards:/usr/share/metricbeat/kibana/7/dashboard:ro
    deploy:
      mode: replicated
      replicas: 1

configs:
  metricbeat_config:
    file: ./metricbeat/config/metricbeat.yml

Docker setup

Docker version 19.03.5, build 633a0ea
docker-compose version 1.25.0, build 0a186604

Docker logs

initdb: error: directory "/var/lib/postgresql/data" exists but is not empty If you want to
create a new database system, either remove or empty the directory
"/var/lib/postgresql/data" or run initdb with an argument other than
"/var/lib/postgresql/data". initdb: error: directory "/var/lib/postgresql/data" exists but
is not empty If you want to create a new database system, either remove or empty
the directory "/var/lib/postgresql/data" or run initdb with an argument other than
"/var/lib/postgresql/data". The files belonging to this database system will be owned
by user "postgres". This user must also own the server process.
@AlanPadi95 AlanPadi95 added the bug Something isn't working label Feb 17, 2020
@AlanPadi95 AlanPadi95 self-assigned this Feb 17, 2020
@AlanPadi95
Copy link
Owner Author

[SOLVED]

Change the PGDATA environment variable from /var/lib/postgresql/data/pgdata to /tmp

version: '3.7'
services:

  web:
    image: ansible/awx_web:9.1.0
    depends_on:
      - rabbitmq
      - memcached
      - postgres
    ports:
      - "8052:8052"
    hostname: awxweb
    user: root
    deploy:
      mode: replicated
      replicas: 1
    volumes:
      - "./config/SECRET_KEY.txt:/etc/tower/SECRET_KEY"
      - "./config/environment.sh:/etc/tower/conf.d/environment.sh"
      - "./config/credentials.py:/etc/tower/conf.d/credentials.py"
      - "./config/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "./projects:/var/lib/awx/projects:rw"
      - "./inventories:/var/lib/awx/inventories:rw"
      # - "/etc/pki/ca-trust/source/anchors:/etc/pki/ca-trust/source/anchors:ro' }}"
      # - "ssl_certificate:/etc/nginx/awxweb.pem:ro"
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  task:
    image: ansible/awx_task:9.1.0
    depends_on:
      - rabbitmq
      - memcached
      - web
      - postgres
    hostname: awx
    user: root
    deploy:
      mode: replicated
      replicas: 1
    volumes:
      - "./config/SECRET_KEY.txt:/etc/tower/SECRET_KEY"
      - "./config/environment.sh:/etc/tower/conf.d/environment.sh"
      - "./config/credentials.py:/etc/tower/conf.d/credentials.py"
      - "./projects:/var/lib/awx/projects:rw"
      # - "/etc/pki/ca-trust/source/anchors:/etc/pki/ca-trust/source/anchors:ro"
      # - "ssl_certificate:/etc/nginx/awxweb.pem:ro"
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  rabbitmq:
    image: ansible/awx_rabbitmq
    ports:
      - "5672:5672"
      - "15672:15672"
    deploy:
      mode: replicated
      replicas: 1
    environment:
      RABBITMQ_DEFAULT_VHOST: "awx"
      RABBITMQ_DEFAULT_USER: "guest"
      RABBITMQ_DEFAULT_PASS: "changeme"
      RABBITMQ_ERLANG_COOKIE: "cookiemonster"
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  memcached:
    image: "memcached"
    ports:
      - "11211:11211"
    deploy:
      mode: replicated
      replicas: 1
    environment:
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''

  postgres:
    image: postgres
    user: root
    ports:
      - "5432:5432"
    deploy:
      mode: replicated
      replicas: 1
    volumes:
      - ./postgres/data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: awx
      POSTGRES_PASSWORD: changeme
      POSTGRES_DB: awx
      PGDATA: /tmp
      http_proxy: ''
      https_proxy: ''
      no_proxy: ''
  
  metricbeat:
    image: docker.elastic.co/beats/metricbeat:${ELASTIC_VERSION:-7.5.2}
    user: root
    environment:
      - KIBANA_HOST='${KIBANA_HOST}:5601'
      - ELASTIC_HOST='${ELASTIC_HOST}:9200'
      - ELASTICSEARCH_USERNAME=${ELASTICSEARCH_USERNAME-elastic}
      - ELASTICSEARCH_PASSWORD=${ELASTICSEARCH_PASSWORD-changeme}
      - AWX_DB_USER=${AWX_DB_USER:-awx}
      - AWX_DB_PASS=${AWX_DB_PASS:-changeme}
      - AWX_RABBITMQ_USER=${AWX_RABBITMQ_USER:-guest}
      - AWX_RABBITMQ_PASS=${AWX_RABBITMQ_PASS:-changeme}
    configs:
      - source: metricbeat_config
        target: /usr/share/metricbeat/metricbeat.yml
    command: -system.hostfs=/hostfs
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /sys/fs/cgroup:/hostfs/sys/fs/cgroup:ro
      - /proc:/hostfs/proc:ro
      - /:/hostfs:ro
      - ./metricbeat/dashboards:/usr/share/metricbeat/kibana/7/dashboard:ro
    deploy:
      mode: replicated
      replicas: 1

configs:
  metricbeat_config:
    file: ./metricbeat/config/metricbeat.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant