您的位置:首页 > 数据库 > Redis

Linux下Redis安装及配置为服务

2016-10-30 13:08 447 查看


最重要的要点  

必备知识: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中肯定会包含配置信息:



确认就是/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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: