linux(CentOS 7)安裝redis 及實現redis desktop manager連接

redis版本:redis-4.0.8

redis官方網站可以獲取最新版本:https://redis.io/


創建文件夾來存放redis安裝包:

mkdir server_redis

下載redis安裝包:

wget http://download.redis.io/redis-stable.tar.gz

解壓:

tar xzf redis-4.0.8.tar.gz

編譯安裝:

[root@localhost server_redis]# cd redis-4.0.8 # 進入解壓後的文件夾,使用make編譯

[root@localhost redis-4.0.8]# make

編譯後報錯,未找到gcc:

gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c  
make[3]: gcc:命令未找到  
make[3]: *** [net.o] 錯誤 127 

可以使用yum insatll 安裝gcc 一些依賴庫也會自動下載比較方便:

[root@localhost server_redis]# yum search gcc  # 找到我們想要的gcc編譯器

[root@localhost server_redis]# yum search gcc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.nju.edu.cn
=============================== N/S matched: gcc ===============================
relaxngcc-javadoc.noarch : Javadoc for relaxngcc
compat-gcc-44.x86_64 : Compatibility GNU Compiler Collection
compat-gcc-44-c++.x86_64 : C++ support for compatibility compiler
compat-gcc-44-gfortran.x86_64 : Fortran support for compatibility compiler
gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
gcc-gfortran.x86_64 : Fortran support
gcc-go.x86_64 : Go support
libgomp.i686 : GCC OpenMP v3.0 shared support library
...部分省略...

這裏我下載的是gcc.x86_64 我也不是太懂,但是後來的編譯中並沒有什麼問題  但是有幾個warning 求大神指導一下

然後就一路 y 就可以了

[root@localhost server_redis]# yum install gcc.x86_64
Is this ok [y/N]: y

安裝成功後就可以編譯了:

[root@localhost redis-4.0.8]# make

這裏我並沒有出現報錯但是有的人可能出現編譯失敗的 可以參考一下這個:

http://blog.csdn.net/qq_26144777/article/details/56839257

進入 src文件夾 執行make install :

[root@localhost src]# make install
    CC Makefile.dep

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

到這裏就可以運行redis了 可以執行 ./redis-server:

[root@localhost src]# ./redis-server
6195:C 07 Mar 11:58:29.584 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6195:C 07 Mar 11:58:29.584 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=6195, just started
6195:C 07 Mar 11:58:29.584 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
6195:M 07 Mar 11:58:29.584 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 4.0.8 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6195
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

但是這樣退出後並不會後臺運行:

[root@localhost redis-4.0.8]# ./utils/install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

我都是默認的沒有修改, 下面就修改配置文件了,進入並打開etc/redis/6379.conf:

[root@localhost server_redis]# cd /etc/redis/
[root@localhost redis]# vim 6379.conf

找到requierpass去掉註釋  修改密碼 方便後面的redis desktop manager連接

註釋掉 bing 127.0.0.1

將appendonly yes 修改爲no:

appendonly no

退出並保存

下面就是介紹怎麼使用redis desktop manager 連接了 由於linux 安全策略的問題,這裏我們要修改防火牆配置,有點麻煩:

命令比較簡單:

[root@localhost redis]# iptables -A INPUT -P tcp --dport 6379 -j ACCEPT        # centos 7中不知道iptables有沒有影響但是還是設置了一下
最後發現保存不了,醉了,網上查要修改文件,不管了先

修改firewall策略:

[root@localhost etc]# firewall-cmd --zone=public --add-port=6379/tcp           # 修改firewall規則
success
[root@localhost etc]# firewall-cmd --permanent --zone=public --add-port=6379/tcp
success
[root@localhost etc]# firewall-cmd --reload      # 永久保存
success
linux中基本配置完成,下面用redis desktop manager連接:


附帶連接成功效果圖:




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章