您的位置:首页 > 数据库 > Redis

NoSQL之Redis - CentOS 6.5安装测试

2014-10-29 10:34 495 查看
1.下载redis可以在线安装或者下载redis①在线安装前需要检测是否存在rpm包不存在的话查看yum在线是否存在rpm包不存在的话就只能手动下载或者用别的方式下载[root@localhost~]#rpm-qa|grepredis [root@localhost~]#yumlist|grepredis说明不存在。②去官网下载或者在线下载wgethttp://redis.googlecode.com/files/redis-2.2.13.tar.gz官网下载好的redis[b][/b]已经存在博客中了点击下载redis2.安装由于是tar.gz格式的所以需要解压安装下载好之后查找下载文件所在路径[root@localhost~]#whereisredis redis:/etc/redis [root@localhost~]#
解压编译redis的软件包需要有gcc环境总之缺少什么安装什么。tar-zxvfreids-2.8.13.tar.gzcdredis-2.8.13makesudomakeinstall#配置开始---编译完成后在Src目录下有四个可执行文件redis-server、redis-benchmark、redis-cli和redis.conf。然后拷贝到一个目录下。mkdir/usr/rediscpredis-server/usr/rediscpredis-benchmark/usr/rediscpredis-cli/usr/rediscpredis.conf/usr/rediscd/usr/redis#配置结束--或者可以这样配置
mkdir/etc/rediscpredis.conf/etc/redis/redis.confmkdir/var/lib/redis
可从此处下载修改好的redis.conf
启动redisredis-server/etc/redis/redis.conf#即可在后台启动redis服务确认运行了之后可以用redis-benchmark命令测试看看还可以通过redis-cli命令实际操作一下比如#install的时候redis的命令会被拷贝到/usr/local/bin下面
3.测试客户端测试一下是否启动成功
[root@localhostsrc]#ps-aux|grepredisWarning:badsyntax,perhapsabogus'-'?See/usr/share/doc/procps-3.2.8/FAQroot232660.00.71373567768?Sl00:230:04redis-server*:6379root239820.00.5194045100pts/0S+01:090:00redis-cliroot243980.00.0103244876pts/2S+01:440:00grepredis[root@localhostsrc]#redis-cli127.0.0.1:6379>setwwangOK127.0.0.1:6379>getw"wang"127.0.0.1:6379>
4.关闭服务
redis-clishutdown如果端口变化可以指定端口:redis-cli-p6379shutdown
127.0.0.1:6379>i+jCouldnotconnecttoRedisat127.0.0.1:6379:Connectionrefusednotconnected>setw3CouldnotconnecttoRedisat127.0.0.1:6379:Connectionrefusednotconnected>
5.启动服务
[root@localhostsrc]#redis-server[24502]28Oct01:54:35.784#Warning:noconfigfilespecified,usingthedefaultconfig.Inordertospecifyaconfigfileuseredis-server/path/to/redis.conf[24502]28Oct01:54:35.784*Increasedmaximumnumberofopenfilesto10032(itwasoriginallysetto1024)._.__.-``__''-.__.-```.`_.''-._Redis2.8.13(00000000/0)64bit.-``.-```.```\/_.,_''-._(',.-`|`,)Runninginstandalonemode|`-._`-...-`__...-.``-._|'`_.-'|Port:6379|`-._`._/_.-'|PID:24502`-._`-._`-./_.-'_.-'|`-._`-._`-.__.-'_.-'_.-'||`-._`-.__.-'_.-'|http://redis.io`-._`-._`-.__.-'_.-'_.-'|`-._`-._`-.__.-'_.-'_.-'||`-._`-.__.-'_.-'|`-._`-._`-.__.-'_.-'_.-'`-._`-.__.-'_.-'`-.__.-'`-.__.-'[24502]28Oct01:54:35.786#Serverstarted,Redisversion2.8.13[24502]28Oct01:54:35.786#WARNINGovercommit_memoryissetto0!Backgroundsavemayfailunderlowmemorycondition.Tofixthisissueadd'vm.overcommit_memory=1'to/etc/sysctl.confandthenrebootorrunthecommand'sysctlvm.overcommit_memory=1'forthistotakeeffect.[24502]28Oct01:54:35.786*DBloadedfromdisk:0.000seconds[24502]28Oct01:54:35.786*Theserverisnowreadytoacceptconnectionsonport6379
启动之后最好重新打开个窗口运行redsi-cli进入控制台否则可能出现连接错误。和windows下cmd运行tomcat类似。
[root@localhostredis]#redis-cliCouldnotconnecttoRedisat127.0.0.1:6379:Connectionrefusednotconnected>redis-cliCouldnotconnecttoRedisat127.0.0.1:6379:Connectionrefusednotconnected>[root@localhostredis]#redis-cli127.0.0.1:6379>setname=wangxin(error)ERRsyntaxerror127.0.0.1:6379>setnamewangxinOK127.0.0.1:6379>setage26OK127.0.0.1:6379>getnameage(error)ERRwrongnumberofargumentsfor'get'command127.0.0.1:6379>getname"wangxin"127.0.0.1:6379>getage"26"127.0.0.1:6379>

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux CentOS redis NoSQL