Redis 分布式主从配置实例
redis php客户端的配置~~~
gethttps://github.com/nicolasff/phpredis/downloads tar -zxvf owlient-phpredis-2.1.1-0-g5a07edc.tar.gz mv owlient-phpredis-5a07edc php-5.3.4/ext/phpredis/ cd php-5.3.4/ext/phpredis/ /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install vi /usr/local/php/lib/php.ini extension=redis.so
redis 主从的配置
tar -xvzf redis-2.4.13.tar.gz
cd redis-2.4.13
make
cd src && cp redis-server redis-cli redis-benchmark /bin
echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
cp redis.conf /etc/
/sbin/sysctl -p
主服务器设置
# vim /etc/redis.conf
daemonize yes
port 6379
/var/redis.pid
从服务器设置
# vim /etc/redis.conf
daemonize yes
port 6300
slaveof 192.168.1.100 6379
/var/redis.pid
redis-server /etc/redis.conf
启动脚本
# vim /etc/init.d/redis
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis.conf
# pidfile: /var/redis.pid
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
redis="/usr/local/redis/bin/redis-server"
prog=$(basename $redis)
REDIS_CONF_FILE="/usr/local/redis/etc/redis.conf"
lockfile="/var/lock/subsys/redis"
start()
{
[ -x $redis ] || exit 5
[ -f $REDIS_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
$redis $REDIS_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop()
{
echo -n $"Stopping $prog: "
/sbin/killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart()
{
stop
start
}
reload()
{
echo -n $"Reloading $prog: "
/sbin/killproc $redis -HUP
RETVAL=$?
echo
}
case "$1" in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
reload)
$1
;;
*)
echo $"Usage: $0 {start|stop|restart|reload}"
exit 2
esac
----------------------------------------------------------------------------------------------------
启动服务
# chmod 700 /etc/init.d/redis
# chkconfig --add redis
# service redis start 相关推荐
聚合室 2020-11-16
王道革 2020-11-25
wangdonghello 2020-11-03
chenhualong0 2020-11-16
koushr 2020-11-12
guoyanga 2020-11-10
fackyou00 2020-11-10
Orangesss 2020-11-03
dongCSDN 2020-10-31
Quietboy 2020-10-30
liuyulong 2020-10-29
fansili 2020-10-29
温攀峰 2020-10-23
jackbon 2020-10-19
kaixinfelix 2020-10-04