源码安装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 + 复制的下载链接 例如: ...
随机推荐
- binlog2sql 回滚误操作
参考过在资料: https://github.com/wuyongshenghub/mysqlbinlog2sql https://www.cnblogs.com/xuanzhi201111/p/66 ...
- 【ZJOI2016】大森林
这题理论上可以用ETT,但是用LCT建虚点可以解决这个问题. 对于最晚的操作1建立一个虚点,然后把操作0挂上去. #include<bits/stdc++.h> ; using names ...
- xtraTabControl学习
winform 首先是动态添加page面,并且在page页面上添加一个form窗体 DevExpress.XtraTab.XtraTabPage page = new DevExpress.XtraT ...
- MyBatis 模糊查询 防止Sql注入
#{xxx},使用的是PreparedStatement,会有类型转换,所以比较安全: ${xxx},使用字符串拼接,可以SQL注入: like查询不小心会有漏洞,正确写法如下: Mysql: ...
- iframe的一些介绍
iframe 元素会创建包含另外一个文档的内联框架(即行内框架) 提示:您可以把需要的文本放置在 <iframe> 和 </iframe> 之间,这样就可以应对无法理解 ifr ...
- 自定制Form组件
代码 import re import copy class ValidateError(Exception): def __init__(self,detail): self.detail = de ...
- Search a 2D Matrix——两度二分查找
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...
- matlab安装及使用
matlab R2015b在ubuntu 14.04环境下的安装 挂载及运行安装程序 sudo mkidr /media/matlab mount -o loop matlab_R2015b.iso ...
- 玩转RaspberryPi
step1:烧制树莓派内存卡 可以用[Linux系统烧制]http://www.williamsang.com/archives/1764.html 如果用windows烧制的话,就用Win32 Di ...
- asp.net获取相对文件的绝对路径
HttpContext.Current.Server.MapPath("/sign/");