当前位置:网站首页>(脚本)一键部署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 redis
chmod 755 redis-install.sh && sh redis-install.sh 4.0.10
搜集自网络,仅作参考
边栏推荐
- 企业公司项目开发好一部分基础功能,重要的事保存到线上第一a
- Instructions for go defer
- What is the difference between port mapping and port forwarding
- Hologres Query管理及超时处理
- How to avoid arc generation—— Aafd fault arc detector solves the problem for you
- Is the account opening link of Huatai Securities with low commission safe?
- ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning
- Significance of acrel EMS integrated energy efficiency platform in campus construction
- C语言中sizeof操作符的坑
- P3304 [SDOI2013]直径(树的直径)
猜你喜欢
[IELTS reading] Wang Xiwei reading P4 (matching1)
How long does it take to obtain a PMP certificate?
How to do the project of computer remote company in foreign Internet?
Hong Kong Jewelry tycoon, 2.2 billion "bargain hunting" Giordano
【路径规划】RRT增加动力模型进行轨迹规划
如何避免电弧产生?—— AAFD故障电弧探测器为您解决
Application of multi loop instrument in base station "switching to direct"
Using fast parsing intranet penetration to realize zero cost self built website
"Xiaodeng" domain password policy enhancer in operation and maintenance
Parsing of XML
随机推荐
图解网络:什么是网关负载均衡协议GLBP?
In June, the list of winners of "Moli original author program" was announced! Invite you to talk about the domestic database
XML的解析
Combien de temps faut - il pour obtenir un certificat PMP?
Is it safe to open and register new bonds? Is there any risk? Is it reliable?
IELTS examination process, what to pay attention to and how to review?
如何将自己的代码作品快速存证,已更好的保护自己劳动成果
JS 将伪数组转换成数组
如何报考PMP项目管理认证考试?
Microservice
uniapp 除了数字,其他输入无效
Hologres Query管理及超时处理
P4408 [NOI2003] 逃学的小孩(树的直径)
js如何实现数组转树
Is it safe to open an account in the College of Finance and economics? How to open an account?
Selected cutting-edge technical articles of Bi Ren Academy of science and technology
Robot reinforcement learning synergies between pushing and grassing with self supervised DRL (2018)
Build your own minecraft server with fast parsing
IT转测试岗,从迷茫到坚定我究竟付出了什么?
Pytoch --- use pytoch to realize linknet for semantic segmentation