Linux 安装单机Redis

6 篇文章 0 订阅

开局介绍

  大家好呀,最近又很久没有更新安装的视频了,今天讲讲Redis的安装,相信很多小伙伴在Linux安装Redis,需要一点时间,本文致力于用最快的速度,教大家搭建单机版Redis,然后过一段时间后,我会给大家出一个Sentinel 集群和Cluster集群搭建

开始搭建

1、安装C环境,Redis用C写的

[root@VM-4-12-centos redis01]# pwd
/opt/redis01
[root@VM-4-12-centos redis01]# yum -y install gcc tcl autoconf automake

注意:如果你是使用Centos7,请看看gcc的版本,小于5.3无法编译Redis6.0

[root@VM-4-12-centos redis01]# gcc -v
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC) 

2、上传Redis 6.x包

[root@VM-4-12-centos redis01]# pwd
/opt/redis01
[root@VM-4-12-centos redis01]# ll
total 2180
-rw-r--r-- 1 root root 2228781 Jun 27  2021 redis-6.0.6.tar.gz

3、解压

[root@VM-4-12-centos redis01]# tar -zxvf redis-6.0.6.tar.gz 

4、进入redis,同时创建一个目录,为了后面全局启动

[root@VM-4-12-centos redis01]# cd redis-6.0.6/
[root@VM-4-12-centos redis-6.0.6]# ll
total 264
-rw-rw-r--  1 root root 80561 Jul 21  2020 00-RELEASENOTES
-rw-rw-r--  1 root root    51 Jul 21  2020 BUGS
-rw-rw-r--  1 root root  2381 Jul 21  2020 CONTRIBUTING
-rw-rw-r--  1 root root  1487 Jul 21  2020 COPYING
drwxrwxr-x  6 root root  4096 Jul 21  2020 deps
-rw-rw-r--  1 root root    11 Jul 21  2020 INSTALL
-rw-rw-r--  1 root root   151 Jul 21  2020 Makefile
-rw-rw-r--  1 root root  6888 Jul 21  2020 MANIFESTO
-rw-rw-r--  1 root root 20806 Jul 21  2020 README.md
-rw-rw-r--  1 root root 83392 Jul 21  2020 redis.conf
-rwxrwxr-x  1 root root   275 Jul 21  2020 runtest
-rwxrwxr-x  1 root root   280 Jul 21  2020 runtest-cluster
-rwxrwxr-x  1 root root   679 Jul 21  2020 runtest-moduleapi
-rwxrwxr-x  1 root root   281 Jul 21  2020 runtest-sentinel
-rw-rw-r--  1 root root 10743 Jul 21  2020 sentinel.conf
drwxrwxr-x  3 root root  4096 Jul 21  2020 src
drwxrwxr-x 11 root root  4096 Jul 21  2020 tests
-rw-rw-r--  1 root root  3055 Jul 21  2020 TLS.md
drwxrwxr-x  9 root root  4096 Jul 21  2020 utils
[root@VM-4-12-centos redis-6.0.6]# mkdir -p /usr/local/redis

5、编译

[root@VM-4-12-centos redis-6.0.6]# make PREFIX=/usr/local/redis install

6、编译成功会有以下提示,如果没有成功,麻烦重新安装,最好重装云盘

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

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory '/opt/redis01/redis-6.0.6/src'
[root@VM-4-12-centos redis-6.0.6]# 

7、进入解压的bin目录

[root@VM-4-12-centos redis]# cd /usr/local/redis/bin/
[root@VM-4-12-centos bin]# ll
total 45700
-rwxr-xr-x 1 root root  6391504 Feb 15 19:49 redis-benchmark
-rwxr-xr-x 1 root root 11232512 Feb 15 19:49 redis-check-aof
-rwxr-xr-x 1 root root 11232512 Feb 15 19:49 redis-check-rdb
-rwxr-xr-x 1 root root  6696704 Feb 15 19:49 redis-cli
lrwxrwxrwx 1 root root       12 Feb 15 19:49 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 11232512 Feb 15 19:49 redis-server

8、上去,然后创建conf文件夹

[root@VM-4-12-centos bin]# cd ../ && mkdir conf
[root@VM-4-12-centos redis]# ll
total 8
drwxr-xr-x 2 root root 4096 Feb 15 19:49 bin
drwxr-xr-x 2 root root 4096 Feb 15 19:57 conf

9、拷贝conf,同时修改三个地方

[root@VM-4-12-centos redis]# cp /opt/redis01/redis-6.0.6/redis.conf /usr/local/redis/conf/
[root@VM-4-12-centos redis]# cd /usr/local/redis/conf/
[root@VM-4-12-centos redis]# vi redis.conf

10、bind是开放任意ip访问,daemonize 启动后台进程,requirepass 123456 是密码

#bind 127.0.0.1

bind 0.0.0.0

# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes

# requirepass foobared
  
  requirepass 123456

11、启动

[root@VM-4-12-centos redis]# ./bin/redis-server ./conf/redis.conf 
711347:C 15 Feb 2022 20:40:17.908 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
711347:C 15 Feb 2022 20:40:17.908 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=711347, just started
711347:C 15 Feb 2022 20:40:17.908 # Configuration loaded

12、测试,如果不想看到下面警告,-a 123456先不输入,进入redis后输入 auth 123456

[root@VM-4-12-centos redis]# ./bin/redis-cli -p 6379 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> set a b
OK
127.0.0.1:6379> get a
"b"

13、查看公网ip

[root@VM-4-12-centos /]# curl ifconfig.me

14、本地访问远程Redis,成功
在这里插入图片描述

屏幕前的大帅比、还有大漂亮,给个三连再走呗

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jesscia ^_^

您的打赏将是我努力的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值