1、下载群集扩展
| 1234 | wget https://github.com/nrk/predis/archive/v1.0.zipunzip v1.0cp -Rf predis-1.0 /u01/html/predis注:/u01/html为系统目录 |
2、连接redis集群
| //连接本地的 Redis 服务require 'predis/autoload.php';$parameters = ['tcp://192.168.1.231:7003', 'tcp://192.168.1.231:7003', 'tcp://192.168.1.231:7005'];$options = ['cluster' => 'redis'];$redis = new PredisClient($parameters, $options);$x=rand(10,100); |
注:Predis只是几个PHP文件,不需要安装到PHP扩展中,只需要把文件拷到php能调用的目录就行