cat mysql_init.sh
mysql_init.sh               mysql_init.sh.20190401      mysql_init.sh.back20171030  mysql_init.sh.back20180327  mysql_init.sh.bak          
[admin@yifudevops-jenkins-master-12 files]$ cat mysql_init.sh.20190401
##安装mariadb依赖包
function install_yum()
{
  yum -y install $1
}
i="ncurses* bison gcc* screen make gcc-c++ cmake bison-devel ncurses-devel libaio libaio libaio-devel perl-Data-Dumper net-tools lvm2* unzip zlib-* mdadm libaio* bison* openssl* libcurl-devel libarchive-devel boost* kernel-headers kernel-devel pcre-devel"
for j in $i
do
  install_yum $j
done
echo "###################################finish yum install rpm package 10%"
sleep 5
####软raid0
m1=`ls /dev/* |grep md0`
if [ ! -n "$m1" ]
then
  ra=`ls /dev/vd*|grep -v vda`
  rb=`ls /dev/vd*|grep -v vda|wc -l`
  if [ $rb -eq 0 ]
  then
    echo "no init partition storage"
  else
    mdadm -C /dev/md0 -l raid0 -n $rb $ra
    mkfs.ext4 /dev/md0
    mdadm -E -s -v >> /etc/mdadm.conf
    mkdir /u02
    mount /dev/md0 /u02
    echo '/dev/md0 /u02 ext4 defaults 0 0'>>/etc/fstab
  fi
else
  echo 'Md0 has been created'
fi
echo "###################################finish install raid0 15%"
sleep 5
##新建mariadb安装包存放目录
mkdir /u04/mysql -p
find / -name mariadb-10.3.8.tar.gz > find.log
oz=`cat find.log`
chown root. $oz
for oi in $oz
do
  tar -vzxf $oi -C /u04/mysql
done
ox=`echo $?`
if [ $ox -eq 0 ]
then
  echo "###################################finish tar mysql soft 20%"
  sleep 5
else
  echo "###################################Tar mysql soft is wrong!"
  exit
fi
##新建mysql用户已经相关目录
groupadd mysql
useradd -r -g mysql mysql
#mkdir /u02
#mount /dev/md0 /u02
mkdir /u02/mysql -p
mkdir /u02/mysql/binlog
mkdir /u02/mysql/undo
mkdir /u02/mysql/tmp
mkdir /u02/mysql/slowlog
mkdir /u02/mysql/redo
mkdir /u02/mysql/data
mkdir /u02/mysql/sock
mkdir /u02/mysql/error
chown mysql. /u02/mysql -R
echo "####################################25%"
sleep 5
##编译mariadb
cd /u04/mysql/mariadb-10.3.8
cmake -DCMAKE_INSTALL_PREFIX=/u02/mysql/ -DMYSQL_DATADIR=/u02/mysql/data/ -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/u02/mysql/sock/ -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=utf8mb4,utf8,gbk -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_unicode_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1
a=`echo $?`
if [ $a -eq 0 ]
then
  echo ""
  echo "finish cmake##################################################30%"
  sleep 5
else
  echo "cmake  wrong!"
  exit
fi
make
b=`echo $?`
if [ $b -eq 0 ]
then
  echo ""
  echo "finish make##################################################40%"
  sleep 5
else
  echo "make wrong!"
  exit
fi
make install
c=`echo $?`
if [ $c -eq 0 ]
then
  echo ""
  echo "finishi make install##################################################60%"
  sleep 5
else
  echo "make install wrong!"
  exit
