【转】Linux系统安装Redis详细过程
本文轉載 https://blog.csdn.net/qq_20989105/article/details/76390367,轉載前請標注原作者,謝謝。
一、安裝gcc?
1、Redis在linux上的安裝首先必須先安裝gcc,這個是用來編譯redis的源文件的。首先需要先切換的到root用戶:
2、然后開始安裝gcc:
[root@localhost /]# yum install gcc-c++ //這個命令是在線安裝的,所以在這之前你的VM必須能夠上網,需要在 VM中把網卡設置成NAT模式 ,因為我使用的是centos,在網絡設置中需要把網卡開啟,反正我在裝完系統之后它是默認關閉的3、之后便會出現下載文件界面:?
?
4、會出現2次確認界面,輸入y即可?
?
5、之后會進行更新檢查,進行更新驗證等等操作,等他自動完成即可。?
6、出現如下代碼即是安裝成功:
?
二、解壓redis的源文件
[root@localhost cheny]# cd Desktop/ [root@localhost Desktop]# ls redis-4.0.1.tar.gz [root@localhost Desktop]# tar zxvf redis-4.0.1.tar.gz redis-4.0.1/ redis-4.0.1/.gitignore redis-4.0.1/00-RELEASENOTES redis-4.0.1/BUGS redis-4.0.1/CONTRIBUTING .......等等三、進入redis的解壓目錄
[root@localhost Desktop]# ls redis-4.0.1 redis-4.0.1.tar.gz [root@localhost Desktop]# cd redis-4.0.1/四、使用make命令編譯
[root@localhost redis-4.0.1]# make // 出現以下信息即是編譯成功 CC notify.oCC setproctitle.oCC blocked.oCC hyperloglog.oCC latency.oCC sparkline.oCC redis-check-rdb.oCC redis-check-aof.oCC geo.oCC lazyfree.oCC module.oCC evict.oCC expire.oCC geohash.oCC geohash_helper.oCC childinfo.oCC defrag.oCC siphash.oCC rax.oLINK redis-serverINSTALL redis-sentinelCC redis-cli.oLINK redis-cliCC redis-benchmark.oLINK redis-benchmarkINSTALL redis-check-rdbINSTALL redis-check-aof五、進入解壓的src目錄下
[root@localhost redis-4.0.1]# cd src六、?
1、運行make test測試是否可以安裝
2、在這里發現有錯誤?
TCL(Tool Command Language)工具腳本語言,是Linux內的一種語言包。,這里需要先安裝tcl。
3、再次測試make test?
這里反正檢查的一大堆,都是綠色的ok。這就可以了?
4、安裝?
[root@localhost src]# make PREFIX=/usr/local/redis install?
?
安裝成功!
?
框框中標出的都是一個個工具命令
七、把解壓的redis路徑下的redis.conf文件拷貝到安裝路徑下面
[root@localhost Desktop]# cd redis-4.0.1/ [root@localhost redis-4.0.1]# ls 00-RELEASENOTES INSTALL runtest tests BUGS Makefile runtest-cluster utils CONTRIBUTING MANIFESTO runtest-sentinel COPYING README.md sentinel.conf deps redis.conf src [root@localhost redis-4.0.1]# cp redis.conf /usr/local/redis [root@localhost redis-4.0.1]# cd /usr/local/redis [root@localhost redis]# ls bin redis.conf 到這里redis已經安裝成功了。八、啟動redis?
第一種方法:進入安裝路徑下的bin
?
這樣其實已經啟動成功了,但是這屬于前端啟動,啟動redis之后,我們的控制臺就不能進行任何操作了。只能ctrl+c停止啟動。
第二種方法:?
后端啟動?
1、首先編輯redis.conf
2、找到daemonize no將其改為yes(在vim中插入數據按鍵盤上的i或者insert)?
?
效果如下:?
?
3、按esc退出insert模式,再按:,并且輸入wq。代表保存并且退出
4、再次啟動
[root@localhost redis]# ls bin redis.conf [root@localhost redis]# ./bin/redis-server ./redis.conf //這里加載配置文件80167:C 30 Jul 16:01:58.145 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 80167:C 30 Jul 16:01:58.145 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=80167, just started 80167:C 30 Jul 16:01:58.145 # Configuration loaded這樣redis就啟動了
可以通過 ps -ef | grep -i redis 來查看是否啟動5、關閉redis
[root@localhost redis]# ./bin/redis-cli shutdown九、簡單的使用
//首先鏈接客戶端 [root@localhost redis]# ./bin/redis-cli //檢查網絡是否可以 127.0.0.1:6379> ping PONG //設置一個鍵值對 127.0.0.1:6379> set name cheny OK //獲取剛剛設置的鍵值對 127.0.0.1:6379> get name "cheny" //查看所有的鍵 127.0.0.1:6379> keys * 1) "name" //刪除name這個鍵 127.0.0.1:6379> del name (integer) 1 127.0.0.1:6379> keys * (empty list or set) 127.0.0.1:6379> ---------------------------END-----------------------------最后,非常感謝原作者分享此文章!
轉載于:https://www.cnblogs.com/hujunhui/p/9353684.html
總結
以上是生活随笔為你收集整理的【转】Linux系统安装Redis详细过程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS - 获取安装所有App的Bund
- 下一篇: linux 其他常用命令