写这篇文章算是我,回顾下 Redis学习的历程吧! 加油,加油~~ ~
准备:
1、一台腾讯云服务器
2、Xshell 工具: Xshell-7.0.0113p.exe 版本
开始安装 Redis…
命令:
yum install gcc
code:
[root@VM-4-7-centos ~]# yum install gcc
Last metadata expiration check: 1:51:12 ago on Wed 22 Mar 2023 01:18:14 PM CST.
Package gcc-8.5.0-4.el8_5.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@VM-4-7-centos ~]#
命令:
wget https://download.redis.io/releases/redis-5.0.14.tar.gz
注意: 我这里下载安装的是redis-5.0.14版本。
code:
[root@VM-4-7-centos ~]# wget https://download.redis.io/releases/redis-5.0.14.tar.gz
--2023-03-22 15:39:31-- https://download.redis.io/releases/redis-5.0.14.tar.gz
Resolving download.redis.io (download.redis.io)... 45.60.125.1
Connecting to download.redis.io (download.redis.io)|45.60.125.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2000179 (1.9M) [application/octet-stream]
Saving to: ‘redis-5.0.14.tar.gz’
redis-5.0.14.tar.gz 100%[=======================================>] 1.91M 2.50MB/s in 0.8s
2023-03-22 15:39:32 (2.50 MB/s) - ‘redis-5.0.14.tar.gz’ saved [2000179/2000179]
[root@VM-4-7-centos ~]#
备注:
我是在~目录下(/root 目录下) 执行命令 wget https://download.redis.io/releases/redis-5.0.14.tar.gz 的,所以下载的文件在 /root 目录下。
code:
[root@VM-4-7-centos ~]# ll
-rw-r--r-- 1 root root 2000179 Oct 4 2021 redis-5.0.14.tar.gz
[root@VM-4-7-centos ~]#
命令: (在 ~ 目录下执行命令)
tar -xzvf redis-5.0.14.tar.gz
code:
[root@VM-4-7-centos ~]# tar -xzvf redis-5.0.14.tar.gz
redis-5.0.14/
redis-5.0.14/.gitignore
redis-5.0.14/00-RELEASENOTES
redis-5.0.14/BUGS
redis-5.0.14/CONTRIBUTING
redis-5.0.14/COPYING
redis-5.0.14/INSTALL
redis-5.0.14/MANIFESTO
redis-5.0.14/Makefile
redis-5.0.14/README.md
redis-5.0.14/deps/
redis-5.0.14/deps/Makefile
redis-5.0.14/deps/README.md
redis-5.0.14/deps/hiredis/
redis-5.0.14/deps/hiredis/.gitignore
redis-5.0.14/deps/hiredis/.travis.yml
redis-5.0.14/deps/hiredis/CHANGELOG.md
redis-5.0.14/deps/hiredis/COPYING
redis-5.0.14/deps/hiredis/Makefile
redis-5.0.14/deps/hiredis/README.md
redis-5.0.14/deps/hiredis/adapters/
redis-5.0.14/deps/hiredis/adapters/ae.h
...
(这里省去大量的redis解压路径文件)
命令:
ll
code:
[root@VM-4-7-centos ~]# ll
total 1960
drwxrwxr-x 6 root root 4096 Oct 4 2021 redis-5.0.14
-rw-r--r-- 1 root root 2000179 Oct 4 2021 redis-5.0.14.tar.gz
[root@VM-4-7-centos ~]#
命令:
1- cd redis-5.0.14
2- make
命令执行后,很多报文(省略很很多)
code :
[root@VM-4-7-centos ~]# cd redis-5.0.14
[root@VM-4-7-centos redis-5.0.14]# make
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c
src/tcache.o src/ticker.o src/tsd.o src/witness.o
make[2]: Leaving directory '/root/redis-5.0.14/deps'
CC adlist.o
CC db.o
CC lolwut5.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
INSTALL redis-check-aof
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory '/root/redis-5.0.14/src'
[root@VM-4-7-centos redis-5.0.14]#
code:
[root@VM-4-7-centos redis-5.0.14]# ll
total 288
-rw-rw-r-- 1 root root 127554 Oct 4 2021 00-RELEASENOTES
-rw-rw-r-- 1 root root 53 Oct 4 2021 BUGS
-rw-rw-r-- 1 root root 2381 Oct 4 2021 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 Oct 4 2021 COPYING
drwxrwxr-x 6 root root 4096 Mar 22 16:07 deps
-rw-rw-r-- 1 root root 11 Oct 4 2021 INSTALL
-rw-rw-r-- 1 root root 151 Oct 4 2021 Makefile
-rw-rw-r-- 1 root root 6888 Oct 4 2021 MANIFESTO
-rw-rw-r-- 1 root root 20555 Oct 4 2021 README.md
-rw-rw-r-- 1 root root 63088 Oct 4 2021 redis.conf
-rwxrwxr-x 1 root root 275 Oct 4 2021 runtest
-rwxrwxr-x 1 root root 280 Oct 4 2021 runtest-cluster
-rwxrwxr-x 1 root root 373 Oct 4 2021 runtest-moduleapi
-rwxrwxr-x 1 root root 281 Oct 4 2021 runtest-sentinel
-rw-rw-r-- 1 root root 9710 Oct 4 2021 sentinel.conf
drwxrwxr-x 3 root root 4096 Mar 22 16:08 src
drwxrwxr-x 11 root root 4096 Oct 4 2021 tests
drwxrwxr-x 8 root root 4096 Oct 4 2021 utils
命令:
pwd
code:
[root@VM-4-7-centos redis-5.0.14]# pwd
/root/redis-5.0.14
要修改的地方:
1- daemonize yes #后台启动
2- protected‐mode no #关闭保护模式,开启的话,只有本机才可以访问redis
3- #bind 127.0.0.1(bind绑定的是自己机器网卡的ip,如果有多块网卡可以配多个ip,代表允许客户端通过机器的哪些网卡ip去访问,内网一般可以不配置bind,注释掉即可)
命令:(在redis-5.0.14 目录下)
第一步 vim redis.conf(进入redis.conf 文件)
第二步 i (进入了修改的状态)
退出并保存文件 命令为 :wq
命令:(在 redis-5.0.14 目录下)
src/redis-server redis.conf
code:
[root@VM-4-7-centos redis-5.0.14]# src/redis-server redis.conf
2472369:C 23 Mar 2023 14:57:09.404 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2472369:C 23 Mar 2023 14:57:09.404 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=2472369, just started
2472369:C 23 Mar 2023 14:57:09.404 # Configuration loaded
[root@VM-4-7-centos redis-5.0.14]#
命令:
ps -ef | grep redis
code:
[root@VM-4-7-centos redis-5.0.14]# ps -ef | grep redis
root 2472370 1 0 14:57 ? 00:00:00 src/redis-server 127.0.0.1:6379
root 2473296 2458374 0 15:00 pts/1 00:00:00 grep --color=auto redis
命令:
src/redis-cli
code:
[root@VM-4-7-centos redis-5.0.14]# src/redis-cli
127.0.0.1:6379>
命令:
quit
code:
127.0.0.1:6379> quit
[root@VM-4-7-centos redis-5.0.14]#
命令:(三种)
(1)pkill redis‐server
(2)kill 进程号
(3)src/redis‐cli shutdown
一个单机版的 redis服务就安装、测试好了。