当前位置:网站首页>Redis —— How To Install Redis And Configuration(如何快速在 Ubuntu18.04 与 CentOS7.6 Linux 系统上安装 Redis)
Redis —— How To Install Redis And Configuration(如何快速在 Ubuntu18.04 与 CentOS7.6 Linux 系统上安装 Redis)
2022-07-04 12:44:00 【Alascanfu】
本文目录
如何快速安装 Redis 并配置环境变量
Ubuntu18.04 Linux 下安装 Redis
前期准备
redis-6.2.6.tar.gz 安装包
tcl8.6.1-src.tar 安装包 (为解决
make test过程中 遇到“You need tcl 8.5 or newer in order to run the Redis test”的问题)
Ubuntu 18.04 环境下安装
步骤一:解压下载好置于~/downloads/redis-6.2.6.tar.gz 到 /usr/local 目录下并重命名
# 进入到用户下载好存放安装包的目录
$ cd ~/downloads
# 解压 redis-6.2.6.tar.gz 到 /usr/local 目录下
$ sudo tar -zxvf redis-6.2.6.tar.gz -C /usr/local
# 进入到应用文件夹
$ cd /usr/local
# 重命名
$ sudo mv ./redis-6.2.6 ./redis
# 更改文件夹权限
$ sudo chown -R hadoop ./redis/
步骤二:进入到/usr/local/redis/src 下编译(make)
$ cd /usr/local/redis/src && make
注意点一:如若出现 Command ‘gcc’ not found ,因为 redis 是作者通过C语言进行编写的,而系统中并没有安装 gcc 或者版本较低从而导致无法编译运行,没有该条指令操作去编译。
解决方案
# 更新安装源
$ sudo apt-get update
# 安装 gcc
$ sudo apt-get install gcc
完成上述操作之后,再次在 /usr/local/redis/src 目录下执行 make
注意点二: 当我们再次执行 make 命令时,显示 error: jemalloc/jemalloc.h: No such file or directory 时,官方文档提出这是关于分配器 allocator 的问题,如果有MALLOC 这个 环境变量, 会有用这个环境变量的 去建立Redis。libc 并不是默认的分配器,默认的是 jemalloc 因为 jemalloc 被证明有着比 libc 更少的 fragmentation problems,为了解决上述默认值带来的问题。我们只需要进行如下操作:
$ make MALLOC=libc
完成上述操作之后,再次在 /usr/local/redis/src 目录下执行 make
步骤三:进行 make test 测试 redis 的功能
$ make test
注意点一:在执行redis测试命令make test过程中,遇到“You need tcl 8.5 or newer in order to run the Redis test”的问题时
解决方案
将准备好的 tcl8.6.1-src.tar.gz 解压并配置安装
# 进入到用户下载好存放安装包的目录
$ cd ~/downloads
# 解压 tcl8.6.1-src.tar.gz 到指定目录下
$ tar -zxvf ./tcl8.6.1-src.tar.gz -C ~/software
$ cd ~/software/tcl8.6.1/unix
# 进入到软件并启动配置
$ sudo ./configure
# 安装
$ sudo make
$ sudo make install
完成上述操作之后,进入到 /usr/local/redis/src 目录下 执行make test 进行redis测试
步骤四:安装 redis 之后并启动
$ cd /usr/local/redis/src
$ sudo make install
$ redis-server
启动成功如图所示:

