redis单机安装

一、安装依赖,redis是C语言写的

[root@t2 ~]# yum install -y gcc

二、下载redis

mkdir /app && cd app
[root@t2 app]# wget http://download.redis.io/releases/redis-5.0.8.tar.gz

三、解压安装包

tar -zxvf redis-5.0.8.tar.gz 

四、编译安装redis

#进入解压目录
[root@t2 app]# cd redis-5.0.8
#编译
[root@t2 redis-5.0.8]# make
#出现这个说明成功编译
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/app/redis-5.0.8/src'

#make test 运行测试,确认redis的功能是否正常
#我centos7缺tcl包、执行以下命令安装、安装完重新编译
[root@t2 ~]# yum install tcl -y
[root@t2 ~]# make distclean
[root@t2 ~]# make
#出现下面的提示说明测试成功
o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory `/app/redis-5.0.8/src

#指定目录安装
[root@t2 src]# make install PREFIX=/app/redis/
#出现以下提示就成功了
Hint: It's a good idea to run 'make test' ;)

  INSTALL install
  INSTALL install
  INSTALL install
  INSTALL install
  INSTALL install

五、启动redis

#复制配置文件到刚刚的安装目录/app/redis
cd /app/redis && mkdir conf && cd conf
cp /app/redis-5.0.8/redis.conf ./
#创建pid文件
[root@t2 redis]# pwd
/app/redis
#创建以下目录存数据,pid,日志
[root@t2 redis]# mkdir {pid,logs,data}
[root@t2 pid]# cd pid/  
[root@t2 pid]# touch redis_6379.pid
#更改配置文件(我主要改了下面我贴出来的,其他都没改)
[root@t2 conf]# cat redis.conf |grep -v ^"#" | grep -v ^$
bind 0.0.0.0
port 6379
daemonize yes
pidfile /app/redis/pid/redis_6379.pid
logfile "/app/redis/logs/redis-6379.log"
dbfilename dump-6379.rdb
dir /app/redis/data
appendfilename "appendonly.aof"
###启动
[root@t2 bin]# pwd
/app/redis/bin
[root@t2 bin]# ./redis-server ../conf/redis.conf

六、测试

#连接测试、成功安装了redis     
[root@t2 bin]# ./redis-cli
127.0.0.1:6379> set tzh 11
OK
127.0.0.1:6379> get tzh
"11"
127.0.0.1:6379> exit
原文地址:https://www.cnblogs.com/hsyw/p/13254117.html