暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
mysql_install_1.5.txt
345
23页
11次
2022-05-18
免费下载
#!/bin/bash
#Creation Data: 2021-04-19
#Last-Modified Date: 2021-06-01
#Author: Create by xiaoxuesong
#Mail: xiaoxuesong@longi.com
#Function: mysql 5.7 install on Linux 7(oracle linux && redhat && Centos)
#version: 1.0 初版编写
#version: 1.1 增加多实例
#version: 1.2 增加 backup , 增加新建库 , 修改用户权限
#version: 1.3 增加 8.0 版本
#version: 1.4 使用 xtrabackup 进行热备
#version: 1.5 修改 bug,增加主从复制
#-------------------------#
#set variable
#-------------------------#
SCRIPT_DIR=`pwd`
#SCRIPT_DIR=/root/scripts
hostname_long=`hostname`
host_name=`hostname|cut -f 1 -d '.'`
DNS='10.0.XXX.XXX'
SITE='10.0.3.XXX' #prod
SITE2='10.0.10.XXX' #test
DATETIME=`date +%Y%m%d`
RELS=`more /etc/system-release`
OS_VER_PRI=`echo ${RELS#*release} |awk '{print $1}' | cut -f 1 -d '.'`
initParam(){
#-------------------------#
# input DB_VERSION
# v1.3
#-------------------------#
read -p "please input DB VERSION: 5.7/8.0 [5.7]? " V_DB_VERSION
if [[ -z "${V_DB_VERSION}" ]] || [[ $V_DB_VERSION = "5.7" ]] ||
[[ $V_DB_VERSION = "57" ]];then
MYSQL_VERSION_C='57'
MYSQL_VERSION=mysql-5.7.34-linux-glibc2.12-x86_64
elif [[ $V_DB_VERSION = "8.0" ]] || [[ $V_DB_VERSION = "8" ]] ||
[[ $V_DB_VERSION = "80" ]];then
MYSQL_VERSION=mysql-8.0.25-linux-glibc2.12-x86_64
MYSQL_VERSION_C='80'
else
echo "DB version input error!!!"
exit
fi
#-------------------------#
# set base dir
#-------------------------#
read -p "the DB base dir is: [/usr/local/mysql]? " ENV_BASE_DIR
if [[ -z "${ENV_BASE_DIR}" ]] || [[ $ENV_BASE_DIR = "true" ]] ||
[[ $ENV_BASE_DIR = "y" ]] || [[ $ENV_BASE_DIR = "Y" ]];then
ENV_BASE_DIR=/usr/local/mysql
else
ENV_BASE_DIR=$ENV_BASE_DIR
fi
#-------------------------#
# Product or test evn
#-------------------------#
read -p "the OS is prod or test: [prod]? " IP_TPYE
if [[ -z "${IP_TPYE}" ]] || [[ $IP_TPYE = "true" ]] || [[ $IP_TPYE = "y" ]] ||
[[ $IP_TPYE = "Y" ]];then
IP_TPYE=prod
else
IP_TPYE=test
fi
#-------------------------#
# master or slave
#-------------------------#
read -p "the DB is master or slave: [master]? " DB_TPYE
if [[ -z "${DB_TPYE}" ]] || [[ $DB_TPYE = "true" ]] || [[ $DB_TPYE = "y" ]] ||
[[ $DB_TPYE = "Y" ]];then
DB_TPYE=master
else
DB_TPYE=slave
read -p "please set slave server-id: [102...]" SERVER_ID
read -p "please set master IP ADDR: " MASTER_IP_ADDR
fi
#-------------------------#
# set port
#-------------------------#
read -p "please enter database port: 3306/other[3306]? " DB_PORT
if [[ -z "${DB_PORT}" ]] || [[ $DB_PORT = "true" ]] || [[ $DB_PORT = "y" ]] ||
[[ $DB_PORT = "Y" ]];then
DB_PORT=3306
else
DB_PORT=$DB_PORT
fi
#-------------------------#
# backup or not backup
#-------------------------#
read -p "whether to back up the database: [yes]? " BACKUP_OR_NOT
if [[ -z "${BACKUP_OR_NOT}" ]] || [[ $BACKUP_OR_NOT = "true" ]] ||
[[ $BACKUP_OR_NOT = "y" ]] || [[ $BACKUP_OR_NOT = "Y" ]];then
BACKUP_OR_NOT=yes
else
BACKUP_OR_NOT=no
fi
#-------------------------#
# set password
#-------------------------#
read -p "please enter DB user root PASSWD: " MYPASSWD
#-------------------------#
# create database
# v1.2
#-------------------------#
CREATEDATABASE=N
read -p "Do you need to create new database(y/n) [y]? " CREATE_DB
if [[ -z "${CREATE_DB}" ]] || [[ $CREATE_DB = "y" ]] || [[ $CREATE_DB =
"Y" ]];then
CREATEDATABASE=Y
read -p "please enter NEW database NAME: " DBNAME
fi
#-------------------------#
# create user
#-------------------------#
CREATEUSER=N
read -p "Do you need to create new user(y/n) [y]? " CREATE_USER
of 23
免费下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