博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
redis 安装脚本
阅读量:6853 次
发布时间:2019-06-26

本文共 1260 字,大约阅读时间需要 4 分钟。

#!/usr/bin/env bash

set -e
set -x
REDISVERSION=4.0.1
WORKSPACE=/tmp
if [ $# -eq 1 ]; then
echo 'Redis version unspecified, use default: 4.0.1'
REDISVERSION=$1
fi
apt-get update
apt-get install -y tcl build-essential

#add redis user

groupadd redis
useradd redis -g redis -s /usr/sbin/nologin

#workspace

mkdir -p /etc/redis /data/redis /var/log/redis

#install

wget -O $WORKSPACE/redis-$REDISVERSION.tar.gz
tar xf $WORKSPACE/redis-$REDISVERSION.tar.gz -C $WORKSPACE
cd $WORKSPACE/redis-$REDISVERSION && make && make test && make install
cp $WORKSPACE/redis-$REDISVERSION/*.conf /etc/redis

#configuration

sed -i 's/127.0.0.1/0.0.0.0/g' /etc/redis/redis.conf
sed -i '/^logfile/c logfile "/var/log/redis/redis.log"' /etc/redis/redis.conf
sed -i '/^dir .\//c dir \/data\/redis\/' /etc/redis/redis.conf

cat << EOF > /lib/systemd/system/redis.service

[Unit]
Description=Redis Server
After=network.target

[Service]

User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli -p 6379 shutdown

[Install]

WantedBy=multi-user.target
EOF

#startup

chown -R redis.redis /etc/redis /data/redis /var/log/redis
systemctl daemon-reload
systemctl enable redis
systemctl start redis

转载于:https://blog.51cto.com/jinliang/2107176

你可能感兴趣的文章
Java NIO简易聊天室(一)
查看>>
PHP加密扩展库mcrypt安装及应用技巧
查看>>
APC网络智能卡配置管理
查看>>
【虚拟化实战】存储设计之三MultiPathing
查看>>
在RHEL5下搭建SSH远程登录服务器
查看>>
使用Moblin SDK开发应用程序 -- Image Creator
查看>>
【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记14 视图绘制Demo
查看>>
/dev/null &
查看>>
在Ubuntu上安装Node.js的Upstream版本
查看>>
扩展GridView控件(8) - 导出数据源的数据为Excel、Word或Text
查看>>
CISCO路由器配置基础(3)
查看>>
linux下通过串口登陆交换机
查看>>
微信公众平台群发规则说明
查看>>
LINUX下直接使用ISO文件
查看>>
第四章 apache的工作模式
查看>>
mysql备份和恢复总结
查看>>
软件明明已经删除 控制面板里还有名称
查看>>
深入浅出的SQL server 查询优化
查看>>
Hyper-V vNext新的虚拟机配置文件、配置版本
查看>>
通俗易懂,各常用线程池的执行 流程图
查看>>