源码安装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 + 复制的下载链接 例如: ...
随机推荐
- LINUX中断学习笔记【转】
转自:http://blog.chinaunix.net/uid-14825809-id-2381330.html 1.中断的注册与释放: 在 , 实现中断注册接口: int request_irq( ...
- Oracle 表连接方式
1.嵌套循环联结(NESTED LOOPS)2.哈希联结(HASH JOIN)3.排序合并联结(MERGE JOIN)4.半联结(in/exists)5.反联结(not in/not exists)6 ...
- popup menu案例,无说明只代码
效果图: 布局文件, 展示列表的容器 <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...
- [bugfix]copy属性参数将NSMutableArray变为NSArray类型
问题:NSMutableArray 声明为 copy 属性参数后即使接受NSMutableArray变量依然为NSArray变量 测试: 属性申明为: 1 @property (nonatomic, ...
- Freemarker中JS取Data-model的值的问题
不能在表达式中使用js变量,比如: var key = 1; var value = "${stateMap[key]}"; 因为Freemarker是在服务器端进行解析的,此时j ...
- 提高C#编程水平的50个要诀
一篇旧时的文章,看后觉得还可以,特别贴出来. 提高C#编程水平的50个要点: .总是用属性 (Property) 来代替可访问的数据成员 .在 readonly 和 const 之间,优先使用 rea ...
- 遇见Python.h: No such file or directory的解决方法
出现No such file or directory的错误,有两种情况,一种是没有Python.h这个文件,一种是Python的版本不对, 可以进入/usr/include/文件夹下的Pythonx ...
- mysql ERROR 1366
mysql ERROR 1366 mysql> INSERT INTO tb_room VALUES ('9101','9','1',300,'9101',0,1,'超级豪华间','public ...
- JavaScript 闭包(随笔)
闭包,伟大的闭包.... 先看看百科对百度的定义是什么样的. 百科说:闭包是指可以包含自由(未绑定到特定对象)变量的代码块:这些变量不是在这个代码块内或者任何全局上下文中定义的,而是在定义代码块的环境 ...
- STL模板整理 Binary search(二分查找)
前言: 之前做题二分都是手动二分造轮子,用起来总是差强人意,后来看到STL才发现前辈们早就把轮子造好了,不得不说比自己手动实现好多了. 常用操作 1.头文件 #include <algorith ...