redis-3.2.7 安装脚本 for CentOS 6.5

#!/bin/bash
#Filename: inst_for_redis.sh
#Version: 1.1
#Lastdate: 2017/07/25
#Author: wangshenjin<wangshenjin233@foxmail.com>
#Description: auto install redis export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin VERSION="3.2.7"
PORT="6001"
BASEDIR="/usr/local/redis"
DATADIR="/data/database/redis${PORT}"
LOGDIR="/data/logs/redis"
PIDDIR="/var/run/redis"
REQUIREPASS=`cat /dev/urandom | head -10 | md5sum | head -c8`
REDISUSER="redis" Init_Env() {
yum -y install tcl-8.5* make gcc gcc-c++
[ "$?" -ne 0 ] && echo -e "\n [`date +%Y-%m-%d" "%H:%m:%S`] Install depend soft error.\n" && exit [ -d "${DISTDIR}" ] || mkdir -p ${DISTDIR}
[ -d "${DATADIR}" ] || mkdir -p ${DATADIR}
[ -d "${LOGDIR}" ] || mkdir -p ${LOGDIR}
[ -d "${PIDDIR}" ] || mkdir -p ${PIDDIR}
} Install_Redis() { groupadd ${REDISUSER}
useradd -g ${REDISUSER} -s /sbin/nologin ${REDISUSER} cd /dist/src
if [ ! -d "redis-${VERSION}" ] ; then
[ -f "/dist/dist/redis-${VERSION}.tar.gz" ] || wget http://download.redis.io/releases/redis-${VERSION}.tar.gz -O /dist/dist/redis-${VERSION}.tar.gz
tar xf /dist/dist/redis-${VERSION}.tar.gz
fi cd redis-${VERSION}
make MALLOC=libc
[ "$?" -ne 0 ] && echo -e "\n [`date +%Y-%m-%d" "%H:%m:%S`] Make redis error.\n" && exit mkdir ${BASEDIR}/{bin,etc} -p
mkdir ${DATADIR} -p
cp redis.conf ${BASEDIR}/etc/redis_default.conf
cd src
cp redis-server redis-cli redis-benchmark ${BASEDIR}/bin/
ln -s ${BASEDIR}/bin/* /usr/local/bin/
chown ${REDISUSER}:${REDISUSER} -R ${BASEDIR}
chown ${REDISUSER}:${REDISUSER} -R ${DATADIR}
chown ${REDISUSER}:${REDISUSER} -R ${LOGDIR}
chown ${REDISUSER}:${REDISUSER} -R ${PIDDIR} cat > $BASEDIR/etc/redis${PORT}.conf << EOF
daemonize yes
pidfile ${PIDDIR}/redis${PORT}.pid
port ${PORT}
bind 127.0.0.1
timeout 300 loglevel notice
logfile ${LOGDIR}/redis${PORT}.log
syslog-enabled no databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis${PORT}.rdb
appendfilename redis${PORT}.aof
dir ${DATADIR}
appendonly yes
appendfsync everysec requirepass $REQUIREPASS
no-appendfsync-on-rewrite no
set-max-intset-entries 512
activerehashing yes
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
EOF } Create_Scripts() {
cat > /root/redis_start << EOF
chown redis:redis -R ${LOGDIR}
su - ${REDISUSER} -s /bin/bash -c "${BASEDIR}/bin/redis-server ${BASEDIR}/etc/redis${PORT}.conf"
EOF cat > /root/redis_stop << EOF
${BASEDIR}/bin/redis-cli -h 127.0.0.1 -p ${PORT} -a ${REQUIREPASS} save
sleep 5s
${BASEDIR}/bin/redis-cli -h 127.0.0.1 -p ${PORT} -a ${REQUIREPASS} shutdown
EOF cat > /root/redis_login << EOF
${BASEDIR}/bin/redis-cli -h 127.0.0.1 -p ${PORT} -a ${REQUIREPASS}
EOF chmod 700 /root/redis_* if /root/redis_start ; then
echo -e "\n Help:"
echo -e "\n Base dir: ${BASEDIR}."
echo -e "\n Data dir: ${DATADIR}."
echo
else
echo -e "\n [`date +%Y-%m-%d" "%H:%m:%S`] Redis start error. \n"
fi
} ##################### Main ########################## Init_Env
Install_Redis
Create_Scripts

redis-3.2.7安装脚本的更多相关文章

  1. redis 5.0.5 安装

    redis 5.0.5 安装脚本: #!/bin/bash cd /data/src/ test -e tcl8.6.9-src.tar.gz || wget http://downloads.sou ...

  2. 【redis运维】redis自己主动安装脚本(仅仅安装redis)

    Redis自己主动安装部署 本文总共分为4个部分:         redis自己主动安装脚本文件夹结构说明:         redis自己主动安装脚本内容:         redis的操作系统服 ...

  3. Linux下一个Redis启动/关闭/重新启动服务脚本

    脚本功能: 实现redis单机多实例情况下的正常启动.关闭.重新启动单个redis实例.完毕系统标准服务的下面经常使用功能:  start|stop|status|restart 注:redis程序代 ...

  4. Redis系列(1)之安装

    Redis系列(1)之安装 由于项目的需要,最近需要研究下Redis.Redis是个很轻量级的NoSql内存数据库,它有多轻量级的呢,用C写的,源码只有3万行,空的数据库只占1M内存.它的功能很丰富, ...

  5. Redis+PHP扩展的安装和Redis集群的配置 与 PHP负载均衡开发方案

    以前有想过用 Memcache 实现M/S架构的负载均衡方案,直到听说了 Redis 后才发现它做得更好.发了几天时间研究了一下 Redis ,感觉真的很不错,特整理一下! 以下操作都是在 SUSE  ...

  6. LNMP、LAMP、LANMP一键安装脚本(定期更新)[转]

    这个脚本是使用shell编写,为了快速在生产环境上部署LNMP/LAMP/LANMP(Linux.Nginx/Tengine.MySQL/MariaDB/Percona.PHP),适用于CentOS/ ...

  7. Redis 集群的安装

    Redis 集群介绍.特性.规范等Redis 集群的安装(Redis3.0.3 + CentOS6.6_x64)要让 Redis3.0 集群正常工作至少需要 3 个 Master 节点,要想实现高可用 ...

  8. Redis Sentinel 集群安装 step by step

    一. 准备材料 服务器 IP address 操作系统 位数 Redis 版本   CNT06CAH05 192.168.3.47 CentOS 6.5 x64 Redis-3.2.6 sentine ...

  9. 详细讲解 Redis 的两种安装部署方式

    Redis 是一款比较常用的 NoSQL 数据库,我们通常使用 Redis 来做缓存,这是一篇关于 Redis 安装的文章,所以不会涉及到 Redis 的高级特性和使用场景,Redis 能够兼容绝大部 ...

随机推荐

  1. Pycharm增加新安装Python的路径

    Pycharm默认的Python是python2,但是如果代码是python3写的,就需要在pycharm里的project interpreter增加python3 注意,一定要找到Project ...

  2. 谷歌启用抓取JavaScript,应对方案!

    谷歌启用了抓取JavaScript来深入了解网站,这样,如果网站或黑页是加了跳转代码或判断代码,很有可能将会被识别出来.虽然目前只是谷歌启用识别JavaScript文件,但国内搜索引擎很可能也会跟着模 ...

  3. git安装和使用(二)

    一.git安装 1.目的 通过git管理github托管项目代码 2.下载安装 Git - Downloading Package​www.git-scm.com 点击桌面,右击鼠标,出现两个git单 ...

  4. cocos2d-X JS 获取cocostudio中的UI组件

    1.先加载cocostudio导出的json文件,代码如下所示: var dong = ccs.load("res/Login.json"); //_login.setPositi ...

  5. ajax提交完表单数据依然跳转的解决办法

    1. 既然ajax提交数据,就把表单里面submit按钮换掉,因为触发submit他就会跳转页面 提交的时候他会先触发ajax 再触发submit的提交 2.如果确定了表单没有submit,那么把提交 ...

  6. LeetCode28.实现strStr()

    实现 strStr() 函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始).如果不存在,则返 ...

  7. EL的隐含对象(一)【页面上下文对象】

    页面上下文对象为pageContext,用于访问JSP内置对象(例如:request.response.out.session.exception.page等)和ServletContext.在获取到 ...

  8. c# Mongodb批量更新

    public void Put(List<OnlineItem> datas)         {             try             {                ...

  9. Java包装

    public class Test2 { public static void main(String[] args) { /*String str = "..............&qu ...

  10. arm trustzone

    arm的trustzone并不涉及到具体的crypto算法,只是实现: 1) 敏感信息的安全存储: 2) 控制bus和debug的安全访问,保证信息不被泄露: trustzone是system_lev ...