magento部署redis

#编辑 php.ini 增加

extension=igbinary.so
extension=redis.so

#编辑 /etc/php.d/igbinary.ini

注释;extension=igbinary.so

#安装redis
yum list redis
#安装php-redis
yum install php-redis

#安装php-pecl-lzf
yum install php-pecl-lzf
#安装git
yum install git
#安装redis cache extension
git clone https://github.com/colinmollenhour/Cm_Cache_Backend_Redis.git
mkdir -p  app/code/community/Cm/
rsync -vPpar --delete Cm_Cache_Backend_Redis/Cm/ app/code/community/Cm/
rm -rf Cm_Cache_Backend_Redis

#安装redis session extension
git clone https://github.com/colinmollenhour/credis.git
mkdir -p lib/Credis/ app/code/community/Cm/RedisSession/
rsync -vPpar --delete credis/ lib/Credis/
git clone https://github.com/colinmollenhour/Cm_RedisSession.git
rsync -vPpar --delete Cm_RedisSession/code/ app/code/community/Cm/RedisSession/
rsync -vPpar Cm_RedisSession/Cm_RedisSession.xml app/etc/modules/Cm_RedisSession.xml
rm -rf Cm_RedisSession

#修改local.xml
<cache>
    <backend>Cm_Cache_Backend_Redis</backend>
    <backend_options>
        <server>192.168.1.139</server>
        <port>6379</port>
        <persistent></persistent>
        <database>0</database>
        <password></password>
        <force_standalone>0</force_standalone>
        <connect_retries>1</connect_retries>
        <read_timeout>10</read_timeout>
        <automatic_cleaning_factor>0</automatic_cleaning_factor>
        <compress_data>1</compress_data>
        <compress_tags>1</compress_tags>
        <compress_threshold>20480</compress_threshold>
        <compression_lib>lzf</compression_lib>
    </backend_options>
</cache>

<session_save>db</session_save>
<redis_session>            
    <host>192.168.1.139</host> 
    <port>6379</port>
    <timeout>2.5</timeout> 
    <persistent></persistent>
    <db>0</db>
    <compression_threshold>2048</compression_threshold>
    <compression_lib>lzf</compression_lib>          
    <log_broken_locks>0</log_broken_locks>           
    <max_concurrency>10</max_concurrency>
    <break_after_frontend>5</break_after_frontend>
    <break_after_adminhtml>30</break_after_adminhtml>           
    <bot_lifetime>7200</bot_lifetime>                
</redis_session>     

<full_page_cache>
    <backend>Cm_Cache_Backend_Redis</backend>
    <backend_options>
        <server>192.168.1.139</server>
        <port>6379</port>
        <persistent></persistent>
        <database>2</database>
        <password></password>
        <force_standalone>0</force_standalone>
        <connect_retries>1</connect_retries>
        <lifetimelimit>57600</lifetimelimit>
        <compress_data>0</compress_data>
    </backend_options>
</full_page_cache>

#定义垃圾回收脚本
./shell/redis.php
<?php count($argc) or die('<pre>:P</pre>');
ini_set('memory_limit','1024M');
set_time_limit(0);
error_reporting(E_ALL | E_STRICT);
require_once '../app/Mage.php';
Mage::app()->getCache()->getBackend()->clean('old');
// uncomment this for Magento Enterprise Edition
// Enterprise_PageCache_Model_Cache::getCacheInstance()->getFrontend()->getBackend()->clean('old');

0 */4 * * * ( echo "cd /var/www/html/bestbuy/shell/; php redis.php" | /usr/bin/fakechroot /usr/sbin/chroot /var/www/html/bestbuy /bin/bash )

