Redis安装

操作系统 CentOS 7.4 ```` # 设置redis安装目录并进入 mkdir /mnt/redis/ cd /mnt/redis/ # 下载安装包 wget http://down.leimingyun.com/centos/redis-5.0.3.zip # 解压 unzip redis-5.0.3.zip # 编译并将软件安装到指定的目录 make && make install PREFIX=/usr/local/redis # 切换到服务所在目录 cd /usr/local/redis/bin/ # 启动服务 ./redis-server # 配置自启动及后台运行服务 cp /mnt/redis/redis.conf /usr/local/redis/bin/ # 根据配置文件启动服务 ./redis-server redis.conf # 设置开机自启动 touch /etc/systemd/system/redis.service echo '[Unit]'>>/etc/systemd/system/redis.service echo 'Description=redis-server'>>/etc/systemd/system/redis.service echo 'After=network.target'>>/etc/systemd/system/redis.service echo '[Service]'>>/etc/systemd/system/redis.service echo 'Type=forking'>>/etc/systemd/system/redis.service echo 'ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf'>>/etc/systemd/system/redis.service echo 'PrivateTmp=true'>>/etc/systemd/system/redis.service echo '[Install]'>>/etc/systemd/system/redis.service echo 'WantedBy=multi-user.target'>>/etc/systemd/system/redis.service systemctl daemon-reload systemctl start redis.service systemctl enable redis.service # 开机自启动 systemctl enable redis.service ````