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 能够兼容绝大部 ...
随机推荐
- [LeetCode] 339. Nested List Weight Sum_Easy tag:DFS
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- react 基本配置使用
react入门的一些配置 安装和启动 npm install -g create-react-app create-react-app my-app cd my-app npm start 创建 t ...
- 10 Free Image Hosting Sites for Your Photos
https://www.lifewire.com/free-image-hosting-sites-3486329 Wondering if there are there any good site ...
- Elasticsearch5.x创建索引(Java)
索引创建代码使用官方给的示例代码,我把它在java项目里实现了一遍. 官方示例 1.创建索引 /** * Java创建Index */ public void CreateIndex() { int ...
- webpack1.0--图片
- iOS 开发笔记 - 开发中如何实现自动检测更新APP
1.获取当前项目APP版本号 2.拿到AppStore项目版本号 3.对比版本号,实现更新功能 直接上代码: #import "ViewController.h" //1一定要先配 ...
- android获取通讯记录,sim卡和手机
//获取手机和手机卡通讯录 public static String getContacts() { String szContacts = ""; szContacts=getP ...
- (已解决)cocos2d-x 运行时xcode提示错误:"vtable for XXX", referenced from;
vtable/引用和虚函数相关,今天在添加一个层的时候报了这个错误,很低级的错误,忘了实现虚函数了(谨记!!) 若如果实现了虚函数还依然如此的话,可能是创建的时候忘了钩上 -desktop 选项了,把 ...
- html网页什么样的字体最好看,css设置各种中文字体样式代码
css代码如下:{ font-family:"Microsoft YaHei",微软雅黑,"MicrosoftJhengHei",华文细黑,STHeiti,Mi ...
- mybatis运行原理
mybatis运行原理 运行过程中涉及到的类或者接口 Resources(c) :用于加载mybatis核心配置文件 XMLConfigBuilder(c) :用于解析xml文件(核心配置文件) Co ...