I'm using AWS OpsWorks for a Rails application with Redis and Sidekiq and would like to do the following:
我正在使用AWS OpsWorks与Redis和Sidekiq的Rails应用程序,并希望执行以下操作:
- Override the
maxmemory
config for redis - Only run Redis & Sidekiq on a selected EC2 instance
覆盖redis的maxmemory配置
仅在选定的EC2实例上运行Redis和Sidekiq
My current JSON config only has the database.yml overrides:
我当前的JSON配置只有database.yml覆盖:
{
"deploy": {
"appname": {
"database": {
"username": "user",
"password": "password",
"database": "db_production",
"host": "db.host.com",
"adapter": "mysql2"
}
}
}
}
1 个解决方案
#1
Override the maxmemory config for redis
覆盖redis的maxmemory配置
Take a look and see if your Redis cookbook of choice gives you an attribute to set that / provide custom config values. I know the main redisio
one lets you set config value, as I do it on my stacks (I set the path to the on disk cache, I believe)
看看您选择的Redis菜谱是否为您提供了设置/提供自定义配置值的属性。我知道主要的redisio允许你设置配置值,就像我在我的堆栈上做的那样(我设置了磁盘缓存的路径,我相信)
Only run Redis & Sidekiq on a selected EC2 instance
仅在选定的EC2实例上运行Redis和Sidekiq
This part is easy: create a Layer for Redis (or Redis/Sidekiq) and add an instance to that layer.
这部分很简单:为Redis(或Redis / Sidekiq)创建一个Layer,并为该层添加一个实例。
Now, because Redis is on a different instance than your Rails server, you won't necessarily know what the IP address for your Redis server is. Especially since you'll probably want to use the internal EC2 IP address vs the public IP address for the box (using the internal address means you're already inside the default firewall).
现在,因为Redis与Rails服务器位于不同的实例上,所以您不一定知道Redis服务器的IP地址是什么。特别是因为你可能想要使用内部EC2 IP地址与盒子的公共IP地址(使用内部地址意味着你已经在默认防火墙内)。
Sooo... what you'll probably need to do is to write a custom cookbook for your app, if you haven't already. In your attributes/default.rb
write some code like this:
Sooo ...您可能需要做的就是为您的应用编写自定义食谱,如果您还没有。在您的attributes / default.rb中编写如下代码:
redis_instance_details = nil
redis_stack_name = "REDIS"
redis_instance_name, redis_instance_details = node["opsworks"]["layers"][redis_stack_name]["instances"].first
redis_server_dns = "127.0.0.1"
if redis_instance_details
redis_server_dns = redis_instance_details["private_dns_name"]
end
Then later in the attributes file set your redis config to your redis_hostname (maybe using it to set:
然后在属性文件中将redis配置设置为redis_hostname(可能使用它来设置:
default[:deploy][appname][:environment_variables][:REDIS_URL] = "redis://#{redis_server_dns}:#{redis_port_number}"
Hope this helps!
希望这可以帮助!
#1
Override the maxmemory config for redis
覆盖redis的maxmemory配置
Take a look and see if your Redis cookbook of choice gives you an attribute to set that / provide custom config values. I know the main redisio
one lets you set config value, as I do it on my stacks (I set the path to the on disk cache, I believe)
看看您选择的Redis菜谱是否为您提供了设置/提供自定义配置值的属性。我知道主要的redisio允许你设置配置值,就像我在我的堆栈上做的那样(我设置了磁盘缓存的路径,我相信)
Only run Redis & Sidekiq on a selected EC2 instance
仅在选定的EC2实例上运行Redis和Sidekiq
This part is easy: create a Layer for Redis (or Redis/Sidekiq) and add an instance to that layer.
这部分很简单:为Redis(或Redis / Sidekiq)创建一个Layer,并为该层添加一个实例。
Now, because Redis is on a different instance than your Rails server, you won't necessarily know what the IP address for your Redis server is. Especially since you'll probably want to use the internal EC2 IP address vs the public IP address for the box (using the internal address means you're already inside the default firewall).
现在,因为Redis与Rails服务器位于不同的实例上,所以您不一定知道Redis服务器的IP地址是什么。特别是因为你可能想要使用内部EC2 IP地址与盒子的公共IP地址(使用内部地址意味着你已经在默认防火墙内)。
Sooo... what you'll probably need to do is to write a custom cookbook for your app, if you haven't already. In your attributes/default.rb
write some code like this:
Sooo ...您可能需要做的就是为您的应用编写自定义食谱,如果您还没有。在您的attributes / default.rb中编写如下代码:
redis_instance_details = nil
redis_stack_name = "REDIS"
redis_instance_name, redis_instance_details = node["opsworks"]["layers"][redis_stack_name]["instances"].first
redis_server_dns = "127.0.0.1"
if redis_instance_details
redis_server_dns = redis_instance_details["private_dns_name"]
end
Then later in the attributes file set your redis config to your redis_hostname (maybe using it to set:
然后在属性文件中将redis配置设置为redis_hostname(可能使用它来设置:
default[:deploy][appname][:environment_variables][:REDIS_URL] = "redis://#{redis_server_dns}:#{redis_port_number}"
Hope this helps!
希望这可以帮助!