测试redis需要tcl的支持,如果没安装,需要安装,除非跳过测试。
#yum install tcl -y
编译安装redis
#cd /usr/local/src
#wget http://download.redis.io/releases/redis-2.8.17.tar.gz
#tar zxfv redis-2.8.17.tar.gz
# cd redis-2.8.17
#make MALLOC=jemalloc
# make test
#当出现All tests passedwithout errors!时,表示测试没问题。有个测试是多个链接并发的,需要打开多个socket,如果系统配置的文件打开数太小,会导致测试失败。
安装编译好的程序到指定目录
# make PREFIX=/usr/local/redis/2.8.17 install
1.1.1.1 将Redis配置成系统服务
在redis的源码目录下
# utils/install_server.sh
第一个选端口:默认6379,选默认的。
第二个选配置文件:输入配置文件将存放的位置,自动生成,没其它情况选默认。
第三个选日志文件:输入日志文件将存放的位置,没其它情况选默认。
第四个选存放数据的目录:输入数据的目录,建议指定专门的目录,这里指定/data/redis/6379。
第五个输入redis服务端的可执行文件,服务端的可执行文件在安装目录的bin下,输入:/usr/local/redis/2.8.17/bin/redis-server
查看redis服务状态
# service redis_6379 status
关闭redis
# service redis_6379 stop
启动redis
# service redis_6379 start
重启redis
# service redis_6379 restart
主从同步设置:
只需要在slave 上修改 redis.conf
################################# REPLICATION #################################
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
#
slaveof 120.25.148.194 6379
# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
#
masterauth youpasswd