#!/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初始化实例脚本的更多相关文章

  1. 高级运维(六):源码安装Redis缓存服务、常用Redis数据库操作指令、配置Redis主从服务器

    一.源码安装Redis缓存服务 目标: 本案例要求先快速搭建好一台Redis服务器,并测试该缓存服务器: 1> 设置变量test,值为123 2> 查看变量test的值 3> 设置计 ...

  2. Linux平台下源码安装mysql多实例数据库

    Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...

  3. 搭建LNAMP环境(五)- PHP7源码安装Redis和Redis拓展

    上一篇:搭建LNAMP环境(四)- 源码安装PHP7 一.安装Redis 1.创建redis用户组和用户 groupadd redis useradd -r -g redis -s /sbin/nol ...

  4. CentOS7(Linux)源码安装Redis

    介绍 项目中经常需要用到Redis做缓存数据库,可是还有小伙伴不会在Linux上安装Redis,毕竟我们开发的项目都是要在服务器上运行的,今天就来讲讲如何在CentOS7环境使用源码进行安装Redis ...

  5. centos7 源码安装redis

    安装3.x [root@node1 ~]# yum install wget gcc-c++ make [root@node1 ~]# wget http://download.redis.io/re ...

  6. 源码安装redis环境

    linux下安装redis 1.下载源码,解压包后编译源码: wget http://download.redis.io/releases/redis-2.8.3.tar.gz tar xzf red ...

  7. Linux下源码安装redis,编译安装

    1.下载redis源码 [root@localhost opt]# wget http://download.redis.io/releases/redis-4.0.10.tar.gz 2.解压缩 [ ...

  8. Linux centos7编译源码安装redis

    1.安装准备 ① 由于redis底层用c语言编写的,安装redis需要先将官网下载的源码进行编译,编译依赖make和gcc环境,如果没有则需要安装(一般系统中已经装了了make和gcc,无须再装) 安 ...

  9. Linux 基于源码安装 Redis

    1.下载 Redis: 前往 Redis 官网复制 Redis 相应版本的下载链接,到终端下载 2. 进入到指定目录, 下载 redis.tar.gz 包,运行 wget + 复制的下载链接  例如: ...

随机推荐

  1. supervisor 简单使用

    supervisor是一个c/s系统,被用来在类Unix系统中监控进程状态.supervisor使用python开发. 服务端进程为supervisord,主要负责启动自身及其监控的子进程,响应客户端 ...

  2. ifa_local 和 ifa_address

    ifa_local 和 ifa_address区别联系: 1. 在配置了支持广播的接口上,与IFA_LOCAL一样,同样表示本地ip地址: 2. 对于点对点链路,IFA_ADDRESS表示的是对端的地 ...

  3. memcached和redis区别

    Memcached:是高性能分布式内存缓存服务器,本质是一个内存 key-value 数据库,但不支持数据持久化,服务器关闭后,数据全丢失.只支持 key-value 结构. Redis:将大部分数据 ...

  4. C基础 算法实现层面套路

    引言 - 从实践狗讲起 理论到实践(有了算法到实现) 中间有很多过程. 算法方面本人啥也不懂, 只能说说实现方面. 例如下面 一个普通的插入排序. // // 插入排序默认从大到小 // extern ...

  5. ltsdangerous加密解密

    前言 在做QQ第三方登录时,用户跳转到QQ登录界面登录成功后,会在URL返回一个code参数.前端把code发送给后端.后端收到后,会查询出openid.然后判断openid是否存在,如果存在就可以绑 ...

  6. Nginx-请求处理与响应

    void ngx_http_init_connection(ngx_connection_t *c) { ngx_uint_t i; ngx_event_t *rev; struct sockaddr ...

  7. BlockingQueue drainTo()

    BlockingQueue BlockingQueue的核心方法:放入数据: offer(anObject):表示如果可能的话,将anObject加到BlockingQueue里,即如果Blockin ...

  8. 自定制Form组件

    代码 import re import copy class ValidateError(Exception): def __init__(self,detail): self.detail = de ...

  9. spring-web涉及jar包说明

    <!-- spring-context, spring-aop, spring-beans, spring-core, spring-expression --> <dependen ...

  10. web前端零基础入门学习!前端真不难!

    现在互联网发展迅速,前端也成了很重要的岗位之一,许多人都往前端靠拢,可又无能为力,不知所措,首先我们说为什么在编程里,大家都倾向于往前端靠呢?原因很简单,那就是,在程序员的世界里,前端开发是最最简单的 ...