Redis快速入门:安装、配置和操作
怎么安装 Redis数据库呢?下面将介绍Linux版本的安装方法:
步骤一: 下载Redis
下载安装包:wget http://redis.googlecode.com/files/redis-2.2.12.tar.gz
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> [root@localhost 4setup]# wget http://redis.googlecode.com/files/redis-2.2.12.tar.gz步骤二: 编译源程序
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> [root@localhost 4setup]# ll步骤三: 启动Redis服务
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> src/redis-serverRedis 服务端的默认连接端口是 6379。
步骤四: 将Redis作为 Linux 服务随机启动
vi /etc/rc.local, 使用vi编辑器打开随机启动配置文件,并在其中加入下面一行代码。
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> /root/4setup/redis-2.2.12/src/redis-server?步骤五: 客户端连接验证
新打开一个Session输入:src/redis-cli,如果出现下面提示,那么您就可以开始Redis之旅了。
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> [root@localhost redis-2.2.12]# src/redis-cli步骤六: 查看Redis日志
查看服务器端session,即可对Redis的运行状况进行查看或分析了。
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> [6246] 05 Aug 19:24:33-0 clients connected (0 slaves), 539544 bytes in use以上的几个步骤就OK了!!这样一个简单的Redis数据库就可以畅通无阻地运行起来了。
步骤七: 停止Redis实例
最简单的方法是在启动实例的session中,直接使用Control-C来将实例停止。
我们还可以用客户端来停止服务,如可以用shutdown来停止Redis实例, 具体如下:
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> [root@localhost redis-2.2.12]# src/redis-cli shutdown