centos7安装redis教程(单机版)
官网下载redis安装包,本次使用的是redis-4.0.11.tar.gz
创建redis安装目录
mkdir -p /software/redis
解压
tar -zxvf redis-4.0.11.tar.gz
解压后的目录
[root@hadoop01 redis]# ll
total 1712
drwxr-xr-x 2 root root 4096 Apr 17 14:44 dbfile
drwxrwxr-x 6 root root 4096 Apr 17 14:55 redis-4.0.11
-rw-r--r-- 1 root root 1739656 Apr 17 14:28 redis-4.0.11.tar.gz
[root@hadoop01 redis]# pwd
/software/redis
[root@hadoop01 redis]#
创建dbfile目录,并且编译redis
[root@hadoop01 redis]# mkdir dbfile
[root@hadoop01 redis]# ll
total 1712
drwxr-xr-x 2 root root 4096 Apr 17 14:44 dbfile
drwxrwxr-x 6 root root 4096 Aug 4 2018 redis-4.0.11
-rw-r--r-- 1 root root 1739656 Apr 17 14:28 redis-4.0.11.tar.gz
[root@hadoop01 redis]# cd redis-4.0.11
[root@hadoop01 redis-4.0.11]# make && make install
编译完后,此时不能直接redis-cli连接客户端
[root@hadoop01 redis-4.0.11]# cd ..
[root@hadoop01 redis]# ll
total 1712
drwxr-xr-x 2 root root 4096 Apr 17 14:44 dbfile
drwxrwxr-x 6 root root 4096 Aug 4 2018 redis-4.0.11
-rw-r--r-- 1 root root 1739656 Apr 17 14:28 redis-4.0.11.tar.gz
[root@hadoop01 redis]# redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
[root@hadoop01 redis]# cd redis-4.0.11
[root@hadoop01 redis-4.0.11]# ll
total 320
-rw-rw-r-- 1 root root 164219 Aug 4 2018 00-RELEASENOTES
-rw-rw-r-- 1 root root 53 Aug 4 2018 BUGS
-rw-rw-r-- 1 root root 1815 Aug 4 2018 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 Aug 4 2018 COPYING
drwxrwxr-x 6 root root 4096 Apr 17 14:44 deps
-rw-rw-r-- 1 root root 11 Aug 4 2018 INSTALL
-rw-rw-r-- 1 root root 151 Aug 4 2018 Makefile
-rw-rw-r-- 1 root root 4223 Aug 4 2018 MANIFESTO
-rw-rw-r-- 1 root root 20543 Aug 4 2018 README.md
-rw-rw-r-- 1 root root 58766 Aug 4 2018 redis.conf
-rwxrwxr-x 1 root root 271 Aug 4 2018 runtest
-rwxrwxr-x 1 root root 280 Aug 4 2018 runtest-cluster
-rwxrwxr-x 1 root root 281 Aug 4 2018 runtest-sentinel
-rw-rw-r-- 1 root root 7921 Aug 4 2018 sentinel.conf
drwxrwxr-x 3 root root 4096 Apr 17 14:45 src
drwxrwxr-x 10 root root 4096 Aug 4 2018 tests
drwxrwxr-x 8 root root 4096 Aug 4 2018 utils
修改redis.conf
[root@hadoop01 redis-4.0.11]# vim redis.conf
修改的内容如下,其他视情况修改
#bind 127.0.0.1
bind 0.0.0.0
daemonize yes
logfile "/var/log/redis.log"
dir /software/redis/dbfile
复制redis.conf
[root@hadoop01 redis-4.0.11]# cp redis.conf redis.conf.bak
[root@hadoop01 redis-4.0.11]# ll /usr/local/redis
ls: cannot access /usr/local/redis: No such file or directory
[root@hadoop01 redis-4.0.11]# chkconfig redis_6379 on
error reading information on service redis_6379: No such file or directory
创建etc bin目录,并将redis.conf移到/usr/local/redis/etc
[root@hadoop01 redis-4.0.11]# mkdir -p /usr/local/redis/bin
[root@hadoop01 redis-4.0.11]# mkdir -p /usr/local/redis/etc
[root@hadoop01 redis-4.0.11]# mv redis.conf /usr/local/redis/etc/
移动src目录文件
[root@hadoop01 redis-4.0.11]# cd src/
[root@hadoop01 src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server /usr/local/redis/bin/
启动redis
[root@hadoop01 src]# cd /usr/local/redis/bin
[root@hadoop01 bin]# redis-server /usr/local/redis/etc/redis.conf
[root@hadoop01 bin]# redis-cli
127.0.0.1:6379> exit