当前位置:网站首页>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測試是否成功
到這裏就全部完成了!!!
边栏推荐
- 相关数据库问题提问。
- 原理:WebMvcConfigurer 与 WebMvcConfigurationSupport避坑指南
- Goland常用快捷键设置
- RT thread Kernel Implementation (VI): time slice
- How to set the hot deployment of idea web project
- 编写并运行第一个Go语言程序
- Performance comparison of random network, scale-free network, small world network and NS small world matlab simulation
- RT thread migration to s5p4418 (I): scheduler
- [fuzzy neural network] mobile robot path planning based on Fuzzy Neural Network
- Use of sscanf function
猜你喜欢

ETL为什么经常变成ELT甚至LET?

Principle: webmvcconfigurer and webmvcconfigurationsupport pit avoidance Guide

RT thread Kernel Implementation (V): timer

2、 Layout system

CPU到底是怎么识别代码的?
![[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts](/img/ed/76db436ab5e35fba742dc287402fe3.png)
[my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts

Skillfully use 5 keys to improve office efficiency

ROS-URDF

app闪退

Porting RT thread to s5p4418 (V): thread communication
随机推荐
Egret engine P2 physics engine (2) - Funny physical phenomenon of small balls hitting the ground
[datawhale team learning] task02: mathematical operation, string and text, list
CPU到底是怎么识别代码的?
[Hot100]回文子串 与 最长回文子串
SOC_ AHB_ SD_ IF
How to convert XML to JSON
6、 Shopping ⻋ and orders
Use of sscanf function
Install the components corresponding to setup
1.3 - Code System
Go installation and configuration (1)
RT thread Kernel Implementation (I): threads and scheduling
Ftplib+ tqdm upload and download progress bar
2、 Layout system
【申博攻略】五.专家推荐信模板
【Hot100】11. 盛最多水的容器
Linux服务器安装Redis
如果我在珠海,到哪里开户比较好?另外,手机开户安全么?
【Hot100】15. 三数之和
Traverse map