centos7 安装redis 3.2.1
非原创 ren_xian 发表于:2018-06-06 10:48:38
  阅读 :311   收藏   编辑

Redis是一个开源(BSD许可),内存存储的数据结构服务器,可用作数据库,高速缓存和消息队列代理

下载

wget http://download.redis.io/releases/redis-3.2.1.tar.gz

编译环境,如果需要

yum install gcc-c++

解压

tar -zxvf redis-3.2.1.tar.gz 
mv redis-3.2.1 redis3.2.1
cd redis3.2.1
make

make完后,会在src目录下生成相应的文件redis-cli,redis-server等

cd src
make install

输出

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

配置端口,及设置开机启动

./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!

相关命令

查看进程:通过ps -ef|grep redis命令查看Redis进程

启动:service redis_6379 start

关闭:service redis_6379 stop

测试

[root@localhost redis3.2.1]# ./src/redis-cli 
127.0.0.1:6379> set test 'Hello Redis'
OK
127.0.0.1:6379> get test
"Hello Redis"
127.0.0.1:6379>