一、Redis简介
Redis(Remote Dictionary Server:远程字典服务)是ANSI C 语言编写的一款开源,遵循BSD协议,支持网络、可基于内存亦可持久化的日志型、高级key-value存储系统,可以在所有POSIX系统上运行;因为其键(keys)可以是字符串(strings)、哈希(hashes)、列表(lists)、集合(sets)和有序集合(sortedsets),它通常被称作数据结构服务.
你可以对这些数据类型进行原子操作,比如push/pop,add/remove,取交集并集和差集等。
二、安装
1.下载
#wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
2.编译安装redis
#tar xvf redis-2.6.14.tar.gz
#sed -i.bak '/^PREFIX/s@/usr/local@/opt/redis@g'redis-2.6.14/src/Makefile #指定redis安装路径为/opt/redis
#make
#make install
3.为redis设置PATH
#vi /etc/profile #添加下行内容
PATH=$PATH:/opt/redis/bin
#source /etc/profile
4.配置
#cp redis.conf /etc/
#vi /etc/sysctl.conf #添加vm.overcommit_memory=1,否则出现如下警告
# WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
#redis-server /etc/redis.conf #默认情况下redis前端运行,并把日志输出到屏幕上
#vi /etc/redis.conf #对应行修改为下面内容
daemonize yes
logfile /var/log/redis.log
#netstat -tnlp |grep [6]379
5.编写服务管理脚本
#vi /etc/init.d/redis
#!/bin/bash
# redis - this script can start|stop the redis service.
# chkconfig: - 89 11
# description: redis is a presistent key-value store Database
# processname: redis-server
# config: /etc/redis.conf
# config: /opt/redis/bin/redis-server
# pidfile: /var/run/redis.pid
# source function library.
. /etc/rc.d/init.d/functions
# source networking configuration.
. /etc/sysconfig/network
# check that networking is up.
[ "$NETWORKING" = "no"] && exit 0
REDIS=/opt/redis/bin/redis-server
PROG=$(basename $REDIS)
CONFIG=/etc/redis.conf
PIDFILE=/var/run/redis.pid
LOCKFILE=/var/lock/subsys/redis
start() {
[ -x $REDIS ] || exit 3
[ -f $CONFIG ] || exit 4
echo -n $"Starting $PROG: "
daemon $REDIS $CONFIG
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
stop() {
echo -n $"Stopping $REDIS: "
killproc $PROG -QUIT
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $PROG: "
killproc $REDIS -HUP
RETVAL=$?
echo
}
status() {
status $PROG
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
reload)
reload
;;
*)
echo $"Useage: $PROG {start|stop|status|reload|restart}"
RETVAL=2
esac
exit $RETVAL
#chmod +x /etc/init.d/redis
6.设置开机启动
#chkconfig --add redis
#chkconfig --level 35 redis on
#chkconfig --list redis
7.web 管理工具phpRedisAdmin安装
//参考资料: https://github.com/ErikDubbelboer/phpRedisAdmin
# yum install git httpd -y //安装git,httpd
#cd /var/www/html
#git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
#cd phpRedisAdmin
#git submodule init
#git submodule update
#/etc/init.d/httpd start
http://yourip/phpRedisAdmin
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com