Discourse Multisite > Access denied on db:migrate


(Luke) #1

So, I’ve been trying to setup multisite, and the only problem I have come across is this one:

I, [2015-02-28T02:37:11.302090 #36]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
URGENT: FATAL:  password authentication failed for user "discourse"
FATAL:  password authentication failed for user "discourse"
 Failed to initialize site default
URGENT: FATAL:  password authentication failed for user "discourse"
FATAL:  password authentication failed for user "discourse"
 Failed to initialize site secondsite
URGENT: FATAL:  password authentication failed for user "discourse"
FATAL:  password authentication failed for user "discourse"
 Failed to initialize site thirdsite
rake aborted!
PG::ConnectionBad: FATAL:  password authentication failed for user "discourse"
FATAL:  password authentication failed for user "discourse"
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/connection_handling.rb:87:in `connection'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/migration.rb:916:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/migration.rb:814:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/migration.rb:814:in `up'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/migration.rb:792:in `migrate'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.9/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I, [2015-02-28T02:37:16.868844 #36]  INFO -- : 


FAILED
--------------------
RuntimeError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 24367 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:105:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
ef235298bb7296e50a9ca14a1a9ac850281f383b0c39b8e08eb56d888c17822b
FAILED TO BOOTSTRAP

data.yml

# A container for all things Data, be sure to set a secret password for
# discourse account, SOME_SECRET is just an example
#

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/sshd.template.yml"
  - "templates/cron.template.yml"

expose:
  - "5432:5432"
  - "6379:6379"
  - "2221:22"
params:
  db_default_text_search_config: "pg_catalog.english"
  ## Set db_shared_buffers to 1/3 of the memory you wish to allocate to postgres
  ## on 1GB install set to 128MB on a 4GB instance you may raise to 1GB
  #db_shared_buffers: "256MB"

env:
  # ensure locale exists in container, you may need to install it
  LANG: en_US.UTF-8

volumes:
  - volume:
        host: /var/discourse/shared/data
        guest: /shared
  - volume:
        host: /var/discourse/shared/data/log/var-log
        guest: /var/log

# TODO: SOME_SECRET to a password for the discourse user
hooks:
  after_postgres:
    - exec:
        stdin: |
          alter user discourse with password 'blahblah';
        cmd: su - postgres -c 'psql discourse'

        raise_on_fail: false

# Craftd
hooks:
  after_postgres:
     - exec: sudo -u postgres createdb craftd_discourse || exit 0
     - exec:
          stdin: |
            grant all privileges on database craftd_discourse to discourse;
          cmd: sudo -u postgres psql craftd_discourse
          raise_on_fail: false
 
     - exec: /bin/bash -c 'sudo -u postgres psql craftd_discourse <<< "alter schema public owner to discourse;"'
     - exec: /bin/bash -c 'sudo -u postgres psql craftd_discourse <<< "create extension if not exists hstore;"'
     - exec: /bin/bash -c 'sudo -u postgres psql craftd_discourse <<< "create extension if not exists pg_trgm;"'

hooks:
  after_postgres:
     - exec: sudo -u postgres createdb persia_discourse || exit 0                                                                
     - exec:
          stdin: |
            grant all privileges on database persia_discourse to discourse;
          cmd: sudo -u postgres psql persia_discourse
          raise_on_fail: false

     - exec: /bin/bash -c 'sudo -u postgres psql persia_discourse <<< "alter schema public owner to discourse;"'
     - exec: /bin/bash -c 'sudo -u postgres psql persia_discourse <<< "create extension if not exists hstore;"'
     - exec: /bin/bash -c 'sudo -u postgres psql persia_discourse <<< "create extension if not exists pg_trgm;"'
root@discourse:/var/discourse# 

web_only.yml

# IMPORTANT: SET A SECRET PASSWORD in Postgres for the Discourse User
# TODO: change SOME_SECRET in this template

templates:
  - "templates/sshd.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"

expose:
  - "80:80"
  - "2222:22"

params:
  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LANG: en_US.UTF-8
  ## TODO: How many concurrent web requests are supported?
  ## With 2GB we recommend 3-4 workers, with 1GB only 2
  UNICORN_WORKERS: 4

  ## TODO: configure connectivity to the databases
  DISCOURSE_DB_SOCKET: ''
  #DISCOURSE_DB_USER: discourse
  DISCOURSE_DB_PASSWORD: blah
  DISCOURSE_DB_HOST: 172.17.42.1
  DISCOURSE_REDIS_HOST: 172.17.42.1
  ##
  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'miley.cyrus@instagram.com'
  ##
  ## TODO: The domain name this Discourse instance will respond to
  DISCOURSE_HOSTNAME: 'discourse.example.com'
  ##
  ## TODO: The mailserver this Discourse instance will use
  DISCOURSE_SMTP_ADDRESS: blahblahsmtp.com         # (mandatory)
  DISCOURSE_SMTP_PORT: 587                        # (optional)
  DISCOURSE_SMTP_USER_NAME: babydaddy@gmail.com   # (optional)
  DISCOURSE_SMTP_PASSWORD: blahblahsecret            # (optional)
  DISCOURSE_SMTP_AUTHENTICATION: login  
##
  ## The CDN address for this Discourse instance (configured to pull)
  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

volumes:
  - volume:
      host: /var/discourse/shared/web-only
      guest: /shared
  - volume:
      host: /var/discourse/shared/web-only/log/var-log
      guest: /var/log

#Use 'links' key to link containers together, aka use Docker --link flag.
links:
  - link:
      name: data
      alias: data

## The docker manager plugin allows you to one-click upgrade Discouse
## http://discourse.example.com/admin/docker
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git

#multisite
hooks:
  after_code:
    - file:
        path: /var/www/discourse/config/multisite.yml
        contents: |
         secondsite:
           adapter: postgresql
           host: 172.17.42.1
           database: craftd_discourse
           username: discourse
           password: blah
           pool: 25
           timeout: 5000
           db_id: 2
           host_names:
             - discourse.craftd.net
             - forums.craftd.net
         thirdsite:
           adapter: postgresql
           host: 172.17.42.1
           database: persia_discourse
           username: discourse
           password: blah
           pool: 25
           timeout: 5000
           db_id: 3
           host_names:
             - forums.persian-world.com
             - forums.persian-world.comt
## Remember, this is YAML syntax - you can only have one block with a name
run:
  - exec: echo "Beginning of custom commands"

  ## If you want to configure password login for root, uncomment and change:
  #- exec: apt-get -y install whois # for mkpasswd
  ## Use only one of the following lines:
  #- exec: /usr/sbin/usermod -p 'PASSWORD_HASH' root
  #- exec: /usr/sbin/usermod -p "$(mkpasswd -m sha-256 'RAW_PASSWORD')" root

  ## If you want to authorized additional users, uncomment and change:
  #- exec: ssh-import-id username
  #- exec: ssh-import-id anotherusername

  - exec: echo "End of custom commands"
  - exec: awk -F\# '{print $1;}' ~/.ssh/authorized_keys | awk 'BEGIN { print "Authorized SSH keys for this container:"; } NF>=2 {print $NF;}'

Please help! :frowning:

At first I forgot to put the links: in, but even after that it still refuses to work.


(Sigurður Guðbrandsson) #2

Did you have a multi container setup before you started multisite?


(Kane York) #3

If you didn’t have a multi-container setup before you started doing multisite, you should just stick with one-container multisite.


(Sigurður Guðbrandsson) #4

I agree with @riking - it’s much easier to manage, and it doesn’t have any negative impacts.

Multi-container setup is something you might want to think about when your standard server can’t handle the load … which is unlikely in most forums.


(Luke) #5

Is there any documentation on this?


(Sigurður Guðbrandsson) #6

For the negative impacts or how to set up multi forum on a standalone setup?