设为首页 收藏本站
查看: 1327|回复: 1

[经验分享] redis安装手册

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-2-13 14:57:23 | 显示全部楼层 |阅读模式
安装准备
环境:CentOS release 6.8
本次安装版本:redis-3.2.7

redis tar包下载
1
https://redis.io



1
2
3
[iyunv@ppt tools]# tar xf redis-3.2.7.tar.gz
[iyunv@ppt tools]# cd redis-3.2.7
[iyunv@ppt redis-3.2.7]# less README.md   --->通过查看readme.md,了解安装方式



1
2
3
4
5
6
7
8
9
10
11
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
Verbose build
-------------



1
[iyunv@ppt redis-3.2.7]# make MALLOC=jemalloc   --->通过jemalloc方式make



编译过程中,可能会发生报错,报错如下,不报下步可忽略
1
undefined reference to `clock_gettime'



由于clock_gettime在实时库librt(real time)里面,没有链接这个库导致报错。
需要在Makefile文件里面添加动态链接库librt ( -lrt ),从新编译。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[iyunv@ppt redis-3.2.7]# find / -name '*librt*'
/usr/lib64/librt.a
/usr/lib64/librt.so
/usr/lib/librt.a
/usr/lib/x86_64-redhat-linux5E/lib64/librt.a
/usr/lib/x86_64-redhat-linux5E/lib64/librt.so
/lib64/rtkaio/librtkaio-2.12.so
/lib64/rtkaio/librt.so.1
/lib64/librt-2.12.so
/lib64/librt.so.1
/lib/rtkaio/librtkaio-2.12.so
/lib/rtkaio/librt.so.1
/lib/rtkaio/i686/nosegneg/librtkaio-2.12.so
/lib/rtkaio/i686/nosegneg/librt.so.1
/lib/librt-2.12.so
/lib/librt.so.1
/lib/i686/nosegneg/librt-2.12.so
/lib/i686/nosegneg/librt.so.1



找到librt.so路径
1
2
[iyunv@ppt redis-3.2.7]# ll /usr/lib64/librt.so
lrwxrwxrwx. 1 root root 22 Nov  9 11:48 /usr/lib64/librt.so -> ../../lib64/librt.so.1



随后在redis解压的路径下找到Makefile,并进行添加编辑
1
2
/app/tools/redis-3.2.7/src
[iyunv@ppt src]# vim Makefile



:set nu找到108行,并在108行下添加一行内容

1
2
3
4
5
6
7
8
9
  FINAL_LIBS+= /usr/lib64/librt.so
以下是配置文件
ifeq ($(MALLOC),jemalloc)
         DEPENDENCY_TARGETS+= jemalloc
         FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
         FINAL_LIBS+= ../deps/jemalloc/lib/libjemalloc.a
         FINAL_LIBS+= /usr/lib64/librt.so   --->刚刚添加的部分
endif
保存完毕后从新编译安装



编译通过后,设置安装路径进行安装
1
make PREFIX=/app/redis-3.2.7 install  ---> 我把redis安装在/app/redis-3.2.7下




随后我设置了软连接,把版本号去掉了,方便启动
1
ln -s /app/redis-3.2.7/ app/redis



在软连接redis路径下,将redis配置文件redis.conf从解压下redis-3.2.7文件夹下拷贝过来
1
2
3
[iyunv@ppt redis]# mkdir conf  ---> 首先先在redis下创建conf文件夹
[iyunv@ppt conf]# cp /app/tools/redis-3.2.7/redis.conf /app/redis/conf/
[iyunv@ppt conf]# sysctl vm.overcommit_memory=1



设置环境变量
1
2
[iyunv@ppt conf]# echo "export PATH=/app/redis/bin:$PATH" >> /etc/profile
[iyunv@ppt conf]# source /etc/profile




以上步骤redis已经安装完毕,随后进行启动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[iyunv@ppt ~]# redis-server /app/redis/conf/redis.conf  &
[1] 5395
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
(    '      ,       .-`  | `,    )     Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'|              Port: 6379
|    `-._   `._    /     _.-'    |     PID: 5395
  `-._    `-._  `-./  _.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                 
|    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                 
|    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                          
              `-.__.-'                                               
5395:M 10 Feb 10:34:20.747 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
5395:M 10 Feb 10:34:20.747 # Server started, Redis version 3.2.7
5395:M 10 Feb 10:34:20.747 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
5395:M 10 Feb 10:34:20.747 * The server is now ready to accept connections on port 6379



此时表示redis已经安装成功。

检查一下进程和端口。
1
2
3
4
5
[iyunv@ppt ~]# ps -ef | grep redis
root      5395  1955  0 10:34 pts/0    00:00:00 redis-server 127.0.0.1:6379            
root      5527  1955  0 10:36 pts/0    00:00:00 grep redis
[iyunv@ppt ~]# netstat -anp | grep 6379
tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN      5395/redis-server 1




关闭redis服务
1
2
3
4
5
6
7
[iyunv@ppt ~]# redis-cli shutdown  
5395:M 10 Feb 10:37:17.969 # User requested shutdown...
5395:M 10 Feb 10:37:17.969 * Saving the final RDB snapshot before exiting.
5395:M 10 Feb 10:37:18.047 * DB saved on disk
5395:M 10 Feb 10:37:18.047 * Removing the pid file.
5395:M 10 Feb 10:37:18.047 # Redis is now ready to exit, bye bye...
[1]+  Done                    redis-server /app/redis/conf/redis.conf






运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-341686-1-1.html 上篇帖子: redis 集群架构 cluster 、sentinel 下篇帖子: 部署Redis的主从集群模式
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表