微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我将为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时会抛出以下错误

no such file to load — 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

解决方法

您需要将gem’memcache-client’添加到Gemfile中.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