Redis 3.0.1 安装和配置

一、下载,解压和编译Redis

 

1
2
3
4
5
# cd /tmp   
# wget http://download.redis.io/releases/redis-3.0.1.tar.gz    
# tar xzf redis-3.0.1.tar.gz    
# cd redis-3.0.1    
# make

 

二、下载、安装tclsh

 

测试编译:

1
# make test


得到如下错误信息:  

1
2
3
4
5
6
cd src && make test    
make[1]: Entering directory `/tmp/redis-3.0.1/src'    
You need tcl 8.5 or newer in order to run the Redis test    
make[1]: *** [test] Error 1    
make[1]: Leaving directory `/tmp/redis-3.0.1/src'    
make: *** [test] Error 2


Redis在make test有使用到tclsh对Redis进行测试,所有需要将tclsh安装好。

tclsh下载可以直接从官网http://www.tcl.tk/software/tcltk/download.html下载其最新版

1
2
3
4
5
6
# cd /tmp    
# wget http://prdownloads.sourceforge.net/tcl/tcl8.6.4-src.tar.gz    
# tar xzvf tcl8.6.4-src.tar.gz    
# cd tcl8.6.4/unix     #windows进入tcl8.6.4/win    
# ./configure --prefix=/usr/local/tcl8.6.4 --enable-64bit  #enable-64bit对64系统生效    
# make && make install


安装完成之后需要将tclsh添加到PATH中,并使其生效   
    

1
# vim /etc/profile

   
PATH=/usr/local/tcl8.6.4/bin:$PATH    
export PATH    
   

1
# source /etc/profile

这样tclsh就已经安装完成了。

 

三、再次测试编译

1
2
# cd /tmp/redis-3.0.1    
# make test

将会收到信息:   
All tests passed without errors!

 

四、简单试用(生产环境略过)

 

在src目录下,编译后的二进制文件可用。运行Redis服务端:

1
# src/redis-server

你可以用内置的客户端与Redis交互:

1
# src/redis-cli

  
redis> set foo bar    
OK    
redis> get foo    
"bar"

 

五、安装redis到指定目录

 

也可以将redis安装到指定的/usr/local/redis目录下:

1
# make PREFIX=/usr/local/redis install

 

六、配置redis

 

为redis配置PATH:

1
#vi /etc/profile #添加下行内容


PATH=$PATH:/usr/local/redis/bin

export PATH

  

1
#source /etc/profile
1
#cp redis.conf /etc/
1
#vi /etc/sysctl.conf #添加vm.overcommit_memory=1,否则出现如下警告
1
2
# 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.


#vi /etc/redis.conf  #对应行修改为下面内容    
daemonize yes    
logfile /var/log/redis.log

 

七、编写服务管理脚本

 

1
#vi /etc/init.d/redis
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh   
#chkconfig: 345 86 14    
#description: Startup and shutdown script for Redis    
   
PROGDIR=/usr/local/redis #安装路径    
PROGNAME=redis-server    
DAEMON=$PROGDIR/$PROGNAME    
CONFIG=/etc/redis.conf    
PIDFILE=/var/run/redis.pid    
DESC="redis daemon"    
SCRIPTNAME=/etc/rc.d/init.d/redis    
   
start()    
{    
         if test -x $DAEMON    
         then    
        echo -e "Starting $DESC: $PROGNAME"    
                   if $DAEMON $CONFIG    
                   then    
                            echo -e "OK"    
                   else    
                            echo -e "failed"    
                   fi    
         else    
                   echo -e "Couldn't find Redis Server ($DAEMON)"    
         fi    
}    
   
stop()    
{    
         if test -e $PIDFILE    
         then    
                   echo -e "Stopping $DESC: $PROGNAME"    
                   if kill `cat $PIDFILE`    
                   then    
                            echo -e "OK"    
                   else    
                            echo -e "failed"    
                   fi    
         else    
                   echo -e "No Redis Server ($DAEMON) running"    
         fi    
}    
   
restart()    
{    
    echo -e "Restarting $DESC: $PROGNAME"    
    stop    
         start    
}    
   
