4

我将为 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/

配置/环境.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
4

1 回答 1

2

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

于 2012-06-25T16:46:47.960 回答