henry_2016:《史上最詳細Centos7安裝Redis教程》
1、安裝環境
[root@192 ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.3.1611 (Core) Release: 7.3.1611 Codename: Core [root@192 ~]#
注意:如果執行該命令如下圖請情況,請參閱此文:《CentOS 7 命令lsb_release: command not found解決方案》
2、Redis下載
獲取下載地址:
下載到本地
`進入到/usr/local/src/目錄下` [root@m src]# cd /usr/local/src/ `下載Reids` [root@m src]# wget http://download.redis.io/releases/redis-5.0.8.tar.gz
3、安裝
3.1、檢查是否安裝了gcc
由於 redis 是使用 C 語言開發的,在安裝之前需要先確認一下是否安裝了 gcc 環境,先來查看一下:
安裝gcc依賴
[root@iZwz991stxdwj560bfmadtZ local]# yum install gcc
[root@192 src]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) [root@192 src]#
如果未安裝可執行如下語句:
yum -y install gcc
3.2、安裝
#`進入下載目錄進行解壓` [root@m src]# cd /usr/local/src/ [root@m src]# tar -zvxf redis-5.0.8.tar.gz [root@m src]# ls redis-5.0.8 redis-5.0.8.tar.gz #`進入到redis安裝包中` [root@m src]# cd redis-5.0.8/ #`進行編譯` [root@m redis-5.0.8]# make #`安裝到指定目錄` [root@m redis-5.0.8]# cd src [root@m src]# make install prefix=/usr/local/redis
4、啟動redis
4.1 啟動
[root@m bin]# cd /usr/local/redis/bin `啟動redis` [root@m bin]# ./redis-server
4.2 后台啟動
`將redis.conf復制到安裝目錄下` [root@m bin]# cd /usr/local/redis/bin [root@m bin]# cp /usr/local/src/redis-5.0.8/redis.conf ./
- 修改
redis.conf文件:
daemonize no
改為
daemonize yes
- 啟動redis
`啟動redis服務端` [root@m bin]# redis-server ./redis.conf 10115:C 26 Mar 2020 20:59:44.525 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 10115:C 26 Mar 2020 20:59:44.525 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=10115, just started 10115:C 26 Mar 2020 20:59:44.525 # Configuration loaded `啟動redis客戶端` [root@m bin]# ./redis-cli 127.0.0.1:6379>