fi
##配置mariadb配置文件
g=`free -g|grep Mem|awk '{print $2}'`
h=$(($g*4/5))
rm -rf /etc/my.cnf
touch /etc/my.cnf
echo "[mysql]
default-character-set =utf8mb4
[mysqld]
basedir = /u02/mysql/
datadir = /u02/mysql/data
tmpdir =  /u02/mysql/tmp
port = 3306
socket = /u02/mysql/sock/mysql.sock
character_set_server = utf8mb4
max_user_connections=2980
default-storage-engine=InnoDB
partition
lock_wait_timeout=900
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
init_connect='SET collation_connection = utf8mb4_unicode_ci'
skip-character-set-client-handshake
lower_case_table_names=1
default-time-zone=\"+8:00\"
join_buffer_size=128K
sort_buffer_size=8m
table_open_cache=1024
table_definition_cache=1024
query_cache_type=0
query_cache_size=0
query_cache_limit=0
back_log=300
thread_cache_size=512
max_connections=3000
tmp_table_size=128m  #for mairadb
max_heap_table_size=128m #for mairadb
skip-name-resolve
net_buffer_length=8k
max_allowed_packet=1g
connect_timeout=10
wait_timeout=120
interactive_timeout=120
net_read_timeout=3 #set to 10 if across IDC
net_write_timeout=6 #set to 10 if across IDC
net_retry_count=2 #set to 5 if across IDC
log-error=/u02/mysql/error/error3306.log
skip-log-warnings
slow-query-log
slow_query_log_file=/u02/mysql/slowlog/slow3306.log
log_slow_verbosity='Query_plan,Innodb'  #for mariadb
innodb_log_group_home_dir=/u02/mysql/redo
innodb_log_files_in_group=4
innodb_log_file_size=256M
innodb_open_files=4096
innodb_change_buffering=inserts
innodb_adaptive_hash_index=ON
innodb_autoinc_lock_mode=2
innodb_buffer_pool_size="$h"G
innodb_buffer_pool_instances=4
innodb_max_dirty_pages_pct=50
innodb_old_blocks_pct=25
innodb_old_blocks_time=3000
innodb_log_buffer_size=50m
innodb_flush_method=O_DIRECT
innodb_use_native_aio
innodb_adaptive_flushing
innodb_flush_log_at_trx_commit=1
innodb_io_capacity=20000
innodb_read_io_threads=4
innodb_write_io_threads=4
innodb_read_ahead_threshold=56
innodb_purge_threads=1
innodb_purge_batch_size=20
innodb_file_per_table
innodb_autoextend_increment=32
innodb_stats_on_metadata=0  #for mariadb
innodb_stats_sample_pages=32
innodb_stats_method=nulls_unequal
innodb_fast_shutdown=1
autocommit=1
transaction-isolation=READ-COMMITTED #for mariadb
completion_type=NO_CHAIN
#innodb_support_xa
innodb_table_locks
innodb_lock_wait_timeout=900
innodb_spin_wait_delay=6
innodb_sync_spin_loops=30
innodb_commit_concurrency=0
innodb_thread_concurrency=32       #at least equal cpu nums
#server-id=1
#log_bin=/u02/mysql/binlog/master
#sync_binlog=1
#innodb_flush_log_at_trx_commit=1
#log_bin_trust_function_creators=1
#expire_logs_days = 1
#binlog_format=ROW
" >/etc/my.cnf
echo "finish mysql /etc/my.cnf##################################################70%"
sleep 5
##初始化mariadb
cd /u04/mysql/mariadb-10.3.8/scripts
./mysql_install_db --user=mysql --basedir=/u02/mysql --datadir=/u02/mysql/data
sleep 120
echo $'\003'
cd /u02
chown mysql. mysql/ -R
echo "finish mysql init##################################################80%"
sleep 5
##开启mariadb
cd /u04/mysql/mariadb-10.3.8
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig mysqld on
nohup /etc/init.d/mysqld start >/dev/null 2>&1 &
sleep  30
echo "finish mysql start##################################################90%"
sleep 5
##配置变量以及配置root用户密码
ln -s /u02/mysql/bin/mysql /usr/bin/mysql
ln -s /u02/mysql/bin/mysqldump /usr/bin/mysqldump
/u02/mysql/bin/mysqladmin  -u root -h 127.0.0.1 password 'oracletest'
echo "finish mysql install ok##################################################100%"
sleep 5
##配置主从用户
#################################################################flyway init
mysql -uroot -poracletest -h127.0.0.1 -e "create database dbadmin"
mysql -uroot -poracletest -h127.0.0.1 -e "grant all on *.* to dbadmin@'127.0.0.1' identified by 'dbadmin'"
###############################################
#backup
mkdir /u03/mysql/backup -p
mkdir /u01/dba_scripts/mysqldump -p
mkdir /u01/dba_scripts/mysql_add_partition -p
mv /tmp/mysqlbackup.sh /u01/dba_scripts/mysqldump
mv /tmp/mysql_add_partition_tables.sh /u01/dba_scripts/mysql_add_partition
cat /tmp/mysql_crontab.txt >> /var/spool/cron/root
echo "#################################finish shell"
###############################################
yum -y install java
mkdir -p  /u10/flyway_mysql
unzip     /tmp/flyway-commandline-4.2.0-windows-x64.zip -d /u10/flyway_mysql
flyway_home=/u10/flyway_mysql/flyway-4.2.0/
flyway_conf=/u10/flyway_mysql/flyway-4.2.0/conf/flyway.conf
flyway_sql=/u10/flyway_mysql/flyway-4.2.0/sql/db/migration
flyway_drivers=/u10/flyway_mysql/flyway-4.2.0/drivers
#cp        /tmp/ojdbc6.jar  $flyway_drivers
ln -s /u10/flyway_mysql/flyway-4.2.0/flyway /usr/bin/flyway_mysql
#a=`who|awk '{print $1}'`
#cd
echo "alias flymysql='cd /u10/flyway_mysql/flyway-4.2.0'" >>/etc/profile
source /etc/profile
####$flyway_home/.flyway migrate
####Sql?..?½å§..ï####V3_1__20170921_1.sql
#ip_dir=`ifconfig |grep inet|grep -v '127.0.0.1'|awk '{print $2}'|sed -n '1p'`
echo "
flyway.url=jdbc:mariadb://127.0.0.1:3306/dbadmin
flyway.user=dbadmin
flyway.password=dbadmin
flyway.schemas=dbadmin
flyway.table=schema_version
flyway.baselineOnMigrate=true" >> $flyway_conf
cd /u10/flyway_mysql/flyway-4.2.0
chmod 777 sql
flyway_mysql  migrate
echo "#################################finish flyway install"

