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

[经验分享] NoSQL之Redis - CentOS 6.5安装测试

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-10-30 09:47:53 | 显示全部楼层 |阅读模式
1.下载redis

可以在线安装或者下载 redis

①在线安装前需要检测是否存在rpm包不存在的话查看yum在线是否存在rpm包不存在的话就只能手动下载或者用别的方式下载
1
2
   
[iyunv@localhost ~]# rpm -qa|grep redis
[iyunv@localhost ~]# yum list|grep redis

说明不存在。

②去官网下载或者在线下载

wget http://redis.googlecode.com/files/redis-2.2.13.tar.gz

官网下载好的 redis 已经存在博客中了点击下载 redis。


2.安装

由于是tar.gz格式的所以需要解压安装

下载好之后查找下载文件所在路径

1
2
3
   
[iyunv@localhost ~]# whereis redis
redis: /etc/redis
[iyunv@localhost ~]#

解压编译redis的软件包需要有gcc环境

总之缺少什么安装什么。
1
2
3
4
5
6
7
8
9
10
11
12
13
   
tar -zxvf reids-2.8.13.tar.gz
cd redis-2.8.13
make
sudo make install
#配置开始---
编译完成后在Src目录下有四个可执行文件redis-server、redis-benchmark、redis-cli和redis.conf。然后拷贝到一个目录下。
mkdir /usr/redis
cp redis-server  /usr/redis
cp redis-benchmark /usr/redis
cp redis-cli  /usr/redis
cp redis.conf  /usr/redis
cd /usr/redis
#配置结束--

或者可以这样配置

mkdir /etc/redis
cp redis.conf /etc/redis/redis.conf
mkdir  /var/lib/redis

可从此处下载修改好的 redis.conf

启动redis
redis-server /etc/redis/redis.conf
#即可在后台启动redis服务确认运行了之后可以用redis-benchmark命令测试看看还可以通过redis-cli命令实际操作一下比如
#install的时候redis的命令会被拷贝到/usr/local/bin下面


3.测试

客户端测试一下是否启动成功

[iyunv@localhost src]# ps -aux|grep redis
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root     23266  0.0  0.7 137356  7768 ?        Sl   00:23   0:04 redis-server *:6379
root     23982  0.0  0.5  19404  5100 pts/0    S+   01:09   0:00 redis-cli
root     24398  0.0  0.0 103244   876 pts/2    S+   01:44   0:00 grep redis
[iyunv@localhost src]# redis-cli
127.0.0.1:6379> set w wang
OK
127.0.0.1:6379> get w
"wang"
127.0.0.1:6379>

4.关闭服务

redis-cli shutdown
如果端口变化可以指定端口:
redis-cli -p 6379 shutdown

127.0.0.1:6379> i+j
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> set w 3
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>

5.启动服务

[iyunv@localhost src]# redis-server
[24502] 28 Oct 01:54:35.784 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[24502] 28 Oct 01:54:35.784 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.13 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
(    '      ,       .-`  | `,    )     Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 24502
  `-._    `-._  `-./  _.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                 
|    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
|`-._`-._    `-.__.-'    _.-'_.-'|                                 
|    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                          
              `-.__.-'                                               
[24502] 28 Oct 01:54:35.786 # Server started, Redis version 2.8.13
[24502] 28 Oct 01:54:35.786 # 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.
[24502] 28 Oct 01:54:35.786 * DB loaded from disk: 0.000 seconds
[24502] 28 Oct 01:54:35.786 * The server is now ready to accept connections on port 6379

启动之后最好重新打开个窗口运行redsi-cli进入控制台

否则可能出现连接错误。和windows下cmd运行tomcat类似。

[iyunv@localhost redis]# redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
[iyunv@localhost redis]# redis-cli
127.0.0.1:6379> set name = wangxin
(error) ERR syntax error
127.0.0.1:6379> set name wangxin
OK
127.0.0.1:6379> set age 26
OK
127.0.0.1:6379> get name age
(error) ERR wrong number of arguments for 'get' command
127.0.0.1:6379> get name
"wangxin"
127.0.0.1:6379> get age
"26"
127.0.0.1:6379>





运维网声明 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-26668-1-1.html 上篇帖子: redis的优点和缺点 下篇帖子: redis 密码认证
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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