当前位置:网站首页>Linux服務器安裝Redis
Linux服務器安裝Redis
2022-06-30 07:00:00 【菜鳥是大神】
本文章使用的服務器為CentOS7.6
1、下載redis
wget 是一個從網絡上自動下載文件的自由工具,支持通過 HTTP、HTTPS、FTP 三個最常見的 TCP/IP協議 下載,並可以使用 HTTP 代理。“wget” 這個名稱來源於 “World Wide Web” 與 “get” 的結合。
wget https://download.redis.io/releases/redis-6.0.8.tar.gz
2 、移動壓縮包比特置
我們一般將程序的安裝包放在opt目錄下,這是給主機額外安裝軟件所擺放的目錄,所以我們將下載好的安裝包移動到opt目錄下,並解壓。
mv redis-6.0.8.tar.gz /opt
1
進入opt文件夾
cd /opt
3、解壓文件
執行該命令對我們剛下載的redis壓縮包進行解壓
tar -zxvf redis-6.0.8.tar.gz
其他解壓命令
tar –xvf file.tar //解壓 tar包
tar -zxvf file.tar.gz //解壓tar.gz
tar -jxvf file.tar.bz2 //解壓 tar.bz2
tar –Zxvf file.tar.Z //解壓tar.Z
4、進入解壓後的文件
cd redis-6.0.8
5、基本的環境安裝
因為redis是c寫的,所以我們需要安裝c語言環境,如果沒有gcc環境,需要執行以下命令。
yum install gcc-c++ tcl
有則直接執行這一步
make
make install
mak:
使用之後如果出現以下錯誤,是因為redis6以上版本要使用gcc7

昇級gcc
yum install centos-release-scl
yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
昇級完成後,執行以下make distclean清除一下失敗編譯的文件,然後重新make,出現這個就成功了

make install:

6. 複制redis的默認配置文件
默認的安裝路徑一般都是usr/local/bin,我們進入到這個目錄。
為了防止我們頻繁修改配置文件導致出現不必要的麻煩,我們要對配置文件進行複制,以後的修改就只針對複制的這個配置文件就行了
mkdir config # 創建文件夾
cp /opt/redis-6.0.8/redis.conf config # 將/opt目錄下redis配置文件拷貝到config目錄下
之後的操作都是根據這個配置文件來
7、設置為後臺啟動
redis默認不是後臺啟動的,我們要修改配置文件,修改為後臺運行
vim config/redis.conf
將daemonize no 改為 yes就可以。
小提示:可以點擊斜杠然後輸入關鍵詞進行全局搜索

守護進程(daemon)是一類在後臺運行的特殊進程,用於執行特定的系統任務。很多守護進程在系統引導的時候啟動,並且一直運行直到系統關閉。另一些只在需要的時候才啟動,完成任務後就自動結束
8、啟動
redis-server config/redis.conf
通過查看進程來判斷是否啟動成功
ps -fe | grep redis
測試連接
redis-cli -p 6379
關閉
shutdown
9、設置密碼
進入配置文件裏面修改
requirepass:這個就是redis的密碼了,如果要遠程連接的話那麼就配置一下這個密碼

10、遠程連接
1、要配置密碼 (如果不配置密碼就要關閉保護模式,這種是不建議的)
2、redis默認是不支持遠程連接,需要手動開啟,在redis.conf文件中,找到下方法代碼,注釋掉:

然後重啟服務
然後開放6379這個端口號,在服務器工作臺那裏也開放這個端口號
可以通過QuickRedis測試是否成功
到這裏就全部完成了!!!
边栏推荐
- Assembly language learning I (with stack co process, 32-bit registers and related instructions, to be continued 06/29)
- Porting RT thread to s5p4418 (V): thread communication
- Which securities company is good for opening a mobile account? Also, is it safe to open an account online?
- SOC_AHB_SD_IF
- Authority management system
- Out of class implementation of member function of class template
- ETL为什么经常变成ELT甚至LET?
- Four tips in numpy
- RT thread Kernel Implementation (I): threads and scheduling
- Fastapi learning Day1
猜你喜欢

IDEA import导入的类明明存在,却飘红?

1.9 - Cache

How to set the hot deployment of idea web project

RT thread Kernel Implementation (V): timer

First line of code (Third Edition) learning notes

JS widget wave JS implementation of wave progress bar animation style

Go项目目录结构介绍

1.3 - Code System

安装Go语言开发工具

Jingwei Hengrun won the 10ppm quality award of paccar group again
随机推荐
Joseph problem C language
RT thread migration to s5p4418 (I): scheduler
Several C language implementations
ROS service communication programming
史上最全一句话木马
安装setup对应的组件
RT thread Kernel Implementation (I): threads and scheduling
Xshell传输文件
Numpy中的四个小技巧
Write a C program to judge whether the system is large end byte order or small end byte order
[fuzzy neural network] mobile robot path planning based on Fuzzy Neural Network
1.9 - Classification of memory
Running lantern effect JS text rotation effect realization
Huawei full-scale Daniel shared the 598 page full-color Manual of network protocols for the first time
Daemon and user threads
RT thread Kernel Implementation (II): critical area, object container
Win10踩坑-开机0xc0000225
Egret P2 pit encountered by physical engine (1)
RT thread Kernel Implementation (VI): time slice
1.4 - fixed and floating point numbers