易网时代-编程资源站
Welcome
微信登录
首页
/
操作系统
/
Linux
/
Redis安装配置
一)下载源码,编译安装
# wget http://redis.googlecode.com/files/redis-2.2.8.tar.gz
# tar xf redis-2.2.8.tar.gz
# cd redis
# make
# 网上说不能make install,可我这就是可以,奇怪,省去了手动copy redis命令的步骤
# make install
make install后显示
cd src && make install
make[1]: Entering directory `/usr/local/src/redis-2.2.8/src"
cd ../deps/hiredis && make static ARCH=""
make[2]: Entering directory `/usr/local/src/redis-2.2.8/deps/hiredis"
make[2]: Nothing to be done for `static".
make[2]: Leaving directory `/usr/local/src/redis-2.2.8/deps/hiredis"
cd ../deps/linenoise && make ARCH=""
make[2]: Entering directory `/usr/local/src/redis-2.2.8/deps/linenoise"
make[2]: `linenoise_example" is up to date.
make[2]: Leaving directory `/usr/local/src/redis-2.2.8/deps/linenoise"
cd ../deps/hiredis && make static
make[2]: Entering directory `/usr/local/src/redis-2.2.8/deps/hiredis"
make[2]: Nothing to be done for `static".
make[2]: Leaving directory `/usr/local/src/redis-2.2.8/deps/hiredis"
cc -o redis-benchmark -std=c99 -pedantic -O2 -Wall -W -lm -pthread -g -rdynamic -ggdb ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o ../deps/hiredis/libhiredis.a
cc -o redis-cli -std=c99 -pedantic -O2 -Wall -W -lm -pthread -g -rdynamic -ggdb anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o
Hint: To run "make test" is a good idea ;)
mkdir -p /usr/local/bin
cp -p redis-server /usr/local/bin
cp -p redis-benchmark /usr/local/bin
cp -p redis-cli /usr/local/bin
cp -p redis-check-dump /usr/local/bin
cp -p redis-check-aof /usr/local/bin
make[1]: Leaving directory `/usr/local/src/redis-2.2.8/src"
二)修改配置修改配置之前,请将redis.conf copy一份到/etc/目录下
daemonize no
改成
daemonize yes
这两个参数
loglevel warning
logfile /var/log/redis.log
取消注释
syslog-enabled no #这个改成syslog-enabled yes
syslog-facility local0
数据文件目录
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the "dbfilename" configuration directive.
#
# Also the Append Only File will be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /var/db/redis
内存,连接数设置
maxmemory 256000000
maxclients 500
三)启动脚本
#!/bin/bash
#
# Init file for redis
#
# chkconfig: - 80 12
# description: redis daemon
#
# processname: redis
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
. /etc/init.d/functions
BIN="/usr/local/bin"
CONFIG="/etc/redis.conf"
PIDFILE="/var/run/redis.pid"
### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
RETVAL=0
prog="redis-server"
desc="Redis Server"
start() {
if [ -e $PIDFILE ];then
echo "$desc already running...."
exit 1
fi
echo -n $"Starting $desc: "
daemon $BIN/$prog $CONFIG
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $"Stop $desc: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
配置启动脚本
#chmod 755 /etc/init.d/redis
# chkconfig --add redis
# chkconfig redis on
四)启动在正式启动redis之前,先创建数据目录
# mkdir /var/db/redis
否则会出现下面的错误
[3030] 27 May 16:50:38 # Can"t chdir to "/var/db/redis": No such file or directory
同时配置内核参数
sysctl 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.
最后,启动
[root@web ~]# /etc/init.d/redis start
Starting Redis Server: [ OK ]
PS:不利用脚本启动,关闭redis的命令
启动
# redis-server /etc/redis.conf
关闭
# redis-cli shutdown
关闭某个端口上的redis
# redis-cli -p port shutdown
Linux 虚拟化Xen初体验FreeBSD下pureftpd结合MySQL详细配置相关资讯 Redis
Redis 非关系型数据库 ( Nosql ) (07月01日)
Java中使用Jedis操作Redis (04月08日)
在Ubuntu 14.04下安装Redis (01月31日)
关于 Redis的订阅发布 (04月15日)
MongoDB仲裁节点的理解及Memcached (02月13日)
关于redis中的Replication (01月29日)
本文评论 查看全部评论 (0)
表情: 姓名:
匿名
字数
版权所有©石家庄振强科技有限公司2024
冀ICP备08103738号-5
网站地图