Project

General

Profile

Actions

Bug #12727

closed

I can't seed the foreman db,please help me.

Added by xin jianguo over 8 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

hi:
I follow foreman manual doc and install foreman from source.
when I follow this command:
RAILS_ENV=production bundle exec rake db:migrate
it exec sucess.

when I follow this command:
RAILS_ENV=production bundle exec rake db:seed assets:precompile locale:pack . it exec failed.
follow errors:
ActiveRecord::RecordInvalid: Validation failed: Value must be a valid URI
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:56:in `save!'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:264:in `block in save!'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:264:in `save!'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:41:in `create!'
when I follow this command:
rake test

it follow errors:
2015-12-07T20:01:34 [app] [W] <ActiveRecord::StatementInvalid> Could not find table 'users'

I connect mysqldb and exec "show tables",the "users" tables is exist.

My OS is:Red Hat Enterprise Linux Server release 6.6
My db: 5.6.23-log MySQL Community Server

Actions #1

Updated by Dominic Cleal over 8 years ago

  • Status changed from New to Feedback

It's likely that the server's FQDN can't be resolved. Check facter fqdn returns an FQDN.

Otherwise ensure you have a section like this in config/settings.yaml:

# Local administrative settings for application domain, fqdn, foreman URL,
# administrator email address etc. If you don't have a Puppet provisioning
# system you may want to change to setup your project on your local machine.
:domain: 'localdomain.net'
:fqdn: 'localhost.localdomain.net'

Change domain and FQDN as appropriate for your environment.

I'd also strongly recommend using our installer for production environments (http://theforeman.org/manuals/latest/quickstart_guide.html).

Actions #2

Updated by xin jianguo over 8 years ago

hi :
I set set.yaml as: # Local administrative settings for application domain, fqdn, foreman URL,
  1. administrator email address etc. If you don't have a Puppet provisioning
  2. system you may want to change to setup your project on your local machine.
    :domain: 'yf_30_140.sogou-in.domain'
    :fqdn: 'yf_30_140.sogou-in.domain'

here is my ping:
[root@yf_30_140 foreman-1.9.3]# ping yf_30_140.sogou-in.domain
PING yf_30_140.sogou-in.domain (10.139.30.140) 56(84) bytes of data.
64 bytes from yf_30_140.sogou-in.domain (10.139.30.140): icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from yf_30_140.sogou-in.domain (10.139.30.140): icmp_seq=2 ttl=64 time=0.020 ms
64 bytes from yf_30_140.sogou-in.domain (10.139.30.140): icmp_seq=3 ttl=64 time=0.026 ms
64 bytes from yf_30_140.sogou-in.domain (10.139.30.140): icmp_seq=4 ttl=64 time=0.016 ms

and then I exec:
RAILS_ENV=production bundle exec rake db:seed assets:precompile locale:pack

Follow same error:
Apipie cache enabled but not present yet. Run apipie:cache rake task to speed up API calls.
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Value must be a valid URI
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:56:in `save!'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:264:in `block in save!'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
.........
/usr/local/src/foreman-1.9.3/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/railties/databases.rake:346:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:abort_if_pending_migrations => environment
(See full trace by running task with --trace)

when I exec :
rake test
Follow this same error:
2015-12-07T22:12:01 [app] [I] Connecting to database specified by database.yml
The Apipie cache is turned off. Enable it and run apipie:cache rake task to speed up API calls.
2015-12-07T22:12:04 [app] [W] <ActiveRecord::StatementInvalid> Could not find table 'users'

Hi,Three days ago,I use foreman-installer to install foreman,It'turn out the error as same as the error that use from source way. when I exec: rake:db seed ,It can't exec corretly. so I use source but it can't work normally.

Need I config puppet or facter?Need I config other forman configfile? here is my setting.yaml:

---
:unattended: true
:login: true
:require_ssl: false
:locations_enabled: false
:organizations_enabled: false

:support_jsonp: false

:mark_translated: false

:domain: 'yf_30_140.sogou-in.domain'
:fqdn: 'yf_30_140.sogou-in.domain'

:logging:
:level: debug

here is my database.yaml

  1. SQLite version 3.x
  2. gem install sqlite3
    development:
    adapter: sqlite3
    database: db/development.sqlite3
    pool: 5
    timeout: 5000
  1. Warning: The database defined as "test" will be erased and
  2. re-generated from your development database when you run "rake".
  3. Do not set this db to the same as development or production.
    test:
    adapter: sqlite3
    database: db/test.sqlite3
    pool: 5
    timeout: 5000

production:
adapter: mysql2
host: xxxxxxxxxxxxxxx
port: 3306
database: foreman
username: foreman
password: "foreman"
pool: 5

Actions #3

Updated by Dominic Cleal over 8 years ago

Try dropping and recreating the database, or at least all of the contents of the "settings" table.

xin jianguo wrote:

Hi,Three days ago,I use foreman-installer to install foreman,It'turn out the error as same as the error that use from source way. when I exec: rake:db seed ,It can't exec corretly. so I use source but it can't work normally.

Need I config puppet or facter?Need I config other forman configfile? here is my setting.yaml:

No need to configure Puppet or Facter if you don't want to, but Facter is used to retrieve your FQDN. It sounds like the server's hostname isn't correctly configured.

The fqdn now in the settings file should do it instead, but you may need to clear the settings already loaded.

Actions #4

Updated by xin jianguo over 8 years ago

hi Dominic Cleal:
The problem has been resolved.you are right. I change my hostname and clean database,it works. Thank you very much.

Actions #5

Updated by Dominic Cleal over 8 years ago

  • Status changed from Feedback to Resolved

Glad to hear.

Actions

Also available in: Atom PDF