当前位置:网站首页>一键部署Redis任意版本
一键部署Redis任意版本
2022-07-07 18:05:00 【靈熙雲】
今天给大家分享一个超级实用的脚本,Linux环境下一键自动安装部署Redis的任意版本,记住是
任意版本哦! 脚本用法:
chmod 755 redis-install.sh && sh redis-install.sh 4.0.10(后面跟的是你需要的版本号,需要什么版本就写什么版本),我这里安装的4.0.10
执行脚本
#! /usr/bin/bash
##redis任何版本全程自动化源码编译安装
##用法: sh redis-install.sh 4.0.10 (后面跟的是你需要的版本号,需要什么版本就写什么版本),我这里安装的4.0.10
version=$1
usage(){
echo "usage: $0 version"
}
if [ $# -ne 1 ]
then
usage
exit -1
fi
#Redis安装包下载
cd /usr/local/src
if [ ! -f redis-${version}.tar.gz ]
then
curl -o /usr/local/src/redis-${version}.tar.gz http://download.redis.io/releases/redis-${version}.tar.gz
fi
#Redis依赖包安装
yum clean all
yum makecache fast
yum -y install gcc gcc-c++ tcl
#编译Redis所需要的gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
source /opt/rh/devtoolset-9/enable
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
gcc --version
##内系统参数核优化
cat >> /etc/rc.d/rc.local << "EOF" ##关闭Linux的THP(内存管理系统)通过使用更大的内存页面,来减少具有大量内存的计算机上的TLB的开销 if [ -f /sys/kernel/mm/transparent_hugepage/enabled ] then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi if [ -f /sys/kernel/mm/transparent_hugepage/defrag ] then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi EOF
chmod u+x /etc/rc.d/rc.local
if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]
then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if [ -f /sys/kernel/mm/transparent_hugepage/defrag ]
then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
cat >> /etc/sysctl.conf << "EOF" #Linux系统内核参数优化 net.core.somaxconn = 2048 net.ipv4.tcp_max_syn_backlog = 2048 vm.overcommit_memory = 1 EOF
sysctl -p
cat > /etc/security/limits.conf << "EOF" root soft nofile 65535 root hard nofile 65535 * soft nofile 65535 * hard nofile 65535 EOF
#Redis编译安装
cd /usr/local/src
tar -zxvf redis-${version}.tar.gz
cd /usr/local/src/redis-${version}
make
make PREFIX=/usr/local/redis install
#Redis基础配置
mkdir -p /usr/local/redis/{
etc,logs,data}
egrep -v "^$|^#" /usr/local/src/redis-${version}/redis.conf > /usr/local/redis/etc/redis.conf
#sed -i "s/bind 127.0.0.1/bind 0.0.0.0/g" /usr/local/redis/etc/redis.conf
sed -i "s/protected-mode yes/protected-mode no/g" /usr/local/redis/etc/redis.conf
sed -i "s/daemonize no/daemonize yes/g" /usr/local/redis/etc/redis.conf
sed -i "s/pidfile \/var\/run\/redis_6379.pid/pidfile \/usr\/local\/redis\/redis.pid/g" /usr/local/redis/etc/redis.conf
sed -i "s/dir \.\//dir \/usr\/local\/redis\/data/g" /usr/local/redis/etc/redis.conf
sed -i "s/logfile \"\"/logfile \"\/usr\/local\/redis\/logs\/redis.log\"/g" /usr/local/redis/etc/redis.conf
sed -i "s/dbfilename dump.rdb/dbfilename dump.rdb/g" /usr/local/redis/etc/redis.conf
sed -i "s/appendfilename \"appendonly.aof\"/appendfilename \"appendonly.aof\"/g" /usr/local/redis/etc/redis.conf
#PATH配置
echo "export PATH=${
PATH}:/usr/local/redis/bin" >>/etc/profile
source /etc/profile
#启动redis服务
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
#查看redis监听端口
netstat -tanp|grep redis
安装流程
执行脚本后开始自动安装redis4.0.10
自动安装Redis4.0.10所需要的的依赖包,如下图所示:
自动开始解压:
开始自动make
开始自动make install
安装完成,Redis服务已成功启动:
到这里整个自动安装脚本已成功执行完毕,我们可以收到通过ps –ef|grep redis来查看服务状态以及监听端口。
测试
登陆redis,执行简单的语句:
边栏推荐
- Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
- SQL common optimization
- 力扣 989. 数组形式的整数加法
- Interpretation of transpose convolution theory (input-output size analysis)
- 力扣 1961. 检查字符串是否为数组前缀
- 关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
- Compiler optimization (4): inductive variables
- CIS芯片测试到底怎么测?
- The project manager's "eight interview questions" is equal to a meeting
- Force buckle 2315 Statistical asterisk
猜你喜欢

Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!

Introduction to bit operation

整型int的拼接和拆分

Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决

mock.js从对象数组中任选数据返回一个数组

编译器优化那些事儿(4):归纳变量

RESTAPI 版本控制策略【eolink 翻译】

干货分享|DevExpress v22.1原版帮助文档下载集合

力扣 599. 两个列表的最小索引总和

openEuler 资源利用率提升之道 01:概论
随机推荐
Data island is the first danger encountered by enterprises in their digital transformation
Sword finger offer II 013 Sum of two-dimensional submatrix
CIS芯片测试到底怎么测?
一锅乱炖,npm、yarn cnpm常用命令合集
Introduction to bit operation
831. KMP string
mock.js从对象数组中任选数据返回一个数组
mock. JS returns an array from the optional data in the object array
Cloud component development and upgrading
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
使用高斯Redis实现二级索引
Mysql, sqlserver Oracle database connection mode
IP 工具类
【Auto.js】自动化脚本
Some important knowledge of MySQL
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
pom. XML configuration file label: differences between dependencies and dependencymanagement
841. String hash
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!