Linux下安装Redis

Linux下安装Redis

Tags: Redis

摘要

Linux下安装Redis

linux下安装Redis

以ubuntu x86_64为实验环境

自动安装

sudo apt-get install redis-server

这种方式安装有个很大的问题,就是无法控制安装的版本。像我的ubuntu机器上跑出来的结果居然是要安装redis 2.6.7 版本,而目前最新的是 3.x 版本。

手工安装

wget http://download.redis.io/releases/redis-2.8.24.tar.gz
tar zxvf redis-2.8.24.tar.gz
cd redis-2.8.24

sudo apt-get install build-essential
sudo make
sudo make install

后台启动

cd utils
sudo ./install_server.sh

打印的日志如下

$ sudo ./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...
 Adding system startup for /etc/init.d/redis_6379 ...
   /etc/rc0.d/K20redis_6379 -> ../init.d/redis_6379
   /etc/rc1.d/K20redis_6379 -> ../init.d/redis_6379
   /etc/rc6.d/K20redis_6379 -> ../init.d/redis_6379
   /etc/rc2.d/S20redis_6379 -> ../init.d/redis_6379
   /etc/rc3.d/S20redis_6379 -> ../init.d/redis_6379
   /etc/rc4.d/S20redis_6379 -> ../init.d/redis_6379
   /etc/rc5.d/S20redis_6379 -> ../init.d/redis_6379
Success!
Starting Redis server...
Installation successful!

启停服务

sudo service redis_6379 start
sudo service redis_6379 stop

此时已经是开机启动了

连接redis

本机

redis-cli

指定服务器地址

redis-cli -h  redisip