MySQL 5.6.26源码安装
5.6.26源码安装包:http://pan.baidu.com/s/1kUl44WR
cmake安装包链接:http://pan.baidu.com/s/1c0LuwJA
操作系统版本:CentOS release 6.3 (Final)
安装过程:(记得挂载镜像,并且配置yum,方便yum安装各种依赖的包)
CentOS配置yum:
1、cd /etc/yum.repos.d
2、创建个任意目录,将所有文件移动到创建的目录中,除了CentOS-Media.repo
3、编辑CentOS-Media.repo
vi CentOS-Media.repo
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
# file:///media/cdrom/
# file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
4、创建/media/CentOS/目录
5、挂载
mount /dev/cdrom /media/CentOS/
[root@hank-yoon ~]# mkdir -p /export/servers
[root@hank-yoon servers]# 上传安装脚本、MySQL源码安装包,Cmake安装包
[root@hank-yoon servers]#ls
cmake-2.8.3.tar.gz mysql-5.6.26.tar.gz install.sh
[root@hank-yoon servers]#sh install.sh
[root@hank-yoon servers]#cat install.sh 脚本内容
#!/bin/bash
# check
echo -e "\033[;37;34mCheck Memory Size...\033[0m"
if [ `free -g|grep ^Mem|awk '{print $2}'` != 125 ]
then
read -p "Memory size is `free -g|grep ^Mem|awk '{print $2}'`G , enter innodb_buffer_pool_size(default 20G) : " pool
else
echo -e "\033[;37;32mMemory Size is 125G , innodb_buffer_pool_size set 100G\033[0m"
fi
echo -e "\033[;37;34mCheck Network...\033[0m"
#if ! ping -c 1 -w 1 www.baidu.com > /dev/null;then echo -e "\033[;37;31mPlease Check Network Before Setup\033[0m";exit 1;else echo -e "\033[;37;32mOK\033[0m";fi
echo -e "\033[;37;34mCheck Packet...\033[0m"
if ! ls mysql-5.6.26.tar.gz cmake-2.8.3.tar.gz > /dev/null;then echo -e "\033[;37;31mNo Packets\033[0m";exit 1;else echo -e "\033[;37;32mOK\033[0m";fi
# replace yum.repos.d
#rm -f /etc/yum.repos.d/*
#wget -P /etc/yum.repos.d/ http://172.22.197.62/CentOS/app/script/CentOS-Media.repo
#sed -i 's/6.3/6.5/' /etc/yum.repos.d/CentOS-Media.repo
#echo -e "\033[;37;34mreplace yum.repos.d...\033[0m"
#wget mysql cmake
#change IO scheduler
echo deadline > /sys/block/sda/queue/scheduler
echo -e "\033[;37;34mchange IO scheduler to deadline...\033[0m"
# init enviroment
echo -e "\033[;37;34mStarting Yum Install...\033[0m"
yum install -y ncurses-devel glibc gcc gcc-c++ libstdc++* libtool cmake lrzsz libaio-devel
echo -e "\033[;37;32mYum Install Done\033[0m"
echo -e "\033[;37;34mAdd MySQL OS User...\033[0m"
useradd mysql
echo -e "\033[;37;32mAdd User Done\033[0m"
setuplog=/home/mysql/logs/install-log
setupdir=$(pwd)
mysqldir=(/export/data/mysql/tmp /export/data/mysql/undo /export/data/mysql/data /export/servers/mysql/etc /export/data/mysql/dumps /export/data/mysql/log /home/mysql/scripts /home/mysql/logs)
mkdir -p ${mysqldir[*]}
chown mysql:mysql -R /export/data/mysql /home/mysql/
echo -e "\033[;37;34mExtracting package to /usr/local/src/\033[0m"
tar xzf cmake-2.8.3.tar.gz -C /usr/local/src
tar xzf mysql-5.6.26.tar.gz -C /usr/local/src
mv *.tar.gz /usr/local/src
echo -e "\033[;37;32mExtracting Done\033[0m"
# install
echo -e "\033[;37;34mInstall Cmake...\033[0m"
cd /usr/local/src/cmake-2.8.3 ; ./bootstrap && gmake && make install
if [ $? = 0 ];then echo -e "\033[;37;32mCmake Install Done\033[0m";else echo -e "\033[;37;31mCmake Install Faild\033[0m";fi
echo -e "\033[;37;34mInstall MySQL...\033[0m"
echo "Configure Error" > $setuplog
cd /usr/local/src/mysql-5.6.26 ; cmake . -DCMAKE_INSTALL_PREFIX=/export/servers/mysql/ -DMYSQL_DATADIR=/export/data/mysql/data -DSYSCONFDIR=/export/servers/mysql/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/export/data/mysql/tmp/mysql.sock -DENABLED_LOCAL_INFILE=ON -DENABLED_PROFILING=ON -DWITH_DEBUG=0 -DENABLE_DTRACE=OFF -DMYSQL_TCP_PORT=3358 2>> $setuplog
make && make install
if [ $? = 0 ];then echo -e "\033[;37;32mMySQL Install Done\033[0m";else echo -e "\033[;37;31mMySQL Install Faild\033[0m";exit 1;fi
/sbin/ldconfig /export/servers/mysql/lib/
echo -e "\033[;37;34mModify /home/mysql/.bash_profile...\033[0m"
echo "export LANG=en_US.UTF-8" >> /home/mysql/.bash_profile
sed -i 's!PATH=$PATH:$HOME/bin!PATH=$PATH:$HOME/bin:/export/servers/mysql/bin!' /home/mysql/.bash_profile
source /home/mysql/.bash_profile
echo -e "\033[;37;32mDONE\033[0m"
# my.cnf
echo -e "\033[;37;34mCreate /export/servers/mysql/etc/my.cnf...\033[0m"
cat >> /export/servers/mysql/etc/my.cnf << EOF
[client]
port = 3358
socket = /export/data/mysql/tmp/mysql.sock
[mysqld]
port = 3358
socket = /export/data/mysql/tmp/mysql.sock
datadir = /export/data/mysql/data/
#--- GLOBAL ---#
character-set-server = utf8
lower_case_table_names = 1
log-output = FILE
log-error = /export/data/mysql/log/error.log
general_log = 0
general_log_file = /export/data/mysql/log/mysql.log
pid-file = /export/data/mysql/mysql.pid
slow-query-log
slow_query_log_file = /export/data/mysql/log/slow.log
tmpdir = /export/data/mysql/tmp
long_query_time = 1
#--------------#
#thread_concurrency = 16
thread_cache_size = 512
table_open_cache = 16384
table_definition_cache = 16384
sort_buffer_size = 2M
join_buffer_size = 2M
read_buffer_size = 4M
read_rnd_buffer_size = 4M
key_buffer_size = 8M
myisam_sort_buffer_size = 8M
tmp_table_size = 64M
max_heap_table_size = 64M
open_files_limit = 65535
query_cache_size = 0
#add z #################
innodb_undo_directory = /export/data/mysql/undo
innodb_undo_tablespaces = 4
explicit_defaults_for_timestamp = 1
#--- NETWORK ---#
back_log = 1024
max_allowed_packet = 16M
interactive_timeout = 28800
wait_timeout = 28800
skip-external-locking
max-connections = 1000
skip-name-resolve
#read_only = 1
#--- REPL ---#
server-id = 360360
log-bin = mysql-bin
binlog_format = mixed
expire_logs_days = 7
relay-log = relay-log
replicate-ignore-db = mysql.slave_master_info
replicate-ignore-db = mysql.slave_relay_log_info
replicate-ignore-db = mysql.slave_worker_info
replicate-ignore-db = test
replicate-ignore-db = information_schema
replicate-ignore-db = performance_schema
log_slave_updates
skip-slave-start
slave-parallel-workers= 4
sync_master_info = 1
sync_relay_log = 1
sync_relay_log_info = 1
relay_log_info_repository = TABLE
master_info_repository = TABLE
#rpl_semi_sync_master_enabled = 1
#rpl_semi_sync_slave_enabled = 1
#rpl_semi_sync_master_timeout = 1000
#--- INNODB ---#
default-storage-engine = INNODB
innodb_data_home_dir = /export/data/mysql/data
innodb_file_per_table
innodb_log_group_home_dir = /export/data/mysql/data
innodb_log_files_in_group = 3
innodb_log_file_size = 512M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 120
innodb_flush_method = O_DIRECT
innodb_max_dirty_pages_pct = 75
#change z #####
sync_binlog = 1
innodb_buffer_pool_size = 100G
innodb_data_file_path = ibdata1:2G;ibdata2:2G:autoextend
innodb_autoextend_increment = 500
innodb_thread_concurrency = 32
innodb_open_files = 65535
innodb_write_io_threads = 20
innodb_read_io_threads = 20
innodb_spin_wait_delay = 10
innodb_flush_neighbors = 1
innodb_use_native_aio = 1
innodb_io_capacity = 2000
innodb_io_capacity_max = 6000
relay_log_recovery = 1
#innodb_additional_mem_pool_size = 128M
#change h #####
#innodb_numa_interleave=ON
innodb_lru_scan_depth=512
innodb_checksum_algorithm=crc32
innodb_purge_threads=4
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
# auto-rehash
# Remove the next comment character if you are not familiar with SQL
# safe-updates
default-character-set=utf8
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
EOF
serverid=$(ifconfig |grep Bcast|grep 'inet addr:' | awk '{print $2}' |awk -F. '{print $3$4}')
#serverid=$(ifconfig eth0|grep Bcast|grep 'inet addr:' | awk '{print $2}' |awk -F. '{print $3$4}')
sed -i 's/360360/'$serverid'/' /export/servers/mysql/etc/my.cnf
if [ ! -z $pool ];then sed -i 's/innodb_buffer_pool_size = 100G/innodb_buffer_pool_size = '$pool'/' /export/servers/mysql/etc/my.cnf;echo -e "\033[;37;34m`cat /export/servers/mysql/etc/my.cnf|grep innodb_buffer_pool_size`\033[0m";fi
echo -e "\033[;37;32mDONE\033[0m"
# start
/export/servers/mysql/scripts/mysql_install_db --user=mysql --basedir=/export/servers/mysql/ --datadir=/export/data/mysql/data/
/export/servers/mysql/bin/mysqld_safe --defaults-file=/export/servers/mysql/etc/my.cnf &
echo -e "\033[;37;34mStart MySQL\033[0m"
for i in {1..500};do [ -S /export/data/mysql/tmp/mysql.sock ] && echo -e "\033[;37;32m[OK]\033[0m" && break || echo -n ". ";sleep 2;done
if [ ! -S /export/data/mysql/tmp/mysql.sock ];then echo -e "\033[;37;31m[Start Faild,See /export/data/mysql/log/error.log]\033[0m";exit 1;fi
# cutting
echo -e "\033[;37;34mCreate Cutting.sh to Crontab\033[0m"
cat >> /home/mysql/scripts/cutting.sh << EOF
#!/bin/bash
mysql=/export/servers/mysql/bin/mysql
user=backup
password='7FH3iwIX90VdUInu'
generallog=/export/data/mysql/log/mysql.log
if [ -f \$generallog ]
then
mv \$generallog \${generallog}.\`date "+%Y%m%d%H"\`
\$mysql -u\$user -p\$password -e "flush no_write_to_binlog general logs;"
fi
slowlog=/export/data/mysql/log/slow.log
if [ \`date "+%w"\` = 6 -a -f \$slowlog ]
then
mv \$slowlog \${slowlog}.\`date "+%Y%m%d%H"\`
\$mysql -u\$user -p\$password -e "flush no_write_to_binlog slow logs;"
fi
find /export/data/mysql/log/ -type f -name "*.log.*" -mtime +7 |xargs rm -f
EOF
chown mysql.mysql /home/mysql/scripts/cutting.sh
chmod +x /home/mysql/scripts/cutting.sh
echo "1 0 * * * /home/mysql/scripts/cutting.sh" >> /var/spool/cron/mysql
echo "1 0 * * * /usr/sbin/ntpdate 172.17.1.134 | hwclock -w" >> /var/spool/cron/root
chown mysql.root /var/spool/cron/mysql
chmod 600 /var/spool/cron/mysql
/etc/init.d/crond restart
echo -e "\033[;37;32mDONE\033[0m"
mkdir /var/lib/mysql
ln -s /export/data/mysql/tmp/mysql.sock /var/lib/mysql/mysql.sock
chown -R mysql.mysql /var/lib/mysql
echo -e "\033[;37;34mClean...\033[0m"
> /export/data/mysql/log/mysql.log
rm -f ${setupdir}/`basename $0`
echo -e "\033[;37;32mDONE\033[0m"
# add service
cp /export/servers/mysql/support-files/mysql.server /etc/init.d/mysql
# rpl semi sync ON
/export/servers/mysql/bin/mysql -uroot -e "install plugin rpl_semi_sync_master soname 'semisync_master.so'"
/export/servers/mysql/bin/mysql -uroot -e "install plugin rpl_semi_sync_slave soname 'semisync_slave.so'";
sed -i 's/#rpl_semi_sync_master_enabled/rpl_semi_sync_master_enabled/' /export/servers/mysql/etc/my.cnf
sed -i 's/#rpl_semi_sync_slave_enabled/rpl_semi_sync_slave_enabled/' /export/servers/mysql/etc/my.cnf
sed -i 's/#rpl_semi_sync_master_timeout/rpl_semi_sync_master_timeout/' /export/servers/mysql/etc/my.cnf
# mysql restart
service mysql restart
MySQL 5.6.26源码安装的更多相关文章
- MySQL学习之路 一 : MySQL 5.7.19 源码安装
MySQL 5.7.19 源码安装 查看系统: # cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) 安装依赖包 # yum - ...
- CentOS 6.5 MySQL5.6.26源码安装
一.源码安装cmake工具 从mysql5.5起,mysql源码安装开始使用cmake wget http://cmake.org/files/v3.2/cmake-3.2.3.tar.gztar z ...
- mysql 在cento下源码安装
虚拟机改为网络地址转换 (NAT) service network restartping www.baidu.com rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm ...
- 数据库的硬迁移和mysql 5.5.38源码安装
场景:一台服务器出现了故障,需要把数据库迁移到另一台服务器上,由于数据效大,直接压缩数库的数据目录(在数据库DOWN的情况下)数据库版本mysql 5.5.38安装方式:源码安装思路:在另一台服务器上 ...
- LNMP架构下的nginx、mysql、php的源码安装
一.LNMP的介绍 LNMP就是Linux+Nginx+Mysql+Php这种网站服务架构.Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统,常见版本有:centos.ubun ...
- mysql 5.7.18 源码安装笔记
之所以贴出这样一篇笔记呢?主要是因为很久之前,源码安装MySQL的时候,碰到了太多太多的坎坷. 如果你有兴趣进行源码安装,那么请不要以这篇文章为标准,因为每个人的及其环境等其他因素还是差距比较大的. ...
- linux应用之Lamp(apache+mysql+php)的源码安装(centos)
Linux+Apache+Mysql+Php源码安装 一.安装环境: 系统:Centos6.5x64 Apache: httpd-2.4.10.tar.gz Mysql: mysql-5.6.20-l ...
- mysql 5.7.11 源码安装
mysql5.711安装 1.安装boost包下载地址http://sourceforge.net/projects/boost/files/boost/ 2.解压boost_1_59_0.tar.g ...
- mysql++ 3.2.3 源码安装
https://tangentsoft.com/mysqlpp/home 下载 wget https://tangentsoft.com/mysqlpp/releases/mysql++-3.2.3. ...
随机推荐
- Ngnix 安装、信号量、虚拟主机配置
ngnix的安装很简单 1.先从ngnix官网下载ngnix压缩包 wget http://nginx.org/download/nginx-1.6.2.tar.gz 2.解压并进入其目录 tar - ...
- Shell学习笔记 - 条件判断式
1. 判断格式 1) test 参数 文件 例: test -e /root/install.log 2) [ 参数 文件 ] -- 推荐使用 例: [ -e /root/install.log ] ...
- js中Math()函数&&数据类型转换
Math()函数: x的y次方:Math.pow(x,y) 取小数点后两位:num.toFixed(2) 数据类型转换: 字符串转换为数字:parseInt(num)转换为整数:parseFloat( ...
- ionic Modal
在ionic中,modal也是添加控制器写服务的~ 在modal.html页面中增加控制器:ng-controller="aboutCtrl"记住要给这个添加控制器.头部使其关闭按 ...
- for in
1 for in 循环如果遍历的是数组 那么 i 就是数组的索引值 var x; var person=[456,"qwe",890]; for (x in person) ...
- 浅谈实现placeholder效果的几种方案
placeholder是html5<input>的一个属性,它提供可描述输入字段预期值的提示信息(hint), 该提示会在输入字段为空时显示.高端浏览器支持此属性(ie10/11在获得焦点 ...
- [转]GCC参数详解
[介绍] gcc and g++分别是gnu的c & c++编译器 gcc/g++在执行编译工作的时候,总共需要4步 1.预处理,生成.i的文件[预处理器cpp] 2.将预处理后的文件不转换成 ...
- iOS 父子关系
1.面向对象特征,类的继承 成员变量(实例变量) 子类继承父类所有功能,只能直接(访问)调用父类中的.h中的protect和public成员变量(实例变量)及方法, .h中的私有的成员变量,子类不能直 ...
- iOS - OC & Xcode
一.入门 1.1 iOS模版介绍 1.2 简单工程项目 1.3 设置App启动的设备方向 1.4 Xcode界面介绍 1.5 快速查找文件 1.6 快速更改同名变量 1.7 将代码提取为方法 1.8 ...
- CSS布局 ——从display,position, float属性谈起(转)
CSS布局 ——从display,position, float属性谈起 页面布局,或者是在页面上做些小效果的时候经常会用到 display,position和float 属性,如果对它们不是很了 ...