http://download.redis.io/releases/redis-4.0.2.tar.gz
2.上传到centos主机,比如目录 /usr/local (下文的操作都基于此目录)
3. 解压
cd/usr/local
tar -zxvf redis-4.0.2.tar.gz
4. 编译安装
cd redis-4.0.2
make install
5. 目录结构如下
[root@localhost redis-4.0.2]# ls -ll
total 288
-rw-rw-r-- 1 root root 131381 Sep 21 22:12 00-RELEASENOTES
-rw-rw-r-- 1 root root 53 Sep 21 22:12 BUGS
-rw-rw-r-- 1 root root 1815 Sep 21 22:12 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 Sep 21 22:12 copYING
drwxrwxr-x 6 root root 4096 Sep 29 09:56 deps
-rw-rw-r-- 1 root root 11 Sep 21 22:12 INSTALL
-rw-rw-r-- 1 root root 151 Sep 21 22:12 Makefile
-rw-rw-r-- 1 root root 4223 Sep 21 22:12 MANIFESTO
-rw-rw-r-- 1 root root 20530 Sep 21 22:12 README.md
-rw-rw-r-- 1 root root 57764 Sep 21 22:12 redis.conf
-rwxrwxr-x 1 root root 271 Sep 21 22:12 runtest
-rwxrwxr-x 1 root root 280 Sep 21 22:12 runtest-cluster
-rwxrwxr-x 1 root root 281 Sep 21 22:12 runtest-sentinel
-rw-rw-r-- 1 root root 7606 Sep 21 22:12 sentinel.conf
drwxrwxr-x 3 root root 8192 Sep 29 10:20 src
drwxrwxr-x 10 root root 4096 Sep 21 22:12 tests
drwxrwxr-x 8 root root 4096 Sep 29 16:59 util
6.以非daemon模式启动
src/redis-server
7. 再打开一个终端,连接到centos服务器,验证redis服务是否正常。执行redis-cli命令,进入交互模式
[root@localhost redis-4.0.2]# redis-cli
127.0.0.1:6379> set a 1
OK
127.0.0.1:6379> get a
"1"
127.0.0.1:6379>
配置redis为系统的服务
8.停止上述第6步中启动的redis服务。直接:ctrl+c
9.在/etc下创建redis目录
mkdir /etc/redis
10. 复制redis.conf配置文件(6379为redis服务的端口)
cp /usr/local/redis-4.0.2/redis.conf /etc/redis/6379.conf
11. 修改配置文件6379,vi /etc/redis/6379.conf,将daemonize no修改为yes
12.复制redis_init_script配置文件,重命名为redisd
cp /usr/local/redis-4.0.2/utils/redis_init_script/etc/init.d/redisd
13.修改配置文件redisd,第二行加上chkconfig: 2345 90 10。2345是运行级别,90表示启动的优先级,10表示停止的优先级
#!/bin/sh
#chkconfig: 2345 90 10
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
14.配置开机自启动
15 启动与停止redis