mysql 5.7 编译安装脚本。
此脚本尽量运行在centos 服务器上面,用于编译安装mysql 5.7
将此脚本和相应的软件 都放到/usr/local/src 目录下面
由于不能上传附件 所以需要把cmake-3.9.6.tar.gz ,boost_1_59_0.tar.gz,mysql-5.7.22.tar.gz 先下载好。
#####编译安装mysql5.7
#####此脚本的作用在于自动化安装mysql5.7 为并行复制(基于组提交), mysql5.7 自动化failover ,和archer 工单审核做准备
#####version mysql5.7.22
####下载msyql https://downloads.mysql.com/archives/community/mysql-5.7.22.tar.gz
###先将脚本 压缩本上传到服务器/usr/local/src/目录下 这是我习惯用的统一目录
####安装必要的依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel bison libgcrypt perl make openssl-devel
####安装cmake 去这里面下载分为源码版和编译好的版本https://cmake.org/download/
####添加用户 创建目录
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
mkdir /data/mysql/3306/{data,log,tmp,mysql-bin,relay-bin,redo-log,undo-log} -p
chown mysql.mysql /data/mysql -R
chmod 755 /data/mysql -R
#安装cmake
cd /usr/local/src
tar -xvzf cmake-3.9.6.tar.gz
cd /usr/local/src/cmake-3.9.6/
./bootstrap
sleep 10
gmake
make install
cd ..
#安装boost mysql5.7依赖
tar -xvzf boost_1_59_0.tar.gz -C /data/mysql/
######安装mysql5.7
tar -xvzf mysql-5.7.22.tar.gz
cd mysql-5.7.22
#指定boost的位置 -DWITH_BOOST=/data/mysql/boost_1_59_0
/usr/local/src/cmake-3.9.6/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/3306/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/data/mysql/boost_1_59_0 -DSYSCONFDIR=/etc/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_EMBEDDED_SERVER=1 -DMYSQL_TCP_PORT=3306;
make -j `grep processor /proc/cpuinfo | wc -l` #编译时会消耗很大内存,小内存可能无法编译完成
make install
cd /usr/local/src/
rm -rf *.tar.gz
rm -rf mysql-5.7.22
####添加环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
source /etc/profile
cat > /usr/local/mysql/my.cnf <<"EOF"
[client]
port = 3306
socket = /data/mysql/3306/tmp/mysql.socket
[mysqld]
server-id = 100
port = 3306
basedir=/usr/local/mysql
datadir=/data/mysql/3306/data
tmpdir = /tmp
socket = /data/mysql/3306/tmp/mysql.socket
skip-external-locking
skip_name_resolve = 1
transaction_isolation = REPEATABLE-READ
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
lower_case_table_names = 1
max_connections = 8000
max_connect_errors = 8000
explicit_defaults_for_timestamp = 1
max_allowed_packet = 256M
interactive_timeout = 1800
wait_timeout = 1800
tmp_table_size = 128M
max_heap_table_size = 128M
query_cache_size = 0
query_cache_type = 0
read_buffer_size = 1M
read_rnd_buffer_size = 2M
secure-file-priv = "/"
binlog_cache_size = 8M
join_buffer_size = 128M
back_log = 600
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
#######log set#############
log_error = /data/mysql/3306/log/mysql.err
slow_query_log = 1
slow_query_log_file = /data/mysql/3306/log/slow.log
log_queries_not_using_indexes = 1
long_query_time = 2
expire_logs_days = 7
log-bin=/data/mysql/3306/mysql-bin/mysql-bin
binlog_format = ROW
binlog_row_image = minimal
relay_log = /data/mysql/3306/relay-bin/relay-bin
####用户从库级联复制
log_slave_updates
####relay_log_recovery = 1 ##从库参数
slave_skip_errors = 1062
######刷盘方式#########
innodb_flush_log_at_trx_commit = 2
sync_binlog = 0
#########Innodb设置##########
innodb_buffer_pool_size = 512M
innodb_buffer_pool_instances = 8
#innodb_log_buffer_size = 16777216
innodb_flush_method = O_DIRECT
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_lock_wait_timeout = 60
innodb_log_group_home_dir = /data/mysql/3306/redo-log/
innodb_undo_directory = /data/mysql/3306/undo-log/
innodb_log_files_in_group = 3
innodb_log_file_size = 1G #线上改成4G
innodb_undo_log_truncate = 1
#innodb_undo_tablespaces = 1#线上改成3
innodb_undo_logs = 128
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
######gtid#######
gtid_mode = on
enforce_gtid_consistency = 1
######并行复制参数从库需要开启###########
#slave-parallel-type=LOGICAL_CLOCK
#slave-parallel-workers=16
master_info_repository=TABLE
relay_log_info_repository=TABLE
#relay_log_recovery=ON
replicate-wild-ignore-table = mysql.%
replicate-wild-ignore-table = test.%
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 4M
read_buffer = 2M
write_buffer = 2M
[mysqld_safe]
#增加每个进程的可打开文件数量.
open-files-limit = 28192
[mysqld-5.7]
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 4
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 2G
innodb_purge_rseg_truncate_frequency = 128
binlog_gtid_simple_recovery=1
log_timestamps=system
transaction_write_set_extraction=MURMUR32
show_compatibility_56=on
EOF
touch /data/mysql/3306/log/mysql.err
chown mysql.mysql /data/mysql/3306/log/mysql.err
####初始化
/usr/local/mysql/bin/mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data/ --explicit_defaults_for_timestamp
#####启动mysql
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &
sleep 300
######修改数据库密码
#/usr/local/mysql/bin/mysqladmin -u root -p -S /data/mysql/3306/tmp/mysql.socket password "abc123"
/usr/local/mysql/bin/mysql --port=3306 -S /data/mysql/3306/tmp/mysql.socket -BNe "update mysql.user set authentication_string=password('abc123') where user='root';flush privileges;"
####配置快捷登陆方式
cat >/usr/local/local.cnf <<EOF
[client]
host=localhost
port=3306
user=root
password=abc123
socket=/data/mysql/3306/tmp/mysql.socket
EOF
cat >>/root/.bashrc <<EOF
alias mysql.start='/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &'
alias mysql.login='/usr/local/mysql/bin/mysql --defaults-file=/usr/local/local.cnf'
alias mysql.stop='/usr/local/mysql/bin/mysqladmin --port=3306 -uroot -p'abc123' -S /data/mysql/3306/tmp/mysql.socket shutdown'
EOF
source /root/.bashrc
source /root/.bash_profile
cat >>/etc/rc.local <<EOF
alias mysql.3310.start='/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &'
alias mysql.3310.login='/usr/local/mysql/bin/mysql --defaults-file=/usr/local/local.cnf'
alias mysql.3310.stop='/usr/local/mysql/bin/mysqladmin --port=3310 -uroot -p'Pass@word' -S /data/mysql/3310/tmp/mysql.socket shutdown'
EOF
source /root/.bashrc
echo "Please execute:
source /root/.bash_profile"
mysql 5.7 编译安装脚本。的更多相关文章
- MySQL 源码编译安装脚本
cat mysql_init.shmysql_init.sh mysql_init.sh.20190401 mysql_init.sh.back20171030 ...
- CentOS下MySQL 5.7编译安装
CentOS下MySQL 5.7编译安装 文章目录 安装依赖包 下载相应源码包 添加mysql用户 预编译 编译安装 启动脚本,设置开机自启动 /etc/my.cnf,仅供参考 初始化数据库 设置 ...
- MySQL 单实例编译安装 以及多实例安装简介
这是基本的安装教程,与牛逼的大神无关,或许是牛逼大神不用看就会安装吧. CentOS 6.5 Final x86_64 一.预安装软件包 1.开发包组合安装 yum groupinstall &qu ...
- php-fpm编译安装脚本
PHP是开源.轻量级.高效的开发语言,特别适合web项目开发,在中小型互联网公司中常用于开发web后端.PHP常与Nginx及MySQL数据库结合,搭建LNMP环境.以下为centos7系统下ph ...
- Dubbo入门到精通学习笔记(十九):MySQL源码编译安装、MySQL主从复制的配置
文章目录 MySQL 源码编译安装(CentOS-6.6+MySQL-5.6) 一.服务器配置: 二.源码安装 MySQL5.6.26: MySQL主从复制的配置 环境 依赖课程 MySQL 主从复制 ...
- CentOS MySQL 5.7编译安装
CentOS MySQL 5.7编译安装 MySQL 5.7 GA版本的发布,也就是说从现在开始5.7已经可以在生产环境中使用,有任何问题官方都将立刻修复. MySQL 5.7主要特性: 更好的性能: ...
- mysql源码编译安装
首先去官网http://dev.mysql.com/downloads/mysql/ 下载mysql源码.我下的是5.7.10 源码选择的是 Generic Linux (Architecture I ...
- Nginx编译安装脚本
Nginx是高性能的web服务器和反向代理服务器,在互联网公司中被广泛使用.以下是Nginx在centos7系统下的一键编译安装脚本,仅供参考,具体编译参数选项请结合实际生产环境需求进行选择,脚本 ...
- bash-2 httpd服务的源码编译安装脚本
httpd服务的源码编译安装脚本 #!/bin/bash # #******************************************************************** ...
随机推荐
- ng2学习--pipe使用
We use our custom pipe the same way we use built-in pipes.(自定义Pipe和API里自带的Pipe使用方式一致) We must includ ...
- n个点的基环树数量
某裴姓蒟蒻上午提了一个小问题(rt)..然后他升华了..升华之前感受到了神犇的力量... 方法一: g[n][k]表示n个点,k条边的无向图(不一定连通) f[n][k]表示表示n个点,k条边的无向连 ...
- 忘记mysql数据库密码时进行修改方法
长时间没有使用数据库了,或者把密码改完之后就忘了数据库密码,不能正常进入数据库,也无法修改密码,有一个简单的常用修改密码方式: 1.首先找到和打开mysql.exe和mysqld.exe所在的文件夹( ...
- 005 Longest Palindromic Substring 最长回文子串
Given a string s, find the longest palindromic substring in s. You may assume that the maximum lengt ...
- vim 编辑器设置tab缩进
创建 ~/.vimrc文件,写入 set tabstop=4 ,保存 原文
- (转)Linux系统重要子目录及内容小结
Linux系统重要子目录及内容小结 原文:http://blog.csdn.net/xiaolong361/article/details/52318834 1.首先来介绍下根目录下的一些重要目录含义 ...
- clipboard JS(剪切板)的使用
引入js(根据路径需要修改url) <script src="lib/clipboard/clipboard.min.js" type="text/javascri ...
- C# 多线程之线程控制
方案一: 调用线程控制方法.启动:Thread.Start();停止:Thread.Abort();暂停:Thread.Suspend();继续:Thread.Resume(); private vo ...
- hibernate课程 初探单表映射1-6 hibernate项目建立以及导入jar包
hibernate 项目建立 1 new ==>java project hibernate 导入jar包 1 windows==>prerence==>java ==>bui ...
- IO多路复用丶基于IO多路复用+socket实现并发请求丶协程
一丶IO多路复用 IO多路复用指:通过一种机制,可以监视多个描述符,一旦某个描述符就绪(一般是读就绪或者写就绪),能够通知程序进行相应的读写操作 IO多路复用作用: 检测多个socket是否已经发生变 ...