MySQL 源码编译安装脚本的更多相关文章

  1. Dubbo入门到精通学习笔记(十九):MySQL源码编译安装、MySQL主从复制的配置

    文章目录 MySQL 源码编译安装(CentOS-6.6+MySQL-5.6) 一.服务器配置: 二.源码安装 MySQL5.6.26: MySQL主从复制的配置 环境 依赖课程 MySQL 主从复制 ...

  2. bash-2 httpd服务的源码编译安装脚本

    httpd服务的源码编译安装脚本 #!/bin/bash # #******************************************************************** ...

  3. Mysql源码编译安装&主从复制

    一)camke源码编译安装mysql 1)创建软件安装目录software [root@master software]# ls cmake-2.8.8.tar.gz mysql-5.5.32.tar ...

  4. MySQL 源码编译安装

    脚本须知: 1. 该脚本目前只测试过mysql版本为5.6.x的源码,其他源码可以对本脚本稍作修改即可 2. 本脚本也可以使用wget mysql源码的方式进行,但考虑到后期提供源码的地址不可用,所以 ...

  5. ubuntu下mysql源码编译安装

    建议:cpu4核以上,内存4G以上 1. 安装环境:Ubuntu Server 14.10MySQL-5.6.23.tar.gz 2. 安装必备的工具sudo apt-get install make ...

  6. mysql源码编译安装

    首先去官网http://dev.mysql.com/downloads/mysql/ 下载mysql源码.我下的是5.7.10 源码选择的是 Generic Linux (Architecture I ...

  7. Apache源码编译安装脚本

      Apache是开源的的.最流行的Web服务器软件之一,它快速.可靠并且可通过简单的API扩充,将Perl/Python/PHP等解释器编译到服务器中.Apache的模块超多,以及具有运行稳定,强大 ...

  8. Mysql 源码编译安装 ( 5.5 、5.6 共存 )

    简介: 如何在一台服务器同时运行两 ( 多 ) 个 MySQL 服务. 1.MySQL 5.6 shell > useradd -r -s /sbin/nologin mysql shell & ...

  9. Shell脚本一键部署——源码编译安装MySQL及自动补全工具

    Shell脚本一键部署--源码编译安装MySQL及自动补全工具 编译安装MySQL 1.软件包 Mysql安装包 将安装包拖至/opt目录下,编辑一个脚本文件,将以下内容复制进去,然后source或者 ...

随机推荐

  1. python学习-14 基本数据类型3

    1.字符串 获取字符串的字符,例如: test = 'abcd' a= test[0] # 通过索引,下标,获取字符串中的某一个字符 print(a) b = test[0:1] # 通过下标的 范围 ...

  2. python day1 (afternoon)购物清单

    购物清单 #顾客给出余额 #给出商品清单 #顾客挑选商品 #给出购物清单 代码: #!/usr/bin/env python#-*- coding:utf-8 -*- salary = int(inp ...

  3. Vue 组件系统

    vue.js既然是框架,那就不能只是简单的完成数据模板引擎的任务,它还提供了页面布局的功能.本文详细介绍使用vue.js进行页面布局的强大工具,vue.js组件系统. 每一个新技术的诞生,都是为了解决 ...

  4. 1233: 输出杨辉三角前n行(Java)

    WUSTOJ 1233: 输出杨辉三角前n行 题目 原题链接 Description 输出杨辉三角前n行. Input 输入一个数n(n <= 9) Output 输出杨辉三角前n行.(注意行末 ...

  5. html如何点击子元素事件而不触发父元素的点击事件——阻止冒泡

    如果子元素和父元素都有点击事件,会出现点击事件冒泡的情况. 1.如何避免冒泡: html: <html> <head></head> <body> &l ...

  6. 【vue】过滤器的使用

    一.在methods中使用过滤器------全局定义的过滤器 //main.js中 import Vue from 'vue' Vue.filter('testFilter1',function(va ...

  7. RGB转YUV 各种库的性能比较

    分辨率   1920*1080 平台  : X64  Windows  VS2015 测试  BGR24-->YUV420 trans_scale: 4.14 ms (自己写得)libyuv  ...

  8. For... in 及 For… of 及 forEach

    For... in 及 For… of let arr = ["a","b"]; for (let a in arr) { console.log(a) // ...

  9. MVC框架+vue+elementUI

    用自动化构建做的vue项目,因为是动态加载数据,在SEO优化时一直不如意,于是我们换了框架,用MVC框架,做成静态页面,但是原来的代码都是用vue和elementUI,为了快速的复用原来的代码,于是在 ...

  10. CSS3自定义滚动条样式方法

    该代码收集于网上资源,非原创 /*定义滚动条宽高及背景,宽高分别对应横竖滚动条的尺寸*/ ::-webkit-scrollbar { width: 10px; /*对垂直流动条有效*/ height: ...