【Redis】Linux安装Redis5.0

2019-05-06  本文已影响0人  境与界

1、查看linux版本

cat /etc/centos-release
# 响应
# CentOS Linux release 7.6.1810 (Core) 

2、验证gcc-c++环境

rpm -qa | grep gcc-c++

3、没有则安装gcc-c++

yum install gcc-c++
yum -y install cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make gcc-c++

4、创建soft文件夹,并在该文件夹下下载redis安装包(放在哪自己随意)

cd /usr/local/soft
wget http://download.redis.io/releases/redis-5.0.4.tar.gz

5、解压redis到/usr/local/develop文件夹下(放在哪自己随意)

tar -zxvf redis-5.0.4.tar.gz -C /usr/local/develop/

6、编译

cd redis-5.0.4/
make

7、报错

cd src && make all
make[1]: Entering directory `/usr/local/develop/redis-5.0.4/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/develop/redis-5.0.4/src'
make[1]: Entering directory `/usr/local/develop/redis-5.0.4/src'
    CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>
                               ^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/usr/local/develop/redis-5.0.4/src'
make: *** [all] Error 2

8、解决报错

yum groupinstall 'Development Tools'
cd deps
make hiredis lua jemalloc linenoise

8、在redis-5.0.4目录下再次执行make

cd ..
make

# 出现如下内容表示编译成功
Hint: It's a good idea to run 'make test' ;)

9、执行安装命令

cd src
make install
# 出现如下内容表示安装成功
int: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

10、修改参数

cd ..
vim redis.conf

# 修改为如下内容:
# 关闭保护模式
protected-mode no 
# 守护进程模式开启
daemonize yes  
# 修改密码为root  
requirepass root
# 注释掉bind 127.0.0.1,使其可远程访问
# bind 127.0.0.1

11、启动redis5.0服务

redis-server redisconf

12、检查端口

netstat -ltnp | grep 6379

13、登录

redis-cli
auth 你的密码

14、开通防火墙端口,可客户端访问

# 开启端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent  
# 重启防火墙
firewall-cmd --reload  
上一篇下一篇

猜你喜欢

热点阅读