源码安装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 + 复制的下载链接 例如: ...
随机推荐
- Exploring Qualcomm's TrustZone Implementation
转自 http://bits-please.blogspot.com/2015/08 (需要FQ, 狗日的墙) In this blog post, we'll be exploring Qua ...
- python基础===PEP网站,代码规范指南
PEP 8是最古老的PEP之一,它向Python程序员提供了代码格式设置指南.PEP 8的篇幅很长,但大都与复杂的编码结构相关. https://python.org/dev/peps/pep-000 ...
- Linux(Unix)密码策略问题导致root密码不能修改
Linux(Unix)密码策略问题导致root密码不能修改 发布时间: 2016-01-19 浏览次数: 1034 下载次数: 5 用户修改了密码配置文件,导致root账户修改密码时报如下错误: ...
- 【bzoj4765】普通计算姬
一道奇奇怪怪的数据结构题? 把树线性化,然后分块维护吧. 为了加速,求和用树状数组维护每个块的值. #include<bits/stdc++.h> #define N 100010 #de ...
- C++内存管理(转)
C++内存管理比较好的文章,参考链接如下: C++内存管理
- ie6、ie7下overflow失效
如果父对象有overflow:hidden属性,子对象中的position属性是relative或者absolute, 那么在ie6和ie7下父对象的overflow会失效,解决办法是给父对象加rel ...
- jenkins上展示html报告【转载】
转至博客:上海-悠悠 前言 在jenkins上展示html的报告,需要添加一个HTML Publisher plugin插件,把生成的html报告放到指定文件夹,这样就能用jenkins去读出指定文件 ...
- python IDE的配置
本人使用过的两款,系统环境ubuntukylin 15.04 jupyter 主要参考:ref1 和 ref2 遇到问题: error: [I 21:48:41.947 NotebookApp] Wr ...
- 不断学习UI框架的写法
在web开发的过程中,我们会需要用到很多大大小小的插件,比如文本框,下拉树,下拉框等等各种各样的都需要.或许在开发的网页中会用到同一种插件来满足各种各样复杂的业务逻辑,比如简单的一个下拉树,有的地方需 ...
- mysql数据库设置远程连接权限
原文 问题现象 mysql 安装完毕,本机登录正常,在远程输入正确账号密码登录连接时报错如下 问题原因 远程IP没有登录权限,root用户默认只能在localhost也就是只能在本机登录,需要设置允许 ...