list()    
{    
         ps aux | grep $PROGNAME    
}    
   
case $1 in    
         start)    
                   start    
        ;;    
         stop)    
        stop    
        ;;    
         restart)    
        restart    
        ;;    
         list)    
        list    
        ;;    
   
         *)    
        echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&2    
        exit 1    
        ;;    
esac    
exit 0
1
#chmod +x /etc/init.d/redis

 

八、设置开机启动

 

1
2
3
#chkconfig --add redis   
#chkconfig --level 35 redis on    
#chkconfig --list redis


九、启动、关闭服务


前台以配置文件启动:

1
# redis-server /etc/redis.conf #默认情况下redis前端运行,并把日志输出到屏幕上


生产环境直接以服务启动:

1
2
# service redis start
# netstat -tnlp |grep 6379


以命令关闭服务:

1
# redis-cli shutdown


生产环境直接以服务关闭:

1
# service redis stop


十、测试


# redis-cli
127.0.0.1:6379> info
# Server
redis_version:3.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:6d627ecdac18555f
redis_mode:standalone
os:Linux 2.6.32-358.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:6173
run_id:aedc790ab2d0eb75f3d5afe10c6af937d16955b0
tcp_port:6379
uptime_in_seconds:706
uptime_in_days:0
hz:10
lru_clock:6829896
config_file:/etc/redis.conf

...

...


参见:http://redis.io/download
















本文转自UltraSQL51CTO博客,原文链接: http://blog.51cto.com/ultrasql/1656480,如需转载请自行联系原作者



本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/392901.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2021年南宁二中高考成绩查询,2021广西高考圆满结束,6月23日可查询成绩

6月8日下午,2021年高考统考圆满结束。今年广西参加高考统考考生人数40.05万余人,比2020年增加了2.2万人。我区预计6月23日可查询高考成绩,6月24日起可陆续填报志愿,我区的网上咨询会将于6月25日至27日举办。▲高考结束&#xff0c…

29 Python - 字符与编码

字符与编码 01 字符串本质 Python字符串相关概念 字符串 str 字节 bytes 字节数组 bytearray 电脑字符串存储机制 字符库:A、B每个字符有一个代码点如A是65 B为66,这种是方便人类读写的形式,但是最终需要存入计算机的CPU和内存&…

Linux 内存管理与系统架构设计

Linux 提供各种模式(比如,消息队列),但是最著名的是 POSIX 共享内存(shmem,shared memory)。 Linux provides a variety of schemes (such as message queues), but most notable is POSIX shar…

如何正确使用Node.js中的事件

by Usama Ashraf通过Usama Ashraf 如何正确使用Node.js中的事件 (How to use events in Node.js the right way) Before event-driven programming became popular, the standard way to communicate between different parts of an application was pretty straightforward: …

你的成功有章可循

读书笔记 作者 海军 海天装饰董事长 自我修炼是基础。通过自我学习,在预定目标的指引下,将获取的知识转化为个人能力,形成自我规律,不断循环,实现成功。 寻找和掌握规律,并熟练运用于实践,是成功…

98k用计算机图片,98K (HandClap)_谱友园地_中国曲谱网

《98K》文本歌词98K之歌-HandClap-抖音 制谱:孙世彦这首《HandClap》是Fitz&TheTantrums乐队演唱的一首歌曲,同时也是绝地求生中嚣张BGM,是一首吃鸡战歌!这首歌谱曲者和填词者都是三个人:JeremyRuzumna&#xff0c…

qt之旅-1纯手写Qt界面

通过手写qt代码来认识qt程序的构成,以及特性。设计一个查找对话框。以下是设计过程1 新建一个empty qt project2 配置pro文件HEADERS \Find.h QT widgetsSOURCES \Find.cpp \main.cpp3 编写对话框的类代码例如以下://Find.h #ifndef FIND_H #define F…

【随笔】写在2014年的第一天

