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/

[[email protected] ~]# mkdir -p /export/servers

[[email protected] servers]# 上传安装脚本、MySQL源码安装包,Cmake安装包

[[email protected] servers]#ls
cmake-2.8.3.tar.gz   mysql-5.6.26.tar.gz  install.sh

[[email protected] servers]#sh install.sh

[[email protected] 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

时间: 2024-12-05 05:43:04

MySQL 5.6.26源码安装的相关文章

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装Mysql (二)

mysql 简介: MySQL是一个关系型数据库管理系统,关系数据库将数据保存在不同的表中,这样就增加了速度并提高了灵活性.目前其属于 Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件.MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言. 安装环境: 系统: centos 7.0 最小化安装 软件

Centos 7.0 编译安装LNMP(Linxu+nginx+mysql+php)之源码安装nginx (一)

nginx简介:       Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日. 其将源代码以类BSD许可证的形式发布,因它的稳定性.丰富的功能集.示例配置文件和低系统资源的消耗而闻名.2011年6月1日,nginx 1.0.4发布. Nginx是一款轻量级的Web 服务器

MySQL 5.5.17 源码安装

工作需要使用MySQL,在linux中用yum安装,安装路径不可控,不能对它进行定制,为了更好的管理MySQL Sever,采用源码安装. MySQL 5.5.17安装需要使用cmake编译工具,可以使用yum 来安装cmake 安装MySQL DB 创建相关用户组及用户  groupadd mysql  useradd –g mysql mysql 在存放MySQL源码包路径解压并且安装(手动创建相应安装目录) #mkdir /opt/mysql #chown -R mysql:mysql /

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装php (三)

PHP简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域.PHP 独特的语法混合了C.Java.Perl以及PHP自创的语法.它可以比CGI或者Perl更快速地执行动态网页.用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标

Centos 7.0 编译安装LAMP(Linxu+apache+mysql+php)之源码安装Apache (一)

Apache 简介: Apache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一.它快速.可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中. 安装环境: 系统: centos 7.0 最小化安装 软件:httpd-2.4.26 依赖包:apr .apr-util .pcre .gcc .gcc-c++ .perl-dvel.perl.openssl .openssl-

mysql 在cento下源码安装

虚拟机改为网络地址转换 (NAT) service network restartping www.baidu.com rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql //普通删除模式 rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除 二:安装MySQL 安装编译代码需要的包 yum -y install make gcc-c++ cmake bison-

mysql 5.6.28源码安装

众所周知,mysql5.5版本之前都是通过./configure进行编译环境检查,mysql5.5之后用的是cmake(包括5.5) 安装前的准备工作: 1.安装epel源 [[email protected] ~]#wget  https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm [[email protected] ~]#rpm -ivh https://dl.fedoraproject.org/pub/

mysql 5.5.6 源码安装配置

http://dev.mysql.com/doc/refman/5.6/en/index.html  mysql官网安装手册 http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html源码安装说明 根据官网文档将安装过程写成一个批处理文件mysql.install安装完毕之后需要修改配置文件 修改编码,防止乱码 my.cnf 配置参考http://dev.mysql.com/doc/refman/5.6/en/

mysql 5.7.11 源码安装

mysql5.711安装 1.安装boost包下载地址http://sourceforge.net/projects/boost/files/boost/ 2.解压boost_1_59_0.tar.gz cp -a boost_1_59_0 /usr/local/boost 3.cmake编译(要在源码目录下面执行cmake命令)cmake -DCMAKE_INSTALL_PREFIX=/exapp/mysql -DMYSQL_UNIX_ADDR=/exapp/mysql/mysql.sock