1. 下载包
cd /usr/software/
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
2. 创建安装目录,并解压,安装
mkdir /usr/local/redis
tar -zxvf redis-4.0.8.tar.gz
cd redis-4.0.8/
make
此处可能出错gcc ---> gcc: Command not found
yum install gcc
make 或者目录删除,解压,然后 make
cd src/
make install PREFIX=/usr/local/redis
3. 配置
mkdir /usr/local/redis/etc
cd ..
mv redis.conf /usr/local/redis/etc
vi /usr/local/redis/etc/redis.conf
改两处:
将daemonize no 改成daemonize yes
requirepass 123 设置密码
3. 开机启动
vi /etc/rc.local
添加:/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
4. 常用命令
启动redis:./redis-cli -h 127.0.0.1 -p 6379 带密码登录时 -a xxx
set key
get key
quit