phpRedisAdmin 使用的 predis 本身是支持集群的,但是他没做配置。
按照下面方式修改即可支持集群。
修改文件:includes/common.inc.php
修改内容:
// Setup a connection to Redis.
if(isset($server[‘scheme’]) && $server[‘scheme’] === ‘unix’ && $server[‘path’]) {
$redis = new Predis\Client(array(‘scheme’ => ‘unix’, ‘path’ => $server[‘path’]));
} else {
if (isset($server[‘cluster’])){ //新增集群配置判断
$redis = new Predis\Client(array(‘cluster’ => $server[‘host’],’exceptions’ => true)); //新增集群连接
}else{
$redis = !$server[‘port’] ? new Predis\Client($server[‘host’]) : new Predis\Client(‘tcp://’.$server[‘host’].’:’.$server[‘port’]);
}
}
配置文件参考:
array(
‘name’ => ‘cluster’, // Optional name.
‘cluster’ => true,
‘host’ => ‘redis://172.17.0.3:7000,redis://172.17.0.3:7001,redis://172.17.0.3:7002,redis://172.17.0.3:7003,redis://172.17.0.3:7004,redis://172.17.0.3:7005’,
‘filter’ => ‘*’,
‘scheme’ => ‘tcp’, // Optional. Connection scheme. ‘tcp’ – for TCP connection, ‘unix’ – for connection by unix domain socket
‘path’ => ”, // Optional. Path to unix domain socket. Uses only if ‘scheme’ => ‘unix’. Example: ‘/var/run/redis/redis.sock’
‘hide’ => false, // Optional. Override global setting. Hide empty databases in the database list.
‘auth’ => ‘xxxxxx’,
// Optional Redis authentication.
//’auth’ => ‘redispasswordhere’ // Warning: The password is sent in plain-text to the Redis server.
),