Redis官网:https://redis.io
Redis中文官网:http://www.redis.cn
- 下载源码
在服务器上直接使用wget命令安装,最新版下载地址:http://download.redis.io/releases/redis-5.0.7.tar.gz
[root@activemq redis-5.0.7]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
- 编译,源码编译就会在src目录下生成可执行文件
[root@activemq redis-5.0.7]# make
- 安装(install),就是拷贝的过程,将可执行文件拷贝到一个目录
You can use `make PREFIX=/some/other/directory install` if you wish to use a different destination.不指定的话,默认目录就是/usr/local/bin
[root@activemq redis-5.0.7]# make install
- 设置环境变量,这个步骤是为了在服务器任何步骤都可以执行redis的可执行文件,就跟javac一样,设置JAVA_HOME.在/etc/profile文件中添加
export REDIS_HOME=/home/iflytek/redis-5.0.7
export PATH=$PATH:$JAVA_HOME/bin:$REDIS_HOME/bin
- 将redis添加为后台服务,随服务器开机启动,在utils目录下执行install_server.sh 可以装多个实例。
[root@activemq 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 [/home/iflytek/redis-5.0.7/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 : /home/iflytek/redis-5.0.7/bin/redis-server
Cli Executable : /home/iflytek/redis-5.0.7/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!
- 查看服务进程号和状态
[root@activemq utils]# ps -ef|grep redis
root 1429 1 0 17:00 ? 00:00:00 /home/iflytek/redis-5.0.7/bin/redis-server 127.0.0.1:6379
root 1455 26641 0 17:00 pts/0 00:00:00 grep --color=auto redis
[root@activemq utils]# service redis_6379 status
Redis is running (1429)