centos 默认没有安装wget,所以先安装wget
[root@localhost ~]# yum -y install wget
下载redis
[root@localhost ~]# wget http://download.redis.io/releases/redis-2.8.13.tar.gz
解压缩
[root@localhost ~]# tar zxvf redis-2.8.13.tar.gz
如果提示gcc找不到或者make找不到,则
yum -y install gcc automake autoconf libtool make
要先编译
[root@localhost redis-2.8.13]# make
到src编译安装,生成redis命令
[root@localhost redis-2.8.13]# cd src
[root@localhost src]# make install
[root@localhost local]# mkdir -p /usr/local/redis/bin
[root@localhost local]# mkdir -p /usr/local/redis/etc
把命令移动到bin
[root@localhost ~]# cd ~/redis-2.8.13/src/
[root@localhost src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server /usr/local/redis/bin/
把配置文件移动到etc
[root@localhost src]# cd ~/redis-2.8.13/
mv ./redis.conf /usr/local/redis/etc/
启动
[root@localhost bin]# ./redis-server /usr/local/redis/etc/redis.conf
此时启动是占用当前session的,所以先关小ctrl+c,然后编辑配置文件,修改daemonize属性
[root@localhost bin]# vi /usr/local/redis/etc/redis.conf
daemonize no改成daemonize yes=
保存后重新启动redis
[root@localhost bin]# ./redis-server /usr/local/redis/etc/redis.conf
[root@localhost bin]#
查看进程号
[root@localhost bin]# ps -ef|grep redis
root 4541 1 0 11:03 ? 00:00:00 ./redis-server *:6379
root 4545 1416 0 11:03 pts/0 00:00:00 grep redis
查看端口占用情况
[root@localhost bin]# netstat -tunpl|grep 6379
关闭redis-server的两种方法:
1, sudo pkill redis-server
2, redis-cli shutdown