Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento和Redis:与Redis的连接在2次失败后失败升级/降级Redis后出错_Magento_Redis - Fatal编程技术网

Magento和Redis:与Redis的连接在2次失败后失败升级/降级Redis后出错

Magento和Redis:与Redis的连接在2次失败后失败升级/降级Redis后出错,magento,redis,Magento,Redis,最近,我在一台临时服务器(单独的web服务器和DB服务器,DB服务器是运行Redis的服务器)上设置了Redis,以便使用Magento实例进行缓存,它已经运行了一段时间,但问题很少。唯一的问题是偶尔会出现通信错误,因此为了解决这个问题,我将Redis版本从2.4.10升级到最新的3.2.1。我还应该注意,从一开始,我就在三个单独的端口上运行了三个单独的实例,这通常是在您希望将Redis用于Magento中可以执行的所有三种类型的缓存时推荐的 在确保升级后可以在所有三个端口上ping Redis

最近,我在一台临时服务器(单独的web服务器和DB服务器,DB服务器是运行Redis的服务器)上设置了Redis,以便使用Magento实例进行缓存,它已经运行了一段时间,但问题很少。唯一的问题是偶尔会出现通信错误,因此为了解决这个问题,我将Redis版本从2.4.10升级到最新的3.2.1。我还应该注意,从一开始,我就在三个单独的端口上运行了三个单独的实例,这通常是在您希望将Redis用于Magento中可以执行的所有三种类型的缓存时推荐的

在确保升级后可以在所有三个端口上ping Redis后,我重新将Magento连接到它,并立即开始出现错误,表明它根本无法连接:在两次失败后连接到Redis失败。我尝试了一段时间来解决这个问题,最终将Redis包降级到2.4.10,结果遇到了同样的问题。我甚至在Redis 3.2.1之前的本地环境中完成了所有这些工作,并且没有遇到任何这些问题。我觉得我肯定错过了什么,但我觉得我什么都试过了。Redis日志文件完全正常,只是报告启动成功。所有Magento Redis库都是最新的,从Github中提取/etc/init.d/redis文件是标准文件的修改版本,从github上的某个地方提取,以支持启动多个实例

Magento的local.xml:

<config>
    <global>
        <install>
            <date><![CDATA[Sat, 11 Jul 2015 08:00:49 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[24d48474f523332d6dbcd9d1d6931c98]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]></table_prefix>
            </db>
            <default_setup>
                <connection>
                    <host><![CDATA[(address)]]></host>
                    <username><![CDATA[root]]></username>
                    <password><![CDATA[password]]></password>
                    <dbname><![CDATA[magento]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <cache>
          <backend>Cm_Cache_Backend_Redis</backend>
          <backend_options>
            <server><![CDATA[(address)]]></server>                               <!-- or absolute path to unix socket -->
            <port><![CDATA[6379]]></port>
            <persistent></persistent>                                <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
            <database>0</database>                                   <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
            <password></password>                                    <!-- Specify if your Redis server requires authentication -->
            <force_standalone>0</force_standalone>                   <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>                     <!-- Reduces errors due to random connection failures; a value of 1 will not retry after the first failure -->
            <read_timeout>10</read_timeout>                          <!-- Set read timeout duration; phpredis does not currently support setting read timeouts -->
            <automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
            <compress_data>1</compress_data>                         <!-- 0-9 for compression level, recommended: 0 or 1 -->
            <compress_tags>1</compress_tags>                         <!-- 0-9 for compression level, recommended: 0 or 1 -->
            <compress_threshold>20480</compress_threshold>           <!-- Strings below this size will not be compressed -->
            <compression_lib>gzip</compression_lib>                  <!-- Support gzip, lzf, lz4 (https://github.com/kjdev/php-ext-lz4) or snappy (https://github.com/goatherd/php-snappy) -->
            <use_lua>0</use_lua>                                     <!-- Set to 1 if Lua scripts should be used for some operations -->
          </backend_options>
        </cache>
        <full_page_cache>
          <backend>Cm_Cache_Backend_Redis</backend>
          <backend_options>
            <server><![CDATA[(address)]]></server>              <!-- or absolute path to unix socket -->
            <port><![CDATA[6380]]></port>
            <persistent></persistent>               <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
            <database>0</database>                  <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
            <password></password>                   <!-- Specify if your Redis server requires authentication -->
            <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
            <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
            <read_timeout>10</read_timeout>                          <!-- Set read timeout duration; phpredis does not currently support setting read timeouts -->
            <lifetimelimit>57600</lifetimelimit>    <!-- 16 hours of lifetime for cache record -->
            <compress_data>0</compress_data>        <!-- DISABLE compression for EE FPC since it already uses compression -->
          </backend_options>
        </full_page_cache>
        <session_save>db</session_save>
        <redis_session>                                          <!-- All options seen here are the defaults -->
            <host><![CDATA[(address)]]></host>                               <!-- Specify an absolute path if using a unix socket -->
            <port><![CDATA[6381)]]></port>
            <password></password>                                <!-- Specify if your Redis server requires authentication -->
            <timeout>4</timeout>                               <!-- This is the Redis connection timeout, not the locking timeout -->
            <persistent></persistent>                            <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
            <db>0</db>                                           <!-- Redis database number; protection from accidental loss is improved by using a unique DB number for sessions -->
            <compression_threshold>2048</compression_threshold>  <!-- Set to 0 to disable compression (recommended when suhosin.session.encrypt=on); known bug with strings over 64k: https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/18 -->
            <compression_lib>gzip</compression_lib>              <!-- gzip, lzf, lz4 (https://github.com/kjdev/php-ext-lz4) or snappy (https://github.com/goatherd/php-snappy) -->
            <log_level>1</log_level>                             <!-- 0 (emergency: system is unusable), 4 (warning; additional information, recommended), 5 (notice: normal but significant condition), 6 (info: informational messages), 7 (debug: the most information for development/testing) -->
            <max_concurrency>6</max_concurrency>                 <!-- maximum number of processes that can wait for a lock on one session; for large production clusters, set this to at least 10% of the number of PHP processes -->
            <break_after_frontend>5</break_after_frontend>       <!-- seconds to wait for a session lock in the frontend; not as critical as admin -->
            <break_after_adminhtml>30</break_after_adminhtml>
            <first_lifetime>600</first_lifetime>                 <!-- Lifetime of session for non-bots on the first write. 0 to disable -->
            <bot_first_lifetime>60</bot_first_lifetime>          <!-- Lifetime of session for bots on the first write. 0 to disable -->
            <bot_lifetime>7200</bot_lifetime>                    <!-- Lifetime of session for bots on subsequent writes. 0 to disable -->
            <disable_locking>0</disable_locking>                 <!-- Disable session locking entirely. -->
            <min_lifetime>60</min_lifetime>                      <!-- Set the minimum session lifetime -->
            <max_lifetime>2592000</max_lifetime>                 <!-- Set the maximum session lifetime -->
        </redis_session>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

任何其他想法都将不胜感激。

我设法找到了解决方案。在升级过程中,在我来回查看配置文件的过程中,我原来的“bind0.0.0.0”行被更改为“bind127.0.0.1”。把它改回去,一切都好了。

建议阅读:我设法找到了解决办法。在升级过程中,在我来回查看配置文件的过程中,我原来的“bind0.0.0.0”行被更改为“bind127.0.0.1”。更改后修复了所有问题。@BClarkOMP能否将该发现作为答案发布,并接受它,以防将来对其他人有所帮助?请详细解释该问题,以便其他人参考并获得解决方案。此绑定ip位于何处?我使用的是Magento 2版本,在env.php文件中有三个位置。1) 前端,2)后端3)会话阵列。我该换哪一个@B克拉康普
#!/bin/sh
#
# redis        init file for starting up the redis daemon
#
# chkconfig:   - 20 80
# description: Starts and stops the redis daemon.

