redis-3.2.7安装脚本
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安装脚本的更多相关文章
- 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 ...
- 【redis运维】redis自己主动安装脚本(仅仅安装redis)
Redis自己主动安装部署 本文总共分为4个部分: redis自己主动安装脚本文件夹结构说明: redis自己主动安装脚本内容: redis的操作系统服 ...
- Linux下一个Redis启动/关闭/重新启动服务脚本
脚本功能: 实现redis单机多实例情况下的正常启动.关闭.重新启动单个redis实例.完毕系统标准服务的下面经常使用功能: start|stop|status|restart 注:redis程序代 ...
- Redis系列(1)之安装
Redis系列(1)之安装 由于项目的需要,最近需要研究下Redis.Redis是个很轻量级的NoSql内存数据库,它有多轻量级的呢,用C写的,源码只有3万行,空的数据库只占1M内存.它的功能很丰富, ...
- Redis+PHP扩展的安装和Redis集群的配置 与 PHP负载均衡开发方案
以前有想过用 Memcache 实现M/S架构的负载均衡方案,直到听说了 Redis 后才发现它做得更好.发了几天时间研究了一下 Redis ,感觉真的很不错,特整理一下! 以下操作都是在 SUSE ...
- LNMP、LAMP、LANMP一键安装脚本(定期更新)[转]
这个脚本是使用shell编写,为了快速在生产环境上部署LNMP/LAMP/LANMP(Linux.Nginx/Tengine.MySQL/MariaDB/Percona.PHP),适用于CentOS/ ...
- Redis 集群的安装
Redis 集群介绍.特性.规范等Redis 集群的安装(Redis3.0.3 + CentOS6.6_x64)要让 Redis3.0 集群正常工作至少需要 3 个 Master 节点,要想实现高可用 ...
- Redis Sentinel 集群安装 step by step
一. 准备材料 服务器 IP address 操作系统 位数 Redis 版本 CNT06CAH05 192.168.3.47 CentOS 6.5 x64 Redis-3.2.6 sentine ...
- 详细讲解 Redis 的两种安装部署方式
Redis 是一款比较常用的 NoSQL 数据库,我们通常使用 Redis 来做缓存,这是一篇关于 Redis 安装的文章,所以不会涉及到 Redis 的高级特性和使用场景,Redis 能够兼容绝大部 ...
随机推荐
- centos7 yum 安装mysql5.6
这里用科技大学的mysql yum源官方的源太慢 [root@localhost ~]# rpm -ivh http://mirrors.ustc.edu.cn/mysql-repo/mysql-co ...
- socket发送http报文的疑惑(求高手指点一二)
给8080或80端口的服务端(自己写的serverSocket服务端)发送字符串,此字符串按照http协议拼接而成,既是所谓的http报文.服务端接受成功.如果在报头与消息体之间少了“\r\n\r\n ...
- js图的数据结构处理----邻链表,广度优先搜索,最小路径,深度优先搜索,探索时间拓扑
//邻居连表 //先加入各顶点,然后加入边 //队列 var Queue = (function(){ var item = new WeakMap(); class Queue{ construct ...
- js模拟链表
链表: 每个元素,都有一个指针,指向下一个元素 //链表 function LinkedList(){ var head = null; length = 0; this.append = funct ...
- SpringMVC项目模块浅析
本文为个人笔记,对于springmvc模块的规划,仁者见仁.智者见智,请不要生搬硬套. 一.基础模块-basic 主要内容是dao.spring-xml.domain.service等内容,模块内分层 ...
- cocos2d-x JS 利用重复动作实现动画播放(实现倒计时)
cocos2d-js: cc.delayTime() and cc.repeatForever() don't work together in cc.sequence() this.numm = 1 ...
- (已解决)Xcode 运行报错: clang: error: unknown argument: '-websockets'
报错内容: 解决办法:
- Oracle 11g快速收集全库统计信息
环境:Oracle 11.2.0.4 采用并行的方式,快速收集全库统计信息,多用于跨版本升级之后,对全库的统计信息重新进行快速收集: --开启计时 set timing on --设置并行收集 exe ...
- mybatis之注解式开发之关联查询
package com.bjsxt.mapper; import org.apache.ibatis.annotations.Select; import com.bjsxt.pojo.Clazz; ...
- HDU 1757 A Simple Math Problem(矩阵)
A Simple Math Problem [题目链接]A Simple Math Problem [题目类型]矩阵快速幂 &题解: 这是一个模板题,也算是入门了吧. 推荐一个博客:点这里 跟 ...