设为首页 收藏本站
查看: 1259|回复: 0

[经验分享] No SQL 之Redis安装

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-9-26 08:58:11 | 显示全部楼层 |阅读模式

   摘录百科:

     Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。从2010年3月15日起,Redis的开发工作由VMware主持。从2013年5月开始,Redis的开发由Pivotal赞助。

1、安装"Development tools"
1
[iyunv@web1 src]# yum groupinstall "Development tools"



2、下载Redis
  http://download.redis.io/releases/ 选择自己需要的版本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[iyunv@web1 src]# wget http://download.redis.io/releases/redis-3.0.4.tar.gz
--2016-09-25 10:40:04--  http://download.redis.io/releases/redis-3.0.4.tar.gz
Resolving download.redis.io... 109.74.203.151
Connecting to download.redis.io|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1364993 (1.3M) [application/x-gzip]
Saving to: `redis-3.0.4.tar.gz'

100%[=====================================================================================================================================================>] 1,364,993   31.0K/s   in 39s     

2016-09-25 10:40:46 (34.4 KB/s) - `redis-3.0.4.tar.gz' saved [1364993/1364993]

[iyunv@web1 src]# ll
total 1336
-rw-r--r--. 1 root root 1364993 Sep  8  2015 redis-3.0.4.tar.gz
[iyunv@web1 src]#



3、编译安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[iyunv@web1 src]# tar xf  redis-3.0.4.tar.gz
[iyunv@web1 src]# cd redis-3.0.4
[iyunv@web1 redis-3.0.4]# make
cd src && make all
make[1]: Entering directory `/usr/local/src/redis-3.0.4/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
...                                                    \\省略编译信息
    CC redis-check-aof.o
    LINK redis-check-aof

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/usr/local/src/redis-3.0.4/src'
[iyunv@web1 redis-3.0.4]# cd src/
[iyunv@web1 src]# make install

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
[iyunv@web1 src]#



4、简单配置并启动测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
[iyunv@web1 src]# mkdir /usr/local/redis3.0.4/etc/ -p
[iyunv@web1 src]# mkdir /usr/local/redis3.0.4/bin/ -p
[iyunv@web1 src]# find . -perm 755 -o -perm 775| xargs -i cp {} /usr/local/redis3.0.4/bin/
[iyunv@web1 src]# cd ..
[iyunv@web1 redis-3.0.4]# cp redis.conf /usr/local/redis3.0.4/etc/
[iyunv@web1 redis-3.0.4]# ls /usr/local/redis3.0.4/{etc,bin}
/usr/local/redis3.0.4/bin:
mkreleasehdr.sh  redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis-sentinel  redis-server  redis-trib.rb

/usr/local/redis3.0.4/etc:
redis.conf
[iyunv@web1 redis-3.0.4]# vim /usr/local/redis3.0.4/etc/redis.conf
...
################################ GENERAL  #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes        \\默认是no改为yes,这样启动就会在后台运行
#daemonize no
...
:wq            \\保存退出
[iyunv@web1 redis-3.0.4]# ln -sv /usr/local/redis3.0.4/bin/* /usr/local/bin/        \\软连接到PATH去,这样就不用输入绝对路径,可以直接使用命令。
[iyunv@web1 redis-3.0.4]# redis-                                                     \\瞧见没
redis-benchmark   redis-check-aof   redis-check-dump  redis-cli         redis-sentinel    redis-server      redis-trib.rb     
[iyunv@web1 redis-3.0.4]# redis-server /usr/local/redis3.0.4/etc/redis.conf             \\启动Redis,必须制定配置文件,不然出现如下情况
[iyunv@web1 redis-3.0.4]# redis-server
12912:C 25 Sep 10:58:42.547 # Warning: 注意这里-->no config file specified, using the default config.<--注意这里  In order to specify a config file use redis-server /path/to/redis.conf
12912:M 25 Sep 10:58:42.548 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
(    '      ,       .-`  | `,    )     Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 12912
  `-._    `-._  `-./  _.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                 
|    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                 
|    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                          
              `-.__.-'                                               

12912:M 25 Sep 10:58:42.550 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
12912:M 25 Sep 10:58:42.550 # Server started, Redis version 3.0.4
12912:M 25 Sep 10:58:42.550 # 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.
12912:M 25 Sep 10:58:42.550 # 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.
12912:M 25 Sep 10:58:42.550 * The server is now ready to accept connections on port 6379<--这里会无休止提示,并且还会占用我们的session,session关闭则服务停止,这也是为什么配置文件我只强调“daemonize yes        \\默认是no改为yes,这样启动就会在后台运行”
\\下面是正常启动访问关闭
[iyunv@web1 redis-3.0.4]# netstat -tunlp| grep 6379
tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      12827/redis-server  
tcp        0      0 :::6379                     :::*                        LISTEN      12827/redis-server  
[iyunv@web1 redis-3.0.4]# redis-cli
127.0.0.1:6379> exit
[iyunv@web1 redis-3.0.4]# redis-cli shutdown
[iyunv@web1 redis-3.0.4]# netstat -tunlp| grep 6379
[iyunv@web1 redis-3.0.4]#




至此Redis的简单配置就OK拉,具体需求具体配置,配置文件参数度娘即可获得。


运维网声明 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-277498-1-1.html 上篇帖子: linux下redis自动安装脚本 下篇帖子: Redis String存储的操作方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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