系统环境

OS:CentOS6.5_x86_64

 

相关依赖包安装

[root@huis ~]# yum -y install gcc tcl
[root@huis ~]# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/abustany:/epel-rebuilds/CentOS_CentOS-6/x86_64/jemalloc-3.4.0-1.1.x86_64.rpm
[root@huis ~]# wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/abustany:/epel-rebuilds/CentOS_CentOS-6/x86_64/jemalloc-devel-3.4.0-1.1.x86_64.rpm
[root@huis ~]# rpm -ivh jemalloc-3.4.0-1.1.x86_64.rpm jemalloc-devel-3.4.0-1.1.x86_64.rpm

 

Redis安装

[root@huis ~]# wget http://download.redis.io/releases/redis-3.0.2.tar.gz
[root@huis ~]# tar -zxvf redis-3.0.2.tar.gz
[root@huis ~]# cd redis-3.0.2
[root@huis redis-3.0.2 ~]# make && make install PREFIX=/usr/local/redis

 

复制修改redis.conf配置文件

[root@huis redis-3.0.2 ~]# mkdir /etc/redis
[root@huis redis-3.0.2 ~]# cp redis.conf  /etc/redis
[root@huis redis-3.0.2 ~]# vi /etc/redis/redis.conf
#修改如下行:
port 6379				#redis端口
daemonize yes				#开启以守护进程的方式运行
logfile "/var/log/redis.log"		#redis日志文件
dir /var/lib/redis			#redis的数据库镜像备份的文件放置路径
requirepass redis			#redis连接密码
appendonly yes				#是否开启更新操作后日志记录,因为可能断电时导致一段时间内的数据丢失,所以建议开启
appendfilename "appendonly.aof"		#操作日志文件名
[root@huis redis-3.0.2 ~] # mkdir /var/lib/redis

 

Redis的启动

[root@huis redis-3.0.2 ~]# echo 'export PATH=$PATH:/usr/local/redis/bin' > /etc/profile.d/redis.sh
[root@huis redis-3.0.2 ~]# source /etc/profile.d/redis.sh
[root@huis redis-3.0.2 ~]# redis-server /etc/redis/redis.conf

 

Redis的关闭

[root@huis redis-3.0.2 ~]# redis-cli shutdown

 

检查Redis服务的启动状况

[root@huis redis-3.0.2]# ps aux | grep -v grep | grep redis-server
root     10479  0.1  0.2  35552  1704 ?        Ssl  09:08   0:00 redis-server *:6379
[root@huis redis-3.0.2]# netstat -tlnp | grep :6379
tcp    0    0 0.0.0.0:6379        0.0.0.0:*           LISTEN      10479/redis-server  
tcp    0    0 :::6379             :::*                LISTEN      10479/redis-server

#启动之后使用命令查看redis的启动情况,如上面显示则说明启动成功

 

Redis的验证

[root@huis redis-3.0.2]# redis-cli
127.0.0.1:6379> auth redis
OK
127.0.0.1:6379> set name huis
OK
127.0.0.1:6379> get name
"huis"
127.0.0.1:6379> quit

#至此Redis就部署成功了

#另沉醉寒风附上Redis SysV开机自启动脚本,以备各位看官的不时之需