ubuntu 16.04.1 LTS redis安装配置

编译安装:

apt-get update

apt-get install build-essential tcl

wget http://download.redis.io/redis-stable.tar.gz

tar xf redis-stable.tar.gz

cd redis-stable;make;make install

配置文件:

cp /root/work/redis-stable/redis.conf /etc/redis

vi /etc/redis/redis.conf

supervised systemd

dir /data/redis

启动脚本:

vi /etc/systemd/system/redis.service

[Unit]

Description=Redis In-Memory Data Store

After=network.target

[Service]

User=redis

Group=redis

ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf

ExecStop=/usr/local/bin/redis-cli shutdown

Restart=always

[Install]

WantedBy=multi-user.target

用户和组:

adduser --system --group --no-create-home redis

目录和权限:

mkdir /data/redis

chown redis:redis /data/redis

chmod 770 /data/redis

启动和关闭:

systemctl start redis

systemctl status redis

systemctl stop redis

systemctl restart redis

测试redis:

redis-cli

127.0.0.1:6379> ping

PONG

测试都通过后,设置开机启动redis:

systemctl enable redis