想想好像就在不久前还和大家异常兴奋地讨论着世界末日的事,结果一晃也是一年前的事了。大四这一年,或者说整个2013年都是场摇摆不定的戏剧,去过的地方比前三年加起来还多的多,有时候也会恍惚地不知道自己现在在哪。简单记几笔&…

设计冲刺下载_如何运行成功的设计冲刺

设计冲刺下载by George Krasadakis通过乔治克拉萨达基斯(George Krasadakis) Design Sprints can generate remarkable output for your company — such as a backlog of impactful ideas, functional prototypes, learning and key insights from customers along with real…

leetcode 18. 四数之和(双指针)

给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a b c d 的值与 target 相等?找出所有满足条件且不重复的四元组。 注意: 答案中不可以包含重…

WPF:从WPF Diagram Designer Part 4学习分组、对齐、排序、序列化和常用功能

在前面三篇文章中我们介绍了如何给图形设计器增加移动、选择、改变大小及面板、缩略图、框线选择和工具箱和连接等功能,本篇是这个图形设计器系列的最后一篇,将和大家一起来学习一下如何给图形设计器增加分组、对齐、排序、序列化等功能。 WPF Diagram D…

win7如何看计算机用户名和密码怎么办,win7系统电脑查看共享文件夹时不显示用户名和密码输入窗口的解决方法...

win7系统使用久了,好多网友反馈说win7系统电脑查看共享文件夹时不显示用户名和密码输入窗口的问题,非常不方便。有什么办法可以永久解决win7系统电脑查看共享文件夹时不显示用户名和密码输入窗口的问题,面对win7系统电脑查看共享文件夹时不显…

ASP.NET Core跨域设置

项目中经常会遇到跨域问题,解决方法: 在appsettings.json 文件中添加json项 {"Logging": {"LogLevel": {"Default": "Warning"}},"AllowedHosts": "*","AppCores": "https…

微信客户端<->腾讯微信服务器<->开发者服务器

出自 http://blog.csdn.net/hanjingjava/article/details/41653113 首先,通过Token验证,将公众号接入开发者服务器,这样客户端发给公众号的信息会被转发给开发者服务器; 第二,组装微信特定消息格式,返回给用…

idea提高调试超时_如何提高您的调试技能

idea提高调试超时by Nick Karnik尼克卡尼克(Nick Karnik) 如何提高您的调试技能 (How to Improve Your Debugging Skills) All of us write code that breaks at some point. That is part of the development process. When you run into an error, you may feel that you do…

leetcode 834. 树中距离之和(dp)

给定一个无向、连通的树。树中有 N 个标记为 0...N-1 的节点以及 N-1 条边 。第 i 条边连接节点 edges[i][0] 和 edges[i][1] 。返回一个表示节点 i 与其他所有节点距离之和的列表 ans。示例 1:输入: N 6, edges [[0,1],[0,2],[2,3],[2,4],[2,5]] 输出: [8,12,6,10,10,10] 解…

CSS设计指南(读书笔记 - 背景)

本文转自william_xu 51CTO博客,原文链接:http://blog.51cto.com/williamx/1140006,如需转载请自行联系原作者

在计算机网络中 带宽是什么,在计算机网络中,“带宽”用____表示。

答案查看答案解析:【解析题】计算机的发展经历了4个时代,各个时代划分的原则是根据()。【解析题】计算机网络的最主要的功能是______。【解析题】冯.诺依曼提出的计算机工作原理为____。【解析题】计算机的通用性使其可以求解不同的算术和逻辑问题,这主要…

如何在iOS上运行React Native应用

by Soujanya PS通过Soujanya PS 如何在iOS上运行React Native应用 (How to run a React Native app on iOS) I recently started to develop a React-Native app on iOS. This was my first foray into native app development. I was surprised by the ease and level of abs…

导出excel 后 页面按钮失效(页面假死)

在 page_load 里加上如下代码:string beforeSubmitJS "\nvar exportRequested false; \n"; beforeSubmitJS "var beforeFormSubmitFunction theForm.onsubmit;\n"; beforeSubmitJS "theForm.onsubmit function(){ \n"; …