redis安装及主从读写分离

解压redis-5.0.4.tar.gz并且进入redis-5.0.4  安装 gcc cc     yum install -y gcc-c++ 编译make MALLOC=libc 安装make PREFIX=/usr/local/redis install 创建数据文件,配置文件,日志文件,pid文件, Mkdir –p /usr/local/redis/{conf,log,data,var} 配置文件模板 Cp  /usr/local/src/ redis-5.0.4/redis.conf /usr/local/redis/conf/ 修改参数 vim/usr/local/redis/conf/redis.conf daemonize yes pidfile /usr/local/redis/var/redis.pid port 6379 logfile “/usr/local/redis/log/redis.log” dbfilename dump.rdb dir /usr/local/redis/data/   启动redis ./bin/redis-server- –port 6379   进入目录使用配置文件启动redis服务 cd /usr/local/redis ./bin/redis-server ./config/redis.conf     使用redis ./bin/redis-cli -h 127.0.0.1 -p 6379     搭建从服务器,cp /usr/local/redis/conf/redis.conf /usr/local/redis/conf/redis02.conf 修改/usr/local/redis/conf/redis02.conf配置文件 port 6379 修改为: port 6380 pidfile /usr/local/redis/redis_6379.pid 修改为: pidfile /usr/local/redis/redis_6380.pid 增加一行: slaveof 127.0.0.1 6379   启动实例 /usr/local/redis/bin/redis-server /usr/local/redis/conf/6380.conf   链接6380实例 cd /usr/local/redis/bin/ ./redis-cli -h 127.0.0.1 -p 6380        

你可能感兴趣的:(redis安装及主从读写分离)