redis配置部署
版本:redis6.0.9
redis部署步骤如下:
[root@localhost software]# pwd
/data/software
wget http://download.redis.io/releases/redis-6.0.9.tar.gz
[root@localhost software]# ll
total 2240
-rw-r--r--. 1 root root 25548 Apr 7 2017 mysql57-community-release-el7-10.noarch.rpm
-rw-r--r--. 1 root root 2261418 Oct 27 03:14 redis-6.0.9.tar.gz
把下载完的redis安装包解压:
tar -zxvf redis-6.0.9.tar.gz
[root@localhost software]# pwd
/data/software
[root@localhost software]# ll
total 2244
-rw-r--r--. 1 root root 25548 Apr 7 2017 mysql57-community-release-el7-10.noarch.rpm
drwxrwxr-x. 7 root root 4096 Oct 27 03:12 redis-6.0.9
-rw-r--r--. 1 root root 2261418 Oct 27 03:14 redis-6.0.9.tar.gz
进入解压后的redis目录进行编译make:
[root@localhost software]# cd redis-6.0.9/
[root@localhost redis-6.0.9]# pwd
/data/software/redis-6.0.9
注意:在执行make命令时报错:
make[2]: Leaving directory `/data/software/redis-6.0.9/deps'
make[1]: [persist-settings] Error 2 (ignored)
CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/data/software/redis-6.0.9/src'
make: *** [all] Error 2
解决方法:
yum install gcc -y
之后执行make命令继续报如下错:
[root@localhost redis-6.0.9]# make
cd src && make all
make[1]: Entering directory `/data/software/redis-6.0.9/src'
CC Makefile.dep
make[1]: Leaving directory `/data/software/redis-6.0.9/src'
make[1]: Entering directory `/data/software/redis-6.0.9/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 `/data/software/redis-6.0.9/src'
make: *** [all] Error 2
- 解决方法:升级GCC版本,CentOS7默认安装的是4.8.5,而redis6.0只支持5.3以上版本,这里将gcc升级到9.
yum install centos-release-scl
yum install devtoolset-9-gcc*
scl enable devtoolset-9 bash
之后在执行make命令,问题解决:make
注意:gcc终于升级好了,这时千万别忘记要进行版本的切换,升级了新版本肯定是使用新版本。建议进行永久切换这样,别临时切换完成之后重新连接服务器gcc自己又降回去了。
临时切换:scl enable devtoolset-9 bash
永久切换:echo “source /opt/rh/devtoolset-9/enable” >> /etc/profile
切换完成之后重新连接服务器生效,查看gcc版本 gcc -v
接下来执行如下命令:
[root@localhost redis-6.0.9]# pwd
/data/software/redis-6.0.9
make install
redis到此安装完毕,测试下是否安装成功:
出现如下所示,说明成功!
启动redis:
[root@localhost src]# pwd
/data/software/redis-6.0.9/src
[root@localhost src]# ./redis-server /data/software/redis-6.0.9/redis.conf &
对redis进行简单配置:redis.conf
- 以后台进程方式启动
修改daemonize no 为daemonize yes - 设置redis远程连接
(1)先放行你设置的端口号
(2)注释掉bind 127.0.0.1
(3)设置redis连接密码:在requirepass foobard改为requirepass jxlJXL@123,
jxlJXL@123为设置的密码,这个密码尽量设置复杂些.
接下来可以进行简单连接redis测试:
[root@localhost src]# ./redis-cli
127.0.0.1:6379>
如上表示成功!