cenos 6.5
redis-3.2.9.tar.gz 下载地址:http://pan.baidu.com/s/1jHHcGpK
************************************************** 简单方便 ******************************************
redis 其它获取方法 在/usr/local下执行:wget http://download.redis.io/releases/redis-3.2.9.tar.gz
如果执行时提示:-bash: wget: command not found 则执行yum -y install wget 安装wget后在执行上面的就不会报错啦~
*********************************************************************************************************
1.将tar包放到/usr/local下解压并重命名为redis
【解压命令:tar -zxvf redis-3.2.9.tar.gz;重命名命令:mv redis-3.2.9 redis】
2.进到 # cd redis/ 下
//编译(如果程序为初始状态先执行yum -y install gcc安装gcc)
# make
cd src && make all
make[1]: Entering directory `/usr/local/redis/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/usr/local/redis/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
…….此处省略 请忽略安全警告………….
CC rand.o
CC memtest.o
CC crc64.o
CC bitops.o
CC sentinel.o
CC notify.o
CC setproctitle.o
CC blocked.o
CC hyperloglog.o
CC latency.o
CC sparkline.o
CC redis-check-rdb.o
CC geo.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
CC redis-check-aof.o
LINK redis-check-aof# make install
//安装过程提示
cd src && make install
make[1]: Entering directory `/usr/local/redis/src'Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
查看redis/src文件(绿色的是要用的)
3.回到redis目录下创建bin和etc文件夹(创建 mkdir xxx)
创建bin文件夹存放命令,etc下放配置文件
(1)将redis/redis.con移到etc下
在redis下执行
# mv redis.conf etc/
(2)将redis/src下的7个绿色文件移动到/usr/local/redis/src下
# cd src/
# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server /usr/local/redis/bin/
查看/usr/local/redis/bin/
4.启动redis服务
进到/usr/local/redis/bin下执行 # ./redis-server /usr/local/redis/etc/redis.conf
启动成功
![]()
按Ctrl+c停止运行redis
# ps -ef | grep redis 查看redis是否后台h还有程序运行
5.设置后台运行
修改 /usr/local/redis/etc/redis.conf中daemonized改为yes
# vim /usr/local/redis/etc/redis.conf
在到bin/目录下执行./redis-server /usr/local/redis/etc/redis.conf
redis后台启动成功
6.登录(执行/usr/local/redis/bin/redis-cli)