栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

shell脚本实战:linux系统初始化和mysql8.0编译安装

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

shell脚本实战:linux系统初始化和mysql8.0编译安装

linux系统初始化脚本
#!/bin/bash
#version v1
#author: xingdian
cat <<-eof
===========================
=    a:关闭防火墙         =
=    b:关闭selinux        =
=    c:网络连通性检测     =
=    d:配置yum仓库        =
=    q:退出               =
===========================
eof
read -p "请输入你内容:" var
case $var in
a)
	systemctl stop firewalld && systemctl disable firewalld
	if [ $? -eq 0 ];then
		echo "firewalld is disabled"
	else
		echo "firewalld is not disabled"
		exit
	fi
;;
b)
	sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config
	setenforce 0
;;
c)
	ping -c1 www.baidu.com &>/dev/null
	if [ $? -eq 0 ];then
		echo "network is successful"
	else
		echo "network is not successful"
	fi
;;
d)
	rm -rf /etc/yum.repos.d/*
	curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo &>/dev/null
#	curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo &>/dev/null
	wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo &>/dev/null
	if [ $? -eq 0 ];then
		echo "yum is successful"
	else
		yum -y install wget &>/dev/null
		wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo &>/dev/null
	fi
;;
q)
	exit
;;
*)
	echo "请输入正确的参数,参考上面的提示!"
esac
mysql8.0编译安装
#!/bin/bash
#xingdian
mem_all(){
	all=`free -m | awk NR==2'{print $2}'`
	if [ $all -ge 2048 ];then
		echo "mem is ok!"
	else
		echo "mem is low!"

		exit
	fi
}

ping_baidu(){
	ping -c1 www.baidu.com &>/dev/null
	if [ $? -eq 0 ];then
		echo " network is successful!"
	else
		echo " network is dead!"
		exit
	fi
}
yum_repo(){
	rm -rf /etc/yum.repos.d/*
	curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
	curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
	yum clean all &>/dev/null
	yum makecache fast &>/dev/null
	yum repolist &>/dev/null
	if [ $? -eq 0 ];then
		echo "yum is successful"
	else
		echo "yum is dead"
		exit
	fi
}
yum_env(){
	yum install -y wget libaio-devel libaio ncurses-devel ncurses readline-devel.x86_64 readline.x86_64 openssl openssl-devel make &>/dev/null
	yum  -y install centos-release-scl &>/dev/null
	yum -y install devtoolset-10-gcc devtoolset-10-gcc-c++ devtoolset-10-binutils &>/dev/null

}
cmake_safe(){
#	wget https://github.com/Kitware/CMake/releases/download/v3.23.0-rc4/cmake-3.23.0-rc4-linux-x86_64.sh
	if [ -f cmake-3.23.0-rc4-linux-x86_64.sh ];then
		chmod a+x cmake-3.23.0-rc4-linux-x86_64.sh
		bash cmake-3.23.0-rc4-linux-x86_64.sh --prefix=/usr/local
		echo "export PATH=$PATH:/usr/local/cmake-3.23.0-rc4-linux-x86_64/bin" >>/etc/profile
		source /etc/profile
	else
		echo "cmake file is not found"
		exit
	fi
}
mysql80(){
#	wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.28.tar.gz
	if [ -f mysql-boost-8.0.28.tar.gz ];then
		tar xf mysql-boost-8.0.28.tar.gz
		cd mysql-8.0.28
		cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql8 -DWITH_BOOST=./boost/ -DFORCE_INSOURCE_BUILD=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_DATADIR=/usr/local/mysql8/data
		make -j 8
		if [ $? -eq 0 ];then
			make install
		else
			exit
		fi
	else
		echo "mysql file is not found"
		exit
	fi
}


mem_all
ping_baidu
yum_repo
yum_env
cmake_safe
mysql80

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/890969.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号