Linux下redis的安装及用法
1、下载源代码包redis-2.8.21.tar.gz,并将其上传到指定文件夹/urs/src,然后对其进行解压:
[root@Slave1pc src]# tar -xvf redis-2.8.21.tar.gz
进入解压后的文件夹,并运行以下命令,指定安装文件夹为/urs/local/redis:
[root@Slave1pc src]# cd redis-2.8.21
[root@Slave1pc redis-2.8.21]# make PREFIX=/usr/local/redis install
安装redis成功后,能够在/usr/local/redis看到一个bin的文件夹,里面包含了下面文件:
[root@Slave1pc ~]# cd /usr/local/redis/bin/
[root@Slave1pc bin]# ls
redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server
2、将一个程序加入到服务:
复制脚本redis_init_script到/etc/rc.d/init.d文件夹,并将其改名为redis(说明:/etc/rc.d/init.d/文件夹下的脚本在系统启动的时候某些指定脚本将被运行)
[root@Slave1pc ~]# cd /usr/src/redis-2.8.21/utils/
[root@Slave1pc utils]# cp redis_init_script /etc/rc.d/init.d/redis
将redis加入到注冊服务:
[root@Slave1pc ~]# chkconfig --add redis
//报错:service redis does not support chkconfig
遇到这样情况须要改动脚本redis:
[root@Slave1pc ~]# vim /etc/init.d/redis
#chkconfig: 2345 80 90 //新加入的内容
EXEC=/usr/local/redis/bin/redis-server //改动后的内容
CLIEXEC=/usr/local/redis/bin/redis-cli //改动后的内容
$EXEC $CONF & //redis开启的命令,以后台执行的方式执行,那个“&”,即是将服务
//转到后面执行的意思。否则启动服务时,redis服务将占领在前台,占用了主用户界面。导致其他//的命令执行不了
改动后运行例如以下命令:
[root@Slave1pc ~]# chkconfig --add redis
[root@Slave1pc ~]# chkconfig --list redis
redis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
重新启动redis,出现例如以下错误:
[root@Slave1pc ~]# service redis start
Starting Redis server...
[6384] 14 Jul 21:43:19.992 # Fatal error, can't open config file '/etc/redis/6379.conf'
解决方法:
将redis配置文件复制到/etc/redis/${REDISPORT}.conf
[root@Slave1pc ~]# mkdir /etc/redis
[root@Slave1pc ~]# cp /usr/src/redis-2.8.21/redis.conf /etc/redis/6379.conf
这样。redis服务脚本指定的conf就存在了;在默认情况下。redis未启用认证,能够通过开启6379.conf的requirepass 指定一个验证password。
改动/etc/redis/6379.conf,设置redis进程为后台守护进程,并指定一个password:
[root@Slave1pc ~]# vim /etc/redis/6379.conf
daemonize yes //daemonize:是否以后台daemon方式执行
requirepass 20082009 //设置password为20082009
设置完毕后,能够加入注冊服务:
[root@Slave1pc ~]# chkconfig --add redis
[root@Slave1pc ~]# service redis start
Starting Redis server...
查看是否启动成功:
[root@Slave1pc ~]# ps -ef | grep redis
root 2099 1 0 22:17 ?
00:00:00 /usr/local/redis/bin/redis-server *:6379
root 2475 2270 0 22:19 pts/1 00:00:00 grep redis
3、调用redis-cli的命令进行简单操作(注意是否启动password验证):
[root@Slave1pc ~]# redis-cli
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 20082009 //须要输入password
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set name lebron james
(error) ERR syntax error
127.0.0.1:6379> set name "lebron james" //有空格的字符串须要加“”
OK
127.0.0.1:6379> get name
"lebron james"
127.0.0.1:6379> set name lebronjames
OK
127.0.0.1:6379> get name
"lebronjames"
127.0.0.1:6379>
Linux下redis的安装及用法的更多相关文章
- linux下redis的安装及配置启动
linux下redis的安装及配置启动 标签: redisnosql 2014-10-24 14:04 19732人阅读 评论(0) 收藏 举报 分类: 数据与性能(41) wget http:/ ...
- 莫小安 Linux下Redis的安装与配置
转载自--Linux下Redis的安装与配置 redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了 memcached的不足,它 ...
- Linux下Redis的安装和部署
一.Redis介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多 ...
- Linux下redis的安装
第一部分:安装redis 希望将redis安装到此目录 /usr/local/redis 希望将安装包下载到此目录 /usr/local/src 那么安装过程指令如下: $ mkdir /usr/lo ...
- linux下redis的安装与部署及基础命令
<1>下载安装文件:redis-3.2.5.tar.gz 放在opt目录下 <2> tar -zxvf redis-3.2.5.tar.gz,备份redis.conf到自己的目 ...
- [Linux]Linux下redis的安装及配置.
在上一篇[Linux] linux下安装配置 zookeeper/redis/solr/tomcat/IK分词器 详细实例. 我们已经将redis所需tar包拷贝到了linux下的root 根目录下, ...
- Linux下Redis的安装配置
环境: centos7 PHP7 1.切到准备安装的目录 cd /usr/local 2.下载Redis wget http://download.redis.io/redis-stable.tar ...
- Redis学习笔记之Linux下Redis的安装和部署
0x00 Redis介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相 ...
- linux下redis的安装与部署
一.Redis介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多 ...
随机推荐
- [Redux] Extracting Container Components (FilterLink)
Learn how to avoid the boilerplate of passing the props down the intermediate components by introduc ...
- jQuery中 $ 符号的冲突问题
jQuery中 $ 符号的冲突问题是常见问题之一. 在jQuery中,$是jQuery的别名,为了书写方便,我们更习惯用$('#id')这一类的方式来书写代码.当同一页面引用了jQuery多个版本 ...
- jquery之onblur事件
onblur事件与html结合 function discountCheck(){ //var checkVal=$('input:text[name="Fee1"]').val( ...
- vsftp虚拟用户登录配置详解
一.安装:1.安装Vsftpd服务:# yum install vsftpd 2.安装DB4部件包:这里要特别安装一个db4的包,用来支持文件数据库.# yum install db4-utils 二 ...
- F# 越用越喜欢
F# 越用越喜欢 最近由于需要,把遗忘了几年的F#又捡了起来.说捡了起来,倒不如说是从头学习,原来学的早已经忘了!所谓学过,只不过看过一本<F# 语言程序设计> (郑宇军 凌海风 编著 - ...
- EF数据建模(一)
大中型软件开发过程中常会使用ORM技术,ORM全称是“对象-关系映射Object-Relation-Mappping”.是将数据库中的数据对象的形式表现出来,并将通过面向对象的方式将这些对象组织起来, ...
- oracle包概述(一)【weber出品】
一.PL/SQL包概述 1. 什么是PL/SQL包: 相关组件的组合:PL/SQL类型.变量,数据结构,和表达式.子程序: 过程和函数 2. 包的组成部分: 由两部分组成: 包头 包体 3. 包的优点 ...
- struts 2 --SEVERE: Could not find action or result
SEVERE: Could not find action or result There is no Action mapped for namespace / and action name . ...
- iOS_SN_基于AFNetworking3.0网络封装
转发文章,原地址:http://www.henishuo.com/base-on-afnetworking3-0-wrapper/?utm_source=tuicool&utm_medium= ...
- iscroll源码初涉
最近尝试做web app时候,用上了神器iScroll,鉴于功力尚浅,并没有完全用好神器,所以今天特意来认真学习! 翻开官网,目前的版本是5,但是相关的文章并不多,具体的文件版本是: iscroll. ...