#redis参数说明
daemonize yes ##是否以后台daemon方式运行
pidfile /var/run/redis_6379.pid ##守护进程模式下的 pid文件位置
port 6379 ##监听端口  设置为0则不会监听TCP socket
# bind 127.0.0.1 ##绑定接口监听连接,不设置则监听所有连接
# unixsocket /tmp/redis.sock ##用于监听连接的 unix socket
# unixsocketperm 755 ##socket 文件权限
timeout 0 ##客户端闲置N秒后自动断开连接,0为不限制 #请求超时时间
tcp-keepalive 0 ##TCP 连接存活时间,0不限制, 60(秒)
loglevel notice ##日志级别 debug(调试,大量日志信息) verbose(详细) notice(适度详细) warning(仅记录严重的信息)
logfile /var/log/redis_6379.log ##日志文件,使用stdout,日志会发送到/dev/null
# syslog-enabled no ##开启系统日志
# syslog-ident redis ##系统日志标识
# syslog-facility local0 ##系统日志用户 USER 或 LOCAL0 - LOCAL7
databases 16 ##开启的数据库数量 ,默认使用的是 0  使用SELECT <dbid>进行切换(从0开始)
save 900 1 ##跟进key变更次数,间期创建快照,保存数据到磁盘
save 300 10 ##大于10次key操作,300秒存一次盘
save 60 10000 ##大于10000次60秒;设置为 save "" 则实时存盘
stop-writes-on-bgsave-error yes ##存盘错误时禁止写入
rdbcompression yes ##使用LZF压缩存盘
rdbchecksum yes ##存盘校验 CRC64校验
dbfilename dump.rdb ##存盘数据库文件名
dir /var/lib/redis/6379  ##工作目录,(数据保存路径)
# slaveof <masterip> <masterport>  ##从服务器 上的主服务器信息
# masterauth <master-password> ##主服务器密码
slave-serve-stale-data yes ##从服务器可访问
slave-read-only yes #从服务器只读
# repl-ping-slave-period 10 ##从服务器发送ping信息  间隔10秒
# repl-timeout 60 ##超时时间
repl-disable-tcp-nodelay no ##启用小的TCP 包(系统处理会消耗部分时间)
slave-priority 100 ##从服务器优先权  越小越优先
# requirepass foobared ##使用密码,执行命令之前需要 AUTH <PASSWORD> 验证
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 ##命令重命名
# rename-command CONFIG "" ##命令 移除  ##可能会导致从服务器有问题
# maxclients 10000 ##最大连接数  默认10000
# maxmemory <bytes>  ##内存限制
# maxmemory-policy volatile-lru ##(按近期最少用算法清理)  清理规则具体如下
## volatile-lru -> remove the key with an expire set using an LRU algorithm
## allkeys-lru -> remove any key accordingly to the LRU algorithm
## volatile-random -> remove a random key with an expire set
## allkeys-random -> remove a random key, any key
## volatile-ttl -> remove the key with the nearest expire time (minor TTL)
## noeviction -> don't expire at all, just return an error on write operations
# maxmemory-samples 3 #LRU算法检查的key数量
appendonly no #启用AOF日志模式
# appendfilename appendonly.aof ##AOF模式 文件名
# appendfsync always ##记录全部操作
appendfsync everysec ##每秒记录一次
# appendfsync no ##不记录
no-appendfsync-on-rewrite no ##是否允许覆盖 AOF文件
auto-aof-rewrite-percentage 100 #AOF文件使用超过限制大小100%后自动覆盖
auto-aof-rewrite-min-size 64mb #AOF 文件大小限制
lua-time-limit 5000 ##Lua代码 最大执行时间 ,0为不限制
slowlog-log-slower-than 10000 ##慢执行记录
slowlog-max-len 128 ##慢执行记录最大长度
############################### 高级配置 ###############################
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
## 客户端分类限制:
## normal -> normal clients
## slave  -> slave clients and MONITOR clients
## pubsub -> clients subcribed to at least one pubsub channel or pattern
## client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10 ##键值使用频率分级
aof-rewrite-incremental-fsync yes ##间隔写入AOF文件
# include /path/to/local.conf  ##引入配置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值