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. 日志文件系统syslog,syslog-ng

    日志文件系统syslog,syslog-ng   余二五 2017-11-07 20:37:00 浏览127 评论0 日志 LOG 配置 主机 正则表达式 syslog 表达式 source file ...

  2. sublime使用经验汇总

    1. source insight 会对某个修改频繁的文件做多次备份.我们用sublime进行多个文件搜索时,需要把备份的文件排除在外. e:\work\code\sourcev, *.h, *.cp ...

  3. Linux-nmon系统性能监控工具的使用及报表产出

    在进行性能测试的时候,需要获取服务器的各项指标,例如 CPU.MEM.I/O.DISK 等.网上有很多的监控工具,nmon 就是其中的一个,其可与 JMeter结合使用,测试系统的性能.其概要的介绍, ...

  4. cocos2d JS-(JavaScript) 动态生成方法的例子

    function User(properties) { for (var i in properties) { (function (which) { var p = i; which["g ...

  5. openCV学习——一、图像读取、显示、输出

    openCV学习——一.图像读取.显示.输出   一.Mat imread(const string& filename,int flags=1),用于读取图片 1.参数介绍 filename ...

  6. bat cmd 删除文件或文件夹 删除注册表

    @echo off rd "C:\Documents and Settings\Administrator\桌面\新建文件夹" del 是用来删除文件的,删除文件夹的命令是rd 注 ...

  7. python爬虫-基础入门-python爬虫突破封锁

    python爬虫-基础入门-python爬虫突破封锁 >> 相关概念 >> request概念:是从客户端向服务器发出请求,包括用户提交的信息及客户端的一些信息.客户端可通过H ...

  8. 集体干死java 在启动.sh

    #!/bin/bash#reboot .jar#author wangdonghuipid=`ps -ef |grep java |awk '{print $2}'`echo $pidecho'--- ...

  9. aop编程之后置通知,环绕通知和异常通知

    ---恢复内容开始--- 此将实例将在上一讲前置通知的基础上进行配置,前置配置内容:http://www.cnblogs.com/lihuibin/p/7955947.html  具体流程如下: 1. ...

  10. Git常用的命令

    常用 Git 命令清单   作者: 阮一峰 日期: 2015年12月 9日 原文地址:http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.ht ...