Linux下Redis安裝及配置爲服務



最重要的要點  

必備知識:linux常用軟件安裝過程

演示版本:Redis3.2.3

依賴軟件:tcl8.5+

1.解壓

tar -zxf redis-3.2.3.tar.gz

#解壓壓縮包

2.編譯

cd redis-3.2.3/

#切換目錄

sudo make

#編譯

3.安裝

sudo make install

#安裝,防止權限不夠

4.其它

sudo cp src/redis-server src/redis-cli /usr/bin/

#方便在終端在任何地方直接運行

sudo cp redis.conf /etc/

#

5.Redis基本配置

1.首先,需要確認配置文件是哪一個?/etc/redis.conf還是/etc/redis/6379.conf

由於我們使用的服務,所以/etc/init.d/redis_6379中肯定會包含配置信息:

計算機生成了可選文字:,}#!/bin/sh·#Confiqura七ionsinjec七edbyinstallserverbelow.…EXEC=/bin/redis一serverCL工EXEC=/bin/redis一cliP工DF工LE=/var/run/redis6379.pidCONF='/etc/redis/6379.conf'REDISp0RT='6379'

確認就是/etc/redis/6379.conf

2.修改配置

現在還不知道該改什麼配置。

6.測試

make test

#測試

最終結果:All testspassed without errors!

7.Redis配置爲服務

cd utils

#進入redis-3.2.3目錄下的utils目錄下

./install_server.sh

#配置爲服務

給出如下信息(會配置Redis的相關信息):

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] #選擇Redis端口

Selecting default: 6379

Please select the redis config file name[/etc/redis/6379.conf] #選擇redis配置文件

Selected default - /etc/redis/6379.conf

Please select the redis log file name [/var/log/redis_6379.log] #選擇redis日誌文件位置

Selected default - /var/log/redis_6379.log

Please select the data directory for this instance[/var/lib/redis/6379] #選擇redis數據目錄

Selected default - /var/lib/redis/6379

Please select the redis executable path [/bin/redis-server] #選擇redis可執行目錄

Selected config:

Port          : 6379

Config file   :/etc/redis/6379.conf

Log file      :/var/log/redis_6379.log

Data dir      :/var/lib/redis/6379

Executable    :/bin/redis-server

Cli Executable : /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/init.d/redis_6379 start

#啓動Redis Server

/etc/init.d/redis_6379 stop

#停止Redis Server

redis-cli

#進入Redis Command Line

service redis_6379 start

#使用服務啓動Redis

service redis_6379 stop

#使用服務停止Redis

可能存在的問題

問題1:安裝時出現如下提示信息:

install:無法創建普通文件"/usr/local/bin/redis-server":權限不夠

原因:

執行該安裝命令時權限不足

解決:

使用sudo makeinstall命令執行

問題2:測試時出現如下提示信息:

You need tcl 8.5 or newer in order to run the Redis test

原因:

沒有安裝tcl或者tcl版本低於8.5

解決:

1.解壓

tar -zxf tcl8.6.6-src.tar.gz

#解壓

2.配置

cd unix

#切換到unix目錄

./configure

#配置

3.編譯

make

#編譯

4.安裝

make install

#安裝

參考

http://blog.csdn.net/daniel_ustc/article/details/18099067

發佈了77 篇原創文章 · 獲贊 14 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章