配置环境变量
# 修改环境变量配置
$ vim ~/.bashrc
# 使得修改环境变量配置生效
$ source ~/.bashrc
~./bashrc Ubuntu18.04下
export REDIS_HOME=/usr/local/redis
export PATH=${REDIS_HOME}/src:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin:${HBASE_HOME}/bin:${ZOOKEEPER_HOME}/bin:${MY_HOME}/bin:$PATH
大功告成QwQ
CentOS 7.6 Linux 下安装 Redis
前期准备
redis-6.2.6.tar.gz 安装包
CentOS 7.6 环境下安装
步骤一:安装 Redis 依赖
因为 Redis 是基于 C 语言进行编写的,因此首先需要安装 Redis 所需要的 gcc 依赖。
sudo yum install -y gcc tcl
步骤二:解压下载好置于~/downloads/redis-6.2.6.tar.gz 到 /usr/local 目录下并重命名
# 进入到用户下载好存放安装包的目录
$ cd ~/downloads
# 解压 redis-6.2.6.tar.gz 到 /usr/local 目录下
$ sudo tar -zxvf redis-6.2.6.tar.gz -C /usr/local
# 进入到应用文件夹
$ cd /usr/local
# 重命名
$ sudo mv ./redis-6.2.6 ./redis
# 更改文件夹权限
$ sudo chown -R hadoop ./redis/
步骤三:进入解压后的 redis 文件夹之后 进行安装
# 进入到解压好的 redis 目录下
$ cd /usr/local/redis
$ make && make install
# 默认安装好后的路径在 /usr/local/bin 目录下
$ cd /usr/local/bin
# 检查是否安装成功
[[email protected] bin]# ll
总用量 18904
-rwxr-xr-x. 1 root root 4829528 6月 15 10:48 redis-benchmark
lrwxrwxrwx. 1 root root 12 6月 15 10:48 redis-check-aof -> redis-server
lrwxrwxrwx. 1 root root 12 6月 15 10:48 redis-check-rdb -> redis-server
-rwxr-xr-x. 1 root root 5003816 6月 15 10:48 redis-cli
lrwxrwxrwx. 1 root root 12 6月 15 10:48 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 9518952 6月 15 10:48 redis-server
步骤四:启动并测试
# 因为已经配置好全局环境变量所以可以直接启动
$ redis-server
# 测试
[[email protected] redis]$ redis-cli
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> exit
大功告成QwQ
边栏推荐
- Rsyslog配置及使用教程
- [FAQ] summary of common causes and solutions of Huawei account service error 907135701
- C#基础深入学习一
- PostgreSQL 9.1 飞升之路
- Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
- AI painting minimalist tutorial
- Dry goods sorting! How about the development trend of ERP in the manufacturing industry? It's enough to read this article
- 8 expansion sub packages! Recbole launches 2.0!
- Introduction to XML I
- iptables基础及Samba配置举例
猜你喜欢

Comparative study of the gods in the twilight Era

Practice: fabric user certificate revocation operation process

Reptile exercises (I)

Annual comprehensive analysis of China's mobile reading market in 2022

Dry goods sorting! How about the development trend of ERP in the manufacturing industry? It's enough to read this article

"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue

Is the outdoor LED screen waterproof?

聊聊支付流程的设计与实现逻辑

求解:在oracle中如何用一条语句用delete删除两个表中jack的信息
提高MySQL深分页查询效率的三种方案
随机推荐
Flet教程之 03 FilledButton基础入门(教程含源码)(教程含源码)
Using nsproxy to forward messages
Iptables foundation and Samba configuration examples
Etcd storage, watch and expiration mechanism
请问大佬们有遇到这个情况吗,cdc 1.4 连接MySQL 5.7 无法使用 timestamp
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Cors: standard scheme of cross domain resource request
Comprehensive evaluation of modular note taking software: craft, notation, flowus
Simple understanding of binary search
[AI system frontier dynamics, issue 40] Hinton: my deep learning career and research mind method; Google refutes rumors and gives up tensorflow; The apotheosis framework is officially open source
C语言程序设计
Using nsproxy to forward messages
C语言课程设计题
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
AI 绘画极简教程
C语言小型商品管理系统
Golang sets the small details of goproxy proxy proxy, which is applicable to go module download timeout and Alibaba cloud image go module download timeout
Read the BGP agreement in 6 minutes.
WPF double slider control and forced capture of mouse event focus
Database lock table? Don't panic, this article teaches you how to solve it