2016-04-07 25 views
2

Rails projemi Azure'da SQL ile yapılandırmaya çalışıyorum. Mac OS X 10.11 kullanıyorum.Raylar ve Azure: TinyTds :: Hata: Adaptive Server bağlantısı başarısız oldu

Bu benim config/database.yml parçasıdır:

staging: 
    adapter: sqlserver 
    mode: dblib 
    host: db-staging.database.windows.net 
    port: 1433 
    database: db-staging 
    username: [email protected] 
    password: mypass 
    timeout: 5000 
    azure: true 

Ben tsql gibi görünüyor çalıştırmak

Tamam her şeydir:

$ tsql -H db-staging.database.windows.net -U myuser -P 'mypass' -v -p 1433 -D db-staging 
locale is "en_US.UTF-8" 
locale charset is "UTF-8" 
using default charset "UTF-8" 
Setting db-staging as default database in login packet 
Changed database context to 'db-staging'. 
Changed language setting to us_english. 
1> 

Ama rake db:migrate çalıştırdığınızda bu hatayı TinyTds::Error: Adaptive Server connection failed alırsınız. İşte

tam iz: Ben bu gibi diğer sorular gördük

$ rake db:migrate RAILS_ENV=staging --trace                  
** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly: 

    * development - set it to false 
    * test - set it to false (unless you use a tool that preloads your test environment) 
    * production - set it to true 

** Invoke db:load_config (first_time) 
** Execute db:load_config 
** Execute db:migrate 
rake aborted! 
TinyTds::Error: Adaptive Server connection failed 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/tiny_tds-0.7.0/lib/tiny_tds/client.rb:74:in `connect' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/tiny_tds-0.7.0/lib/tiny_tds/client.rb:74:in `initialize' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:311:in `new' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:311:in `dblib_connect' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:302:in `connect' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:58:in `initialize' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/sqlserver_base.rb:17:in `new' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/sqlserver_base.rb:17:in `sqlserver_connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:113:in `retrieve_connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:87:in `connection' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:912:in `initialize' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `new' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `up' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:797:in `migrate' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/tasks/database_tasks.rb:137:in `migrate' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `call' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run' 
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>' 
/Users/monteirobrena/.rvm/gems/ruby-2.0.0-p481/bin/rake:23:in `load' 
/Users/monteirobrena/.rvm/gems/ruby-2.0.0-p481/bin/rake:23:in `<main>' 
Tasks: TOP => db:migrate 

ama bana yardım etmedi:

TinyTds::Error: Adaptive Server connection failed

TinyTds Error: Adaptive Server connection timed out

[Güncellendi]

Aynısını yapmayı denedim burada: config/database.yml Bu gönderiyi takip ederek, config/database.yml numaralı telefonumda ayarlanacak doğru yapılandırmaları buldum. Benim proje klasöre erişim ve rails s çalıştırdığınızda

gem 'tiny_tds' 
gem 'activerecord-sqlserver-adapter' 

Şimdi benim veritabanı ve her şeyi çalışma cezası ile bağlanabilir:

staging: 
    adapter: sqlserver 
    username: '[email protected]' 
    password: 'password' 
    host: 'db-staging.database.windows.net' 
    port: 1433 
    database: 'db-staging' 
    azure: true 

https://azure.microsoft.com/en-us/documentation/articles/sql-database-develop-ruby-simple-mac-osx/ Ve eklemek bu taşlar benim Gemfile im. Ben Puma ve Nginx ile projemi çalıştırırsanız Ama, bu hatayı alırsınız:

TinyTds::Error (Adaptive Server connection failed): 

[/ Güncelleme]

cevap

0
Bence derleme argümanlar geçemez apt-get eğer başıma FreeTDS yüklemek gerek

:

wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz 

$ tar -zxvf freetds-stable.tgz 

$ cd freetds-0.91/ 

$ ./configure --with-tdsver=8.0 --with-openssl=/usr/bin 

$ make 

$ sudo make install 

Ve şimdi benim veritabanına erişebilir:

$ tsql -C# OK! 

$ TDSVER=8.0 tsql -H mydb.database.windows.net -p 1433 -U [email protected] -P mypassword -D mydb 

Ve her şey Puma, Nginx ve Capistrano ile koştuğumda ve çalışınca çalışır.

daha buraya bakınız:

https://github.com/rails-sqlserver/tiny_tds/issues/266