1. 安装步骤
1.1 准备工作:下载安装最新版的gcc编译器
[root@AliyunServer ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1.2 下载redis-6.2.1.tar.gz放/opt目录
[root@AliyunServer opt]# ls
containerd redis-6.2.1 redis-6.2.1.tar.gz
1.3 解压命令:tar -zxvf redis-6.2.1.tar.gz
[root@AliyunServer opt]# tar -zxvf redis-6.2.1.tar.gz
redis-6.2.1/
redis-6.2.1/.github/
redis-6.2.1/.github/ISSUE_TEMPLATE/
redis-6.2.1/.github/ISSUE_TEMPLATE/bug_report.md
redis-6.2.1/.github/ISSUE_TEMPLATE/crash_report.md
redis-6.2.1/.github/ISSUE_TEMPLATE/feature_request.md
redis-6.2.1/.github/ISSUE_TEMPLATE/other_stuff.md
redis-6.2.1/.github/ISSUE_TEMPLATE/question.md
redis-6.2.1/.github/workflows/
redis-6.2.1/.github/workflows/ci.yml
redis-6.2.1/.github/workflows/daily.yml
...
1.4 解压完成后进入目录:cd redis-6.2.1
在redis-6.2.1目录下再次执行make命令(只是编译好)
[root@AliyunServer redis-6.2.1]# make
cd src && make all
make[1]: Entering directory `/opt/redis-6.2.1/src'
CC Makefile.dep
make[1]: Leaving directory `/opt/redis-6.2.1/src'
make[1]: Entering directory `/opt/redis-6.2.1/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
...
1.5 继续执行: make install
[root@AliyunServer redis-6.2.1]# make install
cd src && make install
make[1]: Entering directory `/opt/redis-6.2.1/src'
CC Makefile.dep
make[1]: Leaving directory `/opt/redis-6.2.1/src'
make[1]: Entering directory `/opt/redis-6.2.1/src'
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
make[1]: Leaving directory `/opt/redis-6.2.1/src'
2. 安装目录:/usr/local/bin
查看默认安装目录:
[root@AliyunServer bin]# ll
total 31316
-rwxr-xr-x 1 root root 399 Dec 27 09:52 cloud-id
-rwxr-xr-x 1 root root 403 Dec 27 09:52 cloud-init
-rwxr-xr-x 1 root root 2108 Dec 27 09:52 cloud-init-per
-rwxr-xr-x 1 root root 12737304 Feb 11 15:55 docker-compose
-rwxr-xr-x 1 root root 1003 Dec 27 09:52 jsondiff
-rwxr-xr-x 1 root root 3858 Dec 27 09:52 jsonpatch
-rwxr-xr-x 1 root root 1837 Dec 27 09:52 jsonpointer
-rwxr-xr-x 1 root root 397 Dec 27 09:52 jsonschema
-rwxr-xr-x 1 root root 421 Dec 27 09:52 normalizer
-rwxr-xr-x 1 root root 4833352 Feb 15 22:20 redis-benchmark
lrwxrwxrwx 1 root root 12 Feb 15 22:20 redis-check-aof -> redis-server
lrwxrwxrwx 1 root root 12 Feb 15 22:20 redis-check-rdb -> redis-server
-rwxr-xr-x 1 root root 5003368 Feb 15 22:20 redis-cli
lrwxrwxrwx 1 root root 12 Feb 15 22:20 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 9450208 Feb 15 22:20 redis-server
redis-benchmark:性能测试工具,可以在自己本子运行,看看自己本子性能如何 redis-check-aof:修复有问题的AOF文件,rdb和aof后面讲 redis-check-rdb:修复有问题的dump.rdb文件 redis-sentinel:Redis集群使用 redis-server:Redis服务器启动命令 redis-cli:客户端,操作入口
3.前台启动(不推荐)
前台启动,命令行窗口不能关闭,否则服务器停止
[root@AliyunServer bin]# redis-server
5385:C 15 Feb 2022 22:23:15.016 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5385:C 15 Feb 2022 22:23:15.016 # Redis version=6.2.1, bits=64, commit=00000000, modified=0, pid=5385, just started
5385:C 15 Feb 2022 22:23:15.016 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
5385:M 15 Feb 2022 22:23:15.017 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.2.1 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 5385
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
4. 后台启动(推荐)
4.1 备份redis.conf
拷贝一份redis.conf到其他目录
[root@AliyunServer redis-6.2.1]# cp redis.conf /etc/redis.conf
4.2 后台启动设置daemonize no改成yes
修改redis.conf(128行)文件将里面的daemonize no 改成yes,让服务在后台启动
################################# GENERAL #####################################
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# When Redis is supervised by upstart or systemd, this parameter has no impact.
daemonize yes
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# requires "expect stop" in your upstart job config
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# on startup, and updating Redis status on a regular
# basis.
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
# They do not enable continuous pings back to your supervisor.
#
# The default is "no". To run under upstart/systemd, you can simply uncomment
# the line below:
#
# supervised auto
/daemon
vim redis.conf,然后输入 / ,输入daemon进行查找(vim查找用法)
4.3 Redis启动
[root@AliyunServer bin]# redis-server /etc/redis.conf
[root@AliyunServer bin]# ps -ef | grep redis
root 5565 1 0 22:32 ? 00:00:00 redis-server 127.0.0.1:6379
root 5571 887 0 22:33 pts/0 00:00:00 grep --color=auto redis