###### 二进制自动安装数据库脚本root密码MANAGER将脚本和安装包放在/root目录即可###############
######数据库目录/usr/local/mysql############
######数据目录/data/mysql############
######慢日志目录/data/slowlog############
######端口号默认3306其余参数按需自行修改############
#!/bin/bash
wget http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.7/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
yum install -y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel
# Check if user is root
if [ $(id -u) != "0" ]; thenecho "Error: You must be root to run this script, please use root to install"exit 1
fi
clear
echo "========================================================================="
echo "A tool to auto-compile & install MySQL 5.7.16 on Redhat/CentOS Linux "
echo "========================================================================="
cur_dir=$(pwd)
#set mysql root passwordecho "==========================="mysqlrootpwd="123456"echo -e "Please input the root password of mysql:"read -p "(Default password: 123456):" mysqlrootpwdif [ "$mysqlrootpwd" = "" ]; thenmysqlrootpwd="123456"fiecho "==========================="echo "MySQL root password:$mysqlrootpwd"echo "==========================="
#which MySQL Version do you want to install?
echo "==========================="isinstallmysql57="n"echo "Install MySQL 5.7.16,Please input y"read -p "(Please input y , n):" isinstallmysql57case "$isinstallmysql57" iny|Y|Yes|YES|yes|yES|yEs|YeS|yeS)echo "You will install MySQL 5.7.16"isinstallmysql57="y";;*)echo "INPUT error,You will exit install MySQL 5.7.16"isinstallmysql57="n"exitesacget_char(){SAVEDSTTY=`stty -g`stty -echostty cbreak#dd if=/dev/tty bs=1 count=1 2> /dev/nullstty -rawstty echostty $SAVEDSTTY}echo ""echo "Press any key to start...or Press Ctrl+c to cancel"char=`get_char`
# Initialize  the installation related content.
function InitInstall()
{cat /etc/issueuname -aMemTotal=`free -m | grep Mem | awk '{print  $2}'` echo -e "\n Memory is: ${MemTotal} MB "#Set timezonerm -rf /etc/localtimeln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime#Delete Old Mysql programrpm -qa|grep mysqlrpm -e mysql#Disable SeLinuxif [ -s /etc/selinux/config ]; thensed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/configfisetenforce 0
}
#Installation of depend on and optimization options.
function InstallDependsAndOpt()
{
cd $cur_dir
cat >>/etc/security/limits.conf<<EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
EOF
echo "fs.file-max=65535" >> /etc/sysctl.conf
}
#Install MySQL
function InstallMySQL57()
{
echo "============================Install MySQL 5.7.16=================================="
cd $cur_dir
#Backup old my.cnf
#rm -f /etc/my.cnf
if [ -s /etc/my.cnf ]; thenmv /etc/my.cnf /etc/my.cnf.`date +%Y%m%d%H%M%S`.bak
fi
echo "============================MySQL 5.7.16 installing…………========================="
#mysql directory configuration
tar xvf /root/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
mv /root/mysql-5.7.16-linux-glibc2.5-x86_64 /usr/local/mysql
groupadd mysql -g 512
useradd -u 512 -g mysql -s /sbin/nologin -d /home/mysql mysql
mkdir -p /data/mysql
mkdir -p /data/slowlog
chown -R mysql:mysql /data/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data/slowlog
#edit /etc/my.cnf
SERVERID=`ifconfig eth0 | grep "inet" | awk '{ print $2}'| awk -F. '{ print $3$4}'`
cat >>/etc/my.cnf<<EOF
[client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8
[mysql]
no-auto-rehash
default-character-set=utf8
[mysqld]
port=3306
character-set-server=utf8
socket=/tmp/mysql.sock
basedir=/usr/local/mysql
datadir=/data/mysql
explicit_defaults_for_timestamp=true
lower_case_table_names=1
back_log=103
max_connections=3000
max_connect_errors=100000
table_open_cache=512
external-locking=FALSE
max_allowed_packet=32M
sort_buffer_size=2M
join_buffer_size=2M
thread_cache_size=51
query_cache_size=32M
#query_cache_limit=4M
transaction_isolation=REPEATABLE-READ
tmp_table_size=96M
max_heap_table_size=96M
###***slowqueryparameters
long_query_time=1
slow_query_log = 1
slow_query_log_file=/data/slowlog/slow.log
###***binlogparameters
log-bin=mysql-bin
binlog_cache_size=4M
max_binlog_cache_size=4096M
max_binlog_size=1024M
binlog_format=MIXED
expire_logs_days=7
###***relay-logparameters
#relay-log=/data/3307/relay-bin
#relay-log-info-file=/data/3307/relay-log.info
#master-info-repository=table
#relay-log-info-repository=table
#relay-log-recovery=1
#***MyISAMparameters
key_buffer_size=16M
read_buffer_size=1M
read_rnd_buffer_size=16M
bulk_insert_buffer_size=1M
#skip-name-resolve
###***master-slavereplicationparameters
server-id=$SERVERID
#slave-skip-errors=all
#***Innodbstorageengineparameters
innodb_buffer_pool_size=4G
innodb_data_file_path=ibdata1:10M:autoextend
#innodb_file_io_threads=8
innodb_thread_concurrency=16
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=16M
innodb_log_file_size=512M
innodb_log_files_in_group=2
innodb_max_dirty_pages_pct=75
innodb_buffer_pool_dump_pct=50
innodb_lock_wait_timeout=50
innodb_file_per_table=on
[mysqldump]
quick
max_allowed_packet=32M
[myisamchk]
key_buffer=16M
sort_buffer_size=16M
read_buffer=8M
write_buffer=8M
[mysqld_safe]
open-files-limit=8192
log-error=/data/mysql/error.log
pid-file=/data/mysql/mysqld.pid
EOF
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql --initialize-insecure
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -i 's/`hostname`/mysqld/g'  /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
cat >> /etc/ld.so.conf.d/mysql-x86_64.conf<<EOF
/usr/local/mysql/lib
EOF
ldconfig
if [ -d "/proc/vz" ];then
ulimit -s unlimited
fi
/etc/init.d/mysqld start
cat >> /etc/profile <<EOF
export PATH=$PATH:/usr/local/mysql/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib
EOF
/usr/local/mysql/bin/mysqladmin -u root password $mysqlrootpwd
cat > /tmp/mysql_sec_script<<EOF
use mysql;
delete from mysql.user where user!='root' or host!='localhost';
#grant all privileges on *.* to 'sys_admin'@'%' identified by '123456';
flush privileges;
EOF
/usr/local/mysql/bin/mysql -u root -p$mysqlrootpwd -h localhost < /tmp/mysql_sec_script
rm -f /tmp/mysql_sec_script
/etc/init.d/mysqld restart
echo "============================MySQL 5.7.16 install completed========================="
}
function CheckInstall()
{
echo "===================================== Check install ==================================="
clear
ismysql=""
echo "Checking..."
if [ -s /usr/local/mysql/bin/mysql ] && [ -s /usr/local/mysql/bin/mysqld_safe ] && [ -s /etc/my.cnf ]; thenecho "MySQL: OK"ismysql="ok"elseecho "Error: /usr/local/mysql not found!!!MySQL install failed."
fi
if [ "$ismysql" = "ok" ]; then
echo "Install MySQL 5.7.16 completed! enjoy it."
echo "========================================================================="
netstat -ntl
else
echo "Sorry,Failed to install MySQL!"
echo "You can tail /root/mysql-install.log from your server."
fi
}
#The installation log
InitInstall 2>&1 | tee /root/mysql-install.log
InstallDependsAndOpt 2>&1 | tee -a /root/mysql-install.log
InstallMySQL57 > /dev/null
CheckInstall 2>&1 | tee -a /root/mysql-install.log
rm -f mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
source  /etc/profile

转载于:https://blog.51cto.com/hequan/1886310

集群四 mysql-5.7.16一键安装相关推荐

  1. mysql集群初始化配置_集群Cluster MySQL的安装配置和使用

    集群Cluster MySQL的安装配置和使用 发布时间:2020-05-28 14:20:03 来源:亿速云 阅读:233 作者:鸽子 MySQL Cluster MySQL集群 基本概念: &qu ...

  2. kettle mysql 参数,Kettle集群及Mysql参数调整

    <Kettle集群及Mysql参数调整>由会员分享,可在线阅读,更多相关<Kettle集群及Mysql参数调整(10页珍藏版)>请在人人文库网上搜索. 1.1 Kettle 集 ...

  3. mysql proxy集群_数据库集群中间件MySQL Proxy探讨

    数据库集群中间件 MySQL Proxy 探讨 杨芳萍 ; 马宏艳 ; 王斌 [期刊名称] <电子制作> [年 ( 卷 ), 期] 2013(000)019 [摘要] 互联网高速发展的同时 ...

  4. Ceph (3) - 安装Ceph集群方法3:使用 ceph-ansible 离线安装 Red Hat Ceph Storage 4.1 集群

    <OpenShift 4.x HOL教程汇总> 文章目录 安装前说明 准备主机环境 创建虚拟主机并配置网络 配置主机名和域名 设置环境变量 设置主机hosts 配置免密登录 设置节点主机名 ...

  5. DM MPP集群(带交叉守护进程)安装配置

    目录 DM MPP集群(带交叉守护进程)--安装配置... 3 1.    DM MPP架构基础... 3 2.    环境准备... 4 2.1     系统信息规划... 4 2.2     在 ...

  6. 集群批量管理工具parallel ssh的安装及使用

    集群批量管理工具parallel ssh的安装及使用 最近为了做实验,需要进行集群的配置,虽然十个节点的集群不算多,但是还是用它来减轻负担.但在使用的过程中,发现网上虽然有资料,但大多都没能很好的解决 ...

  7. 运维企业专题(11)RHCS高可用集群下MySql数据库与共享磁盘(单点写入、多点写入)的设置

    实验环境 主机名 IP 服务 server1 172.25.6.1 ricci,luci, iscsi,mysql-server server2 172.25.6.2 ricci,iscsi,mysq ...

  8. Python 检测系统时间,k8s版本,redis集群,etcd,mysql,ceph,kafka

    一.概述 线上有一套k8s集群,部署了很多应用.现在需要对一些基础服务做一些常规检测,比如: 系统时间,要求:k8s的每一个节点的时间,差值上下不超过2秒 k8s版本,要求:k8s的每一个节点的版本必 ...

  9. 大数据生态(六)zookeeper集群部署(Linux和Windows[含一键启动脚本])

    目录 前言 1.解压安装Zookeeper到/e3base/zookeeper目录下 2 .创建$E3_INFO_HOME/zookeeper目录 3 .创建数据目录和日志目录 4.配置环境变量 4. ...

最新文章

  1. springboot整合vue小试牛刀
  2. 如何在nginx中缓存静态文件
  3. 鲁尼禁赛萨哈一射一传领风骚 曼联客场3-0查尔顿
  4. 针对SharePointFarm场时安装部署OWA的步骤
  5. react java_独眼巨人React组织了Java 8库的寒武纪爆发
  6. java怎么将程序保存在桌面_在Java桌面应用程序中保留数据的最佳方法是什么?...
  7. 解决servlet中get方式中中文乱码问题前驱(一):装饰者模式再理解
  8. mysql省市区递归查询_mysql 递归查询
  9. java毕业生设计药品管理系统演示录像 2021计算机源码+系统+mysql+调试部署+lw
  10. 彩虹表破解md5密码
  11. 《web安全原理分析与实践》
  12. Android源码编译:openjdk安装
  13. 国产操作系统都有哪些功能?普通人能满足日常使用吗?
  14. SANGFOR SCSA——协议基础
  15. 高等数学(第七版)同济大学 习题12-3 个人解答
  16. C语言 memcpy和memcpy_s
  17. 实力悍将联想Z5s发布1398元起售,2019超旗舰Z5 Pro GT 855版惊世降临...
  18. 转:eclipse failed to create the java virtual machine 问题图文解析
  19. Data Wrangling
  20. Elasticsearch分词器介绍

热门文章

  1. hadoop集群配置与启动
  2. python字典排序
  3. JS基础篇之作用域、执行上下文、this、闭包
  4. 雷林鹏分享:PHP 5 Directory 函数
  5. vim简单使用教程【转】
  6. 在Linux上进行内核参数调整
  7. selenium实例:unittest框架+PO开发模式
  8. 学习第七天——培训开始
  9. 二分图最大匹配(匈牙利算法) POJ 3020 Antenna Placement
  10. 前端性能优化最佳实践(转)