【环境部署】华为云ECS安装配置Redis5(CentOS 7.4)

华为云ECS CentOS 7.4 安装Redis5

6.1 环境确认

使用命令:gcc -v 确认系统是否已经安装gcc环境。

[root@ecs-s6 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
[root@ecs-s6 ~]# 

如果没有安装请先安装gcc,否则安装Redis会出错。

yum install -y gcc

6.2 Redis下载

登录Xshell客户端连接CentOS服务器,使用wget命令下载相应的安装包。

[root@ecs-s6 J2EETool]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
--2020-01-28 10:14:45--  http://download.redis.io/releases/redis-5.0.7.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1984203 (1.9M) [application/x-gzip]
Saving to: ‘redis-5.0.7.tar.gz’

100%[=========================================================================================================>] 1,984,203    919KB/s   in 2.1s   

2020-01-28 10:14:49 (919 KB/s) - ‘redis-5.0.7.tar.gz’ saved [1984203/1984203]

[root@ecs-s6 J2EETool]# 

6.3 Redis安装

使用tar命令解压缩,进入解压目录进行编译。

[root@ecs-s6 J2EETool]# tar -zxvf redis-5.0.7.tar.gz 
[root@ecs-s6 J2EETool]# cd redis-5.0.7
[root@ecs-s6 redis-5.0.7]## make

将Redis安装到指定目录

[root@ecs-s6 redis-5.0.7]# make PREFIX=/usr/local/redis install
cd src && make install
make[1]: Entering directory `/home/J2EETool/redis-5.0.7/src'
    CC Makefile.dep
make[1]: Leaving directory `/home/J2EETool/redis-5.0.7/src'
make[1]: Entering directory `/home/J2EETool/redis-5.0.7/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/home/J2EETool/redis-5.0.7/src'
[root@ecs-s6 redis-5.0.7]# cp redis.conf /usr/local/redis

编辑安装后的配置文件:/usr/local/redis/redis.conf

# 注释掉本地,这样可以允许远程访问
#bind 127.0.0.1

# 允许进程在后台运行,将配置项从“no”改为“yes”
daemonize no

# 设定需要访问的密码
requirepass HaoJT1980

# 设定日志文件地址(需要提前建立相应的目录)
logfile "/var/log/redis/redis.log"

6.4 Redis启动

[root@ecs-s6 redis]# ./bin/redis-server ./redis.conf
[root@ecs-s6 redis]# ps aux | grep redis
root      2221  0.0  0.0 153896  2308 ?        Ssl  11:05   0:00 ./bin/redis-server *:6379
root      2226  0.0  0.0 112712   964 pts/0    S+   11:06   0:00 grep --color=auto redis

给CentOS的防火墙中添加可访问权限

[root@ecs-s6 redis]# firewall-cmd --query-port=6379/tcp
no
[root@ecs-s6 redis]# firewall-cmd --permanent --add-port=6379/tcp
success
[root@ecs-s6 redis]# firewall-cmd --reload 
success

进入华为云官网的控制台,在网络规则中添加Redis的访问端口权限。

在这里插入图片描述

6.5 客户端访问

在这里插入图片描述

发布了37 篇原创文章 · 获赞 24 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/gavinbj/article/details/104098730
今日推荐