当前位置:网站首页>(脚本)一键部署redis任意版本 —— 筑梦之路
(脚本)一键部署redis任意版本 —— 筑梦之路
2022-07-05 00:05:00 【筑梦之路】
#!/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 redischmod 755 redis-install.sh && sh redis-install.sh 4.0.10
搜集自网络,仅作参考
边栏推荐
- Business implementation - the log is written to the same row of data
- Best practice case of enterprise digital transformation: introduction and reference of cloud based digital platform system security measures
- In the enterprise, win10 turns on BitLocker to lock the disk, how to back up the system, how to recover when the system has problems, and how to recover quickly while taking into account system securi
- Application of multi loop instrument in base station "switching to direct"
- If you open an account of Huatai Securities by stock speculation, is it safe to open an account online?
- The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
- PMP certificate renewal process
- Design of emergency lighting evacuation indication system for urban rail transit station
- 取得PMP证书需要多长时间?
- 挖财学院开户安全的吗?开户怎么开?
猜你喜欢

企业公司项目开发好一部分基础功能,重要的事保存到线上第一a

同事的接口文档我每次看着就头大,毛病多多。。。

ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning

【雅思阅读】王希伟阅读P3(Heading)

Pytoch --- use pytoch to realize linknet for semantic segmentation
![[paper reading] cavemix: a simple data augmentation method for brain vision segmentation](/img/41/eb790e7419a158e985fa503bd7dc17.png)
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation

华为200万年薪聘请数据治理专家!背后的千亿市场值得关注

Jar batch management gadget
![[论文阅读] CarveMix: A Simple Data Augmentation Method for Brain Lesion Segmentation](/img/41/eb790e7419a158e985fa503bd7dc17.png)
[论文阅读] CarveMix: A Simple Data Augmentation Method for Brain Lesion Segmentation

Acrel-EMS综合能效平台在校园建设的意义
随机推荐
Continuous modification of business scenario functions
IELTS examination process, what to pay attention to and how to review?
Combien de temps faut - il pour obtenir un certificat PMP?
Expand your kubecl function
Power operation and maintenance cloud platform: open the new mode of "unattended and few people on duty" of power system
Illustrated network: what is gateway load balancing protocol GLBP?
AcWing164. 可达性统计(拓扑排序+bitset)
JS convert pseudo array to array
[论文阅读] TUN-Det: A Novel Network for Thyroid Ultrasound Nodule Detection
PaddleOCR教程
MIT-6.824-lab4B-2022(万字思路讲解-代码构建)
基本放大电路的学习
Meet ThreadPoolExecutor
How to apply for PMP project management certification examination?
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation
基于三维gis平台的消防系统运用
How to reduce the stock account Commission and stock speculation commission? Is it safe to open an online account
他做国外LEAD,用了一年时间,把所有房贷都还清了
S32 design studio for arm 2.2 quick start
The pit of sizeof operator in C language