mkdir /usr/local/redis/700{1…6} -p
cp redis.conf …/700{1…6}
vim redis.conf
port 700{1..6} ##指定端口 cluster-enabled yes ##集群开启 cluster-config-file nodes.conf ##节点配置文件生成 cluster-node-timeout 5000 ##节点超时 appendonly yes ##AOF的存储模式打开 daemonize yes ##挂入后台
redis-server redis.conf ##开启服务
redis-cli --cluster create 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 --cluster-replicas 1
redis-cli --cluster check 127.0.0.1:7001 ##检查
redis-cli --cluster add-node 127.0.0.1:7009 127.0.0.1:7001 ##加入新的节点,默认为master
redis-cli --cluster add-node 127.0.0.1:7008 127.0.0.1:7001 --cluster-slave --cluster-master-id e35f0d5d327f78dedef337c57986d30fd533eea0 ##加入新节点,指定为slave
hash槽迁移
redis-cli --cluster reshard 127.0.0.1:新master节点的端口
vim .bash_profile:
sourece .bash_profile ##还原环境变量
搭建数据库;
yum install mariadb-server -y ##下载数据库服务
vim /etc/my.cnf ##恢复配置文件到默认状态
systemctl start mariadb-server ##开启服务
获取本地测试资源,倒入数据库:
lftp 172.25.254.37 cd pub/docs/redis get test.sql exit
mysql < test.sql
获取本地资源;
lftp 172.25.254.250 cd pub/docs/redis get phpredis-5.3.4.tar
添加php的redis模块:
1)
tar zxf phpredis-5.3.4.tgz
cd redis-5.3.4/
phpize
./configure --enable-redis
make
make install
vim /usr/local/php/etc/php.ini
systemctl reload php-fpm ##重启php服务
2)
本地资源
lftp 172.25.254.250
cd pub/docs/redis get phpredis-master.zip
yum install unzip
unzip phpredis-master.zip
cd phpredis-master
phpize
./configure --enable-redis
lftp 172.25.254.250
cd pub/docs/redis get redis-5.3.4.tgz
tar zxf redis-5.3.4.tgz
cd redis-5.3.4
phpize
./configure
make
make install
cd /usr/local/php/etc
vim php.ini
php -m | grep redis
php -m | grep mysql
systemctl stop php.fpm
lftp 172.25.254.250
cd pub/docs/redis mirror rhel7
yum install *.rpm -y
vim /etc/php-fpm.d/www.conf:
systemctl start php-fpm
redis服务为master