CentOS7最小化安装后的一些常用的工具初始化安装脚本
#!/bin/bash
yum update -y #进行系统更新
if [ $? = 0 ];then
echo "yum update succes!!!"
fi
yum install lrzsz -y #文件传输的工具
if [ $? = 0 ];then
echo "lrzsz install succes"
fi
yum install wget -y #wget安装
if [ $? = 0 ];then
echo "wget install succes"
fi
yum install vim -y #vim编辑工具
if [ $? = 0 ];then
echo "vim install succes"
fi
yum install net-tools -y #net-tools网络工具
if [ $? = 0 ];then
echo "net-tools install succes"
fi
yum install -y #git工具
if [ $? = 0 ];then
echo "net-tools install succes"
fi
MariaDB10.3 数据库安装脚本
#!/bin/bash
R_mariadb='rpm -qa | grep MariaDB'
echo "command(rpm -qa) results are: $R_mariadb"
if [[ $R_mariadb =~ " " ]]
then
echo "MariaDB is not insatall "
else
rpm -e --nodeps MariaDB-*
if [ $? = 0 ]; then
echo "old mariadb is remove"
fi
fi
R_mysql='rpm -qa | grep mysql'
echo "command(rpm -qa) results are: $R_mysql"
if [[ $R_mysql =~ " " ]]
then
echo "MySQL is not insatall "
else
yum remove mysql mysql-server mysql-libs compat-mysql51
if [ $? = 0 ]; then
echo "Remove MySQL "
fi
fi
function create_mariadbrepo(){
V_repo1="[mariadb]"
V_repo2="name = MariaDB"
V_repo3="baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/"
V_repo4="gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB"
V_repo5="gpgcheck=1"
echo $V_repo1 > /etc/yum.repos.d/MariaDB.repo
echo $V_repo2 >> /etc/yum.repos.d/MariaDB.repo
echo $V_repo3 >> /etc/yum.repos.d/MariaDB.repo
echo $V_repo4 >> /etc/yum.repos.d/MariaDB.repo
echo $V_repo5 >> /etc/yum.repos.d/MariaDB.repo
}
create_mariadbrepo
if [ $? = 0 ];then
echo "MariaDB.repo 创建成功!"
fi
rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
if [ $? = 0 ];then
echo "add RPM-GPG-KEY-MariaDB successful!"
fi
yum -y install MariaDB-server MariaDB-client
if [ $? = 0 ];then
echo "MariaDB 安装成功!"
fi
systemctl start mariadb
if [ $? = 0 ];then
echo "MariaDB 启动成功!"
fi
systemctl enable mariadb
if [ $? = 0 ];then
echo "MariaDB 设置开机启动成功!"
fi
flag=true
while($flag)
do
echo -n "是否初始化MariaDB数据库(y/n) -->"
read var
if [[ $var == 'y' || $var == 'n' ]];then
var1=$var
flag=false
fi
done
if [[ $var1 == 'y' ]];then
echo "初始化MariaDB数据库"
mysql_secure_installation
else
echo "安装结束,请手动初始化数据库"
exit;
fi
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有