源码安装redis初始化实例脚本
#!/bin/bash -
#Date: --
#Auth: Jin version='2.8.7'
progname='redis'
pkgname="${progname}-${version}"
pkgfilename="${pkgname}.tar.gz"
installdir="/usr/local/${progname}"
logdir="/var/log/${progname}"
installbindir="${installdir}/bin"
installetcdir="${installdir}/etc"
datadir='/data/redis'
binfile='redis-server redis-cli redis-check-aof redis-check-dump redis-benchmark redis-sentinel' function install_redis() {
test -f /etc/redhat-release && PKGM=yum || PKG=zypper
${PKGM} install gcc wget
### create base dir ###
mkdir -p ${datadir}
mkdir -p ${installbindir}
mkdir -p ${installetcdir}
### down and copy bin ###
mkdir -p ~root/Downloads/ && cd ~root/Downloads/
test -f ${pkgfilename} || wget http://download.redis.io/releases/${pkgfilename} && tar -zxvf ${pkgfilename} && cd ${pkgname}
make MALLOC=libc && find ./src -perm -exec cp {} ${installbindir}/ \;
#for i in ${binfile};do
# cp ${i} ${installbindir}/ && echo "Install $i OK"
#done
### config file ###
cp ./redis.conf ${installetcdir}/ && echo "Install redis.conf OK"
### kernel option of ram is low ###a
#echo 'vm.overcommit_memory=1' >> /etc/sysctl.conf && sysctl -p /etc/sysctl.conf
} function config_instance(){
if [ $# -eq ];then
port=$
else
echo 'Please give instance port!'
exit
fi grep -vE '^$|^#' ${installetcdir}/redis.conf > ${installetcdir}/${port}.conf
#set port number
sed -i /port/s//${port}/ ${installetcdir}/${port}.conf
#enable daemonize
sed -i /daemonize/s/no/yes/ ${installetcdir}/${port}.conf
#set pid with port number
sed -i /pidfile/s/redis.pid/redis-${port}.pid/ ${installetcdir}/${port}.conf
#data
mkdir -p ${datadir}/${port}
sed -i "/dir/s/\.\//\/data\/redis\/${port}/" ${installetcdir}/${port}.conf
#set logfile with port number
#LOG非绝对路径,则放在数目录下
sed -i "/logfile/s/\"\"/${port}\.log/" ${installetcdir}/${port}.conf
##start intance
cd ${installdir} && ${installbindir}/redis-server ${installetcdir}/${port}.conf
} function uninstall_redis() {
rm -rf ${datadir} && echo "Clean ${datadir} OK"
rm -rf ${installdir} && echo "Clean ${installdir} OK"
} #main
if [ $# -ge ];then
if [ $ = 'install' ];then
echo 'Install'
install_redis
elif [ $ = 'uninstall' ];then
uninstall_redis
elif [ $ = 'confinstance' ];then
if [ $# -eq ];then
port=$
config_instance $port
else
echo "Please give a instance port!"
fi
else
echo "Usage: ${0} {install|uninstall|confinstance [portnumber]}"
fi
else
echo "Usage: ${0} {install|uninstall|confinstance [portnumber]}"
fi
源码安装redis初始化实例脚本的更多相关文章
- 高级运维(六):源码安装Redis缓存服务、常用Redis数据库操作指令、配置Redis主从服务器
一.源码安装Redis缓存服务 目标: 本案例要求先快速搭建好一台Redis服务器,并测试该缓存服务器: 1> 设置变量test,值为123 2> 查看变量test的值 3> 设置计 ...
- Linux平台下源码安装mysql多实例数据库
Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...
- 搭建LNAMP环境(五)- PHP7源码安装Redis和Redis拓展
上一篇:搭建LNAMP环境(四)- 源码安装PHP7 一.安装Redis 1.创建redis用户组和用户 groupadd redis useradd -r -g redis -s /sbin/nol ...
- CentOS7(Linux)源码安装Redis
介绍 项目中经常需要用到Redis做缓存数据库,可是还有小伙伴不会在Linux上安装Redis,毕竟我们开发的项目都是要在服务器上运行的,今天就来讲讲如何在CentOS7环境使用源码进行安装Redis ...
- centos7 源码安装redis
安装3.x [root@node1 ~]# yum install wget gcc-c++ make [root@node1 ~]# wget http://download.redis.io/re ...
- 源码安装redis环境
linux下安装redis 1.下载源码,解压包后编译源码: wget http://download.redis.io/releases/redis-2.8.3.tar.gz tar xzf red ...
- Linux下源码安装redis,编译安装
1.下载redis源码 [root@localhost opt]# wget http://download.redis.io/releases/redis-4.0.10.tar.gz 2.解压缩 [ ...
- Linux centos7编译源码安装redis
1.安装准备 ① 由于redis底层用c语言编写的,安装redis需要先将官网下载的源码进行编译,编译依赖make和gcc环境,如果没有则需要安装(一般系统中已经装了了make和gcc,无须再装) 安 ...
- Linux 基于源码安装 Redis
1.下载 Redis: 前往 Redis 官网复制 Redis 相应版本的下载链接,到终端下载 2. 进入到指定目录, 下载 redis.tar.gz 包,运行 wget + 复制的下载链接 例如: ...
随机推荐
- 【Python学习笔记】有关包的基本知识
python的包(package)是一个有层次的文件目录结构.它定义了一个由模块和子包组成的Python应用程序执行环境. AAA/ __init__.py bbb.py CCC/ __init__. ...
- 【Python学习笔记】Coursera课程《Python Data Structures》 密歇根大学 Charles Severance——Week6 Tuple课堂笔记
Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week6 Tuple 10 Tuples 10.1 Tuples A ...
- ogre3d环境配置 SDK安装配置及简单事例教程
ogre3d环境配置 SDK安装配置及简单事例教程 http://www.cr173.com/html/22594_1.html ogre3d环境配置 SDK安装配置及简单事例教程 http://ww ...
- linux和ubuntu防火墙相关命令
1.永久有效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2.即刻生效 开启: service iptables start 关闭: se ...
- sicily 1153. 马的周游问题
一.题目描述 在一个8 * 8的棋盘中的某个位置有一只马,如果它走29步正好经过除起点外的其他位置各一次,这样一种走法则称马的周游路线,试设计一个算法,从给定的起点出发,找出它的一条周游路线. 为了便 ...
- 关闭自动弹出照片自动弹出iTunes以及关闭手机照片流
关闭自动弹出照片自动弹出iTunes以及关闭手机照片流 如何阻止iPhone连接Mac后自动弹出照片? 时间:2015/6/18 17:07:15来源:本站原创作者:Chenjh我要评论 很多新 iP ...
- MySQL的读写分离---主从复制、主主复制
1.复制是基于BinLog日志 存在三种日志格式:Statement:存储Sql语句,存储日志量是最小的.有可能复制不一致Row:存储event数据,存储日志量大,但是不能很直接进行读取:Mixed: ...
- Python VUE 基础知识
一 什么是VUE 它是一个构建用户界面的JavaScript框架,自动生成(js,css,HTML文件) 二 如何使用VUE 1. 应用vues.js <script src="vu ...
- git+jenkins在windows机器上新建一个slave节点【转载】
转至博客:上海-悠悠 前言 我们在跑自动化项目的时候,希望有单独的测试机能跑自动化项目,并且能集成到jenkins上构建任务.如果公司已经有jenkins环境了,那无需重新搭建. 只需在现有的平台基础 ...
- Oracle数据库共享内存分配不足问题的解决
问题: ORA-: unable to allocate bytes of shared memory ("shared pool,)","session param v ...