redis已经不是什么稀罕玩意,但绝对是一个神器。
1准备
1、能连外网的电脑一台(本文以centos7为例)
2开始安装
1、先监测是否之前安装过(ps -ef|grep redis)
因为我本地已安装过,因此有上面这条记录,否则是空
2、安装gcc-c++(redis编译环境需要用到)
sudo yum install gcc-c++
3、下载源码到本地(wget http://download.redis.io/releases/redis-你需要的版本.tar.gz---我下载的是3.2.8)
我是下载到了user/local下
4、解压(tar -zxvf redis-3.2.8.tar.gz)
5、编译
进入redis-3.2.8(cd redis-3.2.8)
执行make && make install
此时在src目录下会多出几个文件(下图绿色)
3配置
1、在local下创建redis/etc、redis/bin目录,分别存放配置文件和启动文件
2、复制redis-3.2.8/redis.conf到redis/etc
3、将上面第五步中生成的绿色文件移入redis/bin
4、配置redis/etc/redis.conf
主要修改的:
# bind 127.0.0.1(注释掉该行,否则其他机器无法连接到该redis服务)
requirepass 123456789(放开本行,配置自己的密码)
daemonize yes (redis后台运行)
5、启动(./user/local/redis/bin/redis-server /user/local/redis/etc/redis.conf)
注:因为是后台运行,此处不会出现redis的启动图(启动日志等信息)
4测试
本地用redis manager desktop测试连接
5遇到的问题
Q1:执行make时候报错:
cc: 错误:../deps/hiredis/libhiredis.a:没有那个文件或目录
cc: 错误:../deps/lua/src/liblua.a:没有那个文件或目录
cc: 错误:../deps/geohash-int/geohash.o:没有那个文件或目录
cc: 错误:../deps/geohash-int/geohash_helper.o:没有那个文件或目录
make[1]: *** [redis-server] 错误 1
make[1]: 离开目录“/usr/local/redis-3.2.8/src”
make: *** [all] 错误 2
A1:进入redis-3.2.8/deps,执行make geohash-int hiredis jemalloc linenoise lua
Q2:配置都没问题,但是本地连不上
A2:大多数是防火墙的问题
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动