Home > Database > Mysql Tutorial > CentOS 5.9下安装配置redis

CentOS 5.9下安装配置redis

WBOY
Release: 2016-06-07 16:32:58
Original
1082 people have browsed it

紧接上文,那时候是大三暑假,迷茫着不知该学些什么东西,无意中看见51cto在推荐Nosql的书,有一本叫做《Nosql数据库入门》,感觉这东西好高深,就立即买了本回来研究,研究了半天也没弄明白这东西是干吗的,原来路真是一步一步走的,Mysql都搞不明白,Nosql

紧接上文,那时候是大三暑假,迷茫着不知该学些什么东西,无意中看见51cto在推荐Nosql的书,有一本叫做《Nosql数据库入门》,感觉这东西好高深,就立即买了本回来研究,研究了半天也没弄明白这东西是干吗的,原来路真是一步一步走的,Mysql都搞不明白,Nosql又怎么能理解呢?

一:安装redis

1.安装redis

<code class="python">wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
tar zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make PREFIX=/usr/local/redis install
</code>
Copy after login

二:配置redis

1 使用默认配置文件,稍作修改就可以了

<code class="python">a 习惯做法,配置文件放在源码安装的文件夹下,便于管理吧
mkdir /usr/local/redis/etc/
cp redis-2.6.14/redis.conf  /usr/local/redis/etc/
b 修改配置文件 /usr/local/redis/etc/redis.conf
(1)Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程
daemonize yes
(2)当客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能
timeout 300
(3)指定redis日志
logfile /var/log/redis.log
(4)指定本地数据库存放目录
dir  /data/redis/redis_db
c 启动redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
</code>
Copy after login

三:测试redis

1 演示一个简单的set key,get key操作...

请先安装php下redis客户端,具体安装参考(https://github.com/nicolasff/phpredis)

<code class="python"><?php $redis = new Redis();
try{
    $redis->connect('127.0.0.1',6379);
}
catch (Exception $e){
    die("Cannot connect to redis server:".$e->getMessage() );
}
$redis->set('name','budong');
echo $redis->get('name');
?>
输出budong,则说明安装成功.
</code>
Copy after login

2 redis可玩性太多了,运维必备查看redis运行信息,如下:

<code class="python">[root@Cache ~]# /usr/local/redis/bin/redis-cli 
redis 127.0.0.1:6379> INFO
部分结果如下:
redis_version:2.4.7
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
gcc_version:4.1.2
process_id:26615
uptime_in_seconds:2717407
uptime_in_days:31
lru_clock:117839
used_cpu_sys:102659.58
used_cpu_user:101565.17
used_cpu_sys_children:125215.15
used_cpu_user_children:807371.44
</code>
Copy after login

四:是时候结束了

自言自语:

本篇博客就是自己安装redis的一个脚本的简单回顾,最近各种忙,更多精彩内容,下次继续,先挖坑,后栽树...

参考资料:

redis 官网:http://redis.io/

Redis资料汇总专题: http://blog.nosqlfan.com/html/3537.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template