本文主要是介绍第二章 Redis-6.2.1脚本安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#!/usr/bin/bash
# Author:jh
# Time:2021-04-19 17:23:05
# Name:redis-install.sh
# Version: 1.0
# Discription: To
#1.设置变量
data_dir=/data/redis
software_dir=/opt/software
redsis_config_dir=/etc/redis
reids_rely_software=(cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make tcl)
#2.创建目录
mkdir $data_dir
mkdir $software_dir -p
mkdir $redsis_config_dir
#3.下载redis安装包
cd $software_dir
wget https://download.redis.io/releases/redis-6.2.1.tar.gz
#4.安装依赖
for i in ${reids_rely_software[*]}
do
rpm -q $i &>/dev/null
if [ $? -eq 0 ];then
echo "$i is installed"
else
yum -y install $i &>/dev/null
action "$i is installing" /usr/bin/true
fi
done
#5.更新gcc版本
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
#6.编译安装
tar zxf redis-6.2.1.tar.gz -C /opt/
cd /opt/redis-6.2.1/
make && make install
#7.修改配置文件
cp redis.conf /etc/redis/
#8.配置system启动
cat >/etc/systemd/system/redis.service<<EOF
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
ExecStart=/opt/redis-6.2.1/src/redis-server /etc/redis/redis.conf
#ExecReload=/opt/redis-6.2.1/src/redis-server -s reload
#ExecStop=/opt/redis-6.2.1/src/redis-server -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
#9.重启redis
systemctl daemon-reload
systemctl enable redis.service
systemctl restart redis
#10.查看服务状态
systemctl status redis
netstat -lntp
```bash
这篇关于第二章 Redis-6.2.1脚本安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!