Linux安装Redis-3.2.8流程和问题

3 篇文章 0 订阅

这次安装的是比较新版本的3.2.8 官网http://redis.io/ 下载的。

 

以下是参考的一篇文章,基本上文章描述的问题都遇到了,也参考解决了。在这里记录下,以备后用。主要问题是依赖包和cpu64位不支持问题。需要改动的redis配置。

网址:http://www.mayij.com/2017/03/09/linux%E5%AE%89%E8%A3%85redis-3-2-8/

安装依赖包

#yum install gcc gcc-c++ tcl -y


 

PS:遇到的问题

a、如果不安装tcl,后面make test的时候回报错,如下:

cd src && make test
make[1]: Entering directory `/root/redis-3.0.3/src’
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/root/redis-3.0.3/src’
make: *** [test] Error 2


 b、make的时候报错(版本3.0.3)

#make
cd src && make all
make[1]: Entering directory `/root/redis-3.0.3/src’
    CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error “Newer version of jemalloc required”
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/root/redis-3.0.3/src’
make: *** [all] Error 2
在README 有这个一段话。
Allocator 
——— 
Selecting a non-default memory allocator when building Redis is done by setting 
the `MALLOC` environment variable. Redis is compiled and linked against libc 
malloc by default, with the exception of jemalloc being the default on Linux 
systems. This default was picked because jemalloc has proven to have fewer 
fragmentation problems than libc malloc. 
To force compiling against libc malloc, use: 
 % make MALLOC=libc 
To compile against jemalloc on Mac OS X systems, use: 
 % make MALLOC=jemalloc
大概意思是说关于分配器allocator, 如果有MALLOC 这个 环境变量, 会有用这个环境变量的 去建立Redis。
而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明有更少的fragmentation problems 比libc。
但是如果你又没有jemalloc 而只有 libc 当然 make 出错,所以加这么一个参数。
解决办法:
#make MALLOC=libc   #添加一个参数
………………
Hint: It’s a good idea to run ‘make test’ ??
make[1]: Leaving directory `/root/redis-3.0.3/src’


开始编译安装redis-3.0.7

#tar xf redis-3.0.7.tar.gz
#cd redis-3.0.7
#make  
…………
Hint: It’s a good idea to run ‘make test’ ??
make[1]: Leaving directory `/root/redis-3.0.7/src’
#make test
………………
\o/ All tests passed without errors!
Cleanup: may take some time… OK
make[1]: Leaving directory `/root/redis-3.0.7/src’
到这里已经编译安装OK了!


我这里自定义路径,把redis安装到/usr/local/redis/目录下,操作如下:
#mkdir -pv /usr/local/redis/bin
#cd /root/redis-3.0.7/src
#cp  redis-benchmark /usr/local/redis/bin
#cp  redis-check-aof /usr/local/redis/bin
#cp  redis-check-dump /usr/local/redis/bin
#cp  redis-cli /usr/local/redis/bin
#cp  redis-server /usr/local/redis/bin
#cp redis-sentinel /usr/local/redis/bin/
#cp redis-trib.rb /usr/local/redis/bin/
设置环境变量:
#vim /etc/profile
PATH=$PATH:/usr/local/redis/bin
#source /etc/profile
创建conf目录:
#mkdir /usr/local/redis/conf
创建log目录
#mkdir -pv /usr/local/redis/log/
创建配置文件:
#cp /root/redis-3.0.7/redis.conf  /usr/local/redis/conf
#cp /root/redis-3.0.7/sentinel.conf  /usr/local/redis/conf


配置文件
可为redis服务启动指定配置文件,配置文件redis.conf在Redis根目录下。
 
vim /usr/redis/conf/redis.conf
Shell代码  编辑redis.conf
#修改daemonize为yes,即默认以后台程序方式运行(还记得前面手动使用&号强制后台运行吗)。  
daemonize no  
#可修改默认监听端口  
port 6379  
#修改生成默认日志文件位置  
logfile “/home/futeng/logs/redis.log”  
#配置持久化文件存放位置  
dir /home/futeng/data/redisData 

启动时指定配置文件
redis-server ./redis.conf  
#如果更改了端口,使用`redis-cli`客户端连接时,也需要指定端口,例如:  
redis-cli -p 6380  

启动
#加上`&`号使redis以后台程序方式运行  ,redis的bin目录下运行
./redis-server &  


#检测后台进程是否存在  
ps -ef |grep redis  
  
#检测6379端口是否在监听  
netstat -lntp | grep 6379  
  
#使用`redis-cli`客户端检测连接是否正常  操作redis key=》value
./redis-cli  
127.0.0.1:6379> keys *  
(empty list or set)  
127.0.0.1:6379> set key “hello world”  
OK  
127.0.0.1:6379> get key  
“hello world”  



#设置为开机自启动服务器  
chkconfig redisd on  
#打开服务  
service redisd start  
#关闭服务  
service redisd stop  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值