没有这样的文件加载 - memcache但它已安装?

时间:2012-06-25 11:10:16

标签: ruby ruby-on-rails-3 gem memcached redmine

我将为Redmine设置负载平衡和故障转移:

HAProxy 1 ------- Apache 1  ------- MySQL 1
     |           (Repcached)             |
     |                |                  |
(virtual IP)    (memcached repl)   (master-master repl)
     |                |                  |
     |           (Repcached)             |
HAProxy 2 ------- Apache 2  ------- MySQL 2

我希望使用repcached进行会话存储:

/usr/local/memcached/bin/memcached -d -u memcached -l 192.168.3.118 -c 512 -t 8 -m 512 -p 11211 -P /usr/local/memcached/var/run/redmine.pid -f 1.25 -x 192.168.6.142 -X 112110

复制功能正常工作(由telnet测试)。

memcache-client已安装:

# gem list memcache-client

*** LOCAL GEMS ***

memcache-client (1.8.5)

并且可以从命令行加载:

# su - apache -s /bin/bash
-bash-3.2$ gem contents --no-prefix memcache-client
FAQ.rdoc
History.rdoc
LICENSE.txt
README.rdoc
Rakefile
bin/memcached_top
lib/continuum_native.rb
lib/memcache.rb
lib/memcache/event_machine.rb
lib/memcache/version.rb
lib/memcache_util.rb
performance.txt
test/test_benchmark.rb
test/test_event_machine.rb
test/test_mem_cache.rb

-bash-3.2$ ruby -rubygems -e 'require "memcache"'
-bash-3.2$ echo $?
0

我的服务器上只有一个Ruby版本:

-bash-3.2$ which ruby
/usr/bin/ruby
-bash-3.2$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.10
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /var/www/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

到config / environment.rb

require 'memcache'

config.action_controller.session_store = :mem_cache_store

memcache_options = {
   :compression => true,
   :debug => false,
   :namespace => "mem-#{RAILS_ENV}",
   :readonly => false,
   :urlencode => false
}

memcache_servers = [ '192.168.3.118:11211', '192.168.6.142:11211' ]

CACHE = MemCache.new(memcache_options)
CACHE.servers = memcache_servers
ActionController::Base.session_options[:cache] = CACHE

但重启Apache时会抛出以下错误:

  

没有要加载的文件 - memcache

我错过了什么吗?

PS:

  Redmine version                          2.0.3.stable
  Ruby version                             1.8.7 (x86_64-linux)
  Rails version                            3.2.6
  Environment                              production
  Database adapter                         MySQL

1 个答案:

答案 0 :(得分:2)

您需要将gem 'memcache-client'添加到Gemfile。