# Source function library.
. /etc/rc.d/init.d/functions

name="redis-server"
exec="/usr/sbin/$name"
#shut="/usr/bin/redis-shutdown"
#pidfile="/var/run/redis/redis.pid"
#REDIS_CONFIG="/etc/redis.conf"
PORT_NUMBERS=$(grep "^port" /etc/redis.conf-* | awk '{print $NF}')

[ -e /etc/sysconfig/redis ] && . /etc/sysconfig/redis

#lockfile=/var/lock/subsys/redis

start() {
    for PORT in $PORT_NUMBERS; do
                REDIS_CONFIG="/etc/redis.conf-${PORT}"
                pidfile="/var/run/redis/redis-${PORT}.pid"
                lockfile="/var/lock/subsys/redis-${PORT}"
        [ -f $REDIS_CONFIG ] || exit 6
        [ -x $exec ] || exit 5
        echo -n $"Starting $name on $PORT: "
        daemon --user ${REDIS_USER-redis} "$exec $REDIS_CONFIG"
        retval=$?
        echo
        [ $retval -eq 0 ] && touch $lockfile
        done
    return $retval
}

stop() {
    for PORT in $PORT_NUMBERS; do
       REDIS_CONFIG="/etc/redis.conf-${PORT}"
                pidfile="/var/run/redis/redis-${PORT}.pid"
                lockfile="/var/lock/subsys/redis-${PORT}"
        [ -f $REDIS_CONFIG ] || exit 6
        [ -x $exec ] || exit 5
        echo -n $"Starting $name on $PORT: "
        daemon --user ${REDIS_USER-redis} "$exec $REDIS_CONFIG"
        retval=$?
        echo
        [ $retval -eq 0 ] && touch $lockfile
        done
    return $retval
}

stop() {
    for PORT in $PORT_NUMBERS; do
        echo -n $"Stopping $name on $PORT: "
                pidfile="/var/run/redis/redis-${PORT}.pid"
                lockfile="/var/lock/subsys/redis-${PORT}"
        [ -x $shut ] && $shut
        retval=$?
        if [ -f $pidfile ]
        then
                # shutdown haven't work, try old way
                killproc -p $pidfile $name
                retval=$?
        else
                success "$name shutdown"
        fi
         echo
        [ $retval -eq 0 ] && rm -f $lockfile
        done
    return $retval
}
restart() {
    stop
    start
}

reload() {
    false
}

rh_status() {
    for PORT in $PORT_NUMBERS; do
                pidfile="/var/run/redis/redis-${PORT}.pid"
        status -p $pidfile $name
        done
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
        exit 2
esac
exit $?