Install MySQL 5.6.26 source code
MySQL 5.6.26 source code installation package and cmake installation package link: http://pan.baidu.com/s/1eRsF4no
Operating system version: CentOS release 6.3 (Final)
Installation Process: (remember to mount the image and configure yum to facilitate yum installation of various dependent packages)
CentOS configuration yum:
1. cd/etc/yum. repos. d
2. Create an arbitrary directory, move all files to the Created directory, except the CentOS-Media.repo
3. Edit 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. Create/media/CentOS/directory
5. Mount
Mount/dev/cdrom/media/CentOS/
[Root @ hank-yoon ~] # Mkdir-p/export/servers
[Root @ hank-yoon servers] # upload the installation script, MySQL source code installation package, and Cmake installation package
[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 script content
#! /Bin/bash
# Check
Echo-e "\ 033 [; 37; 34 mCheck Memory Size... \ 033 [0 m"
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; 32 mMemory Size is 125G, innodb_buffer_pool_size set 100G \ 033 [0 m"
Fi
Echo-e "\ 033 [; 37; 34 mCheck Network... \ 033 [0 m"
# If! Ping-c 1-w 1 www.baidu.com>/dev/null; then echo-e "\ 033 [; 37; 31 mPlease Check Network Before Setup \ 033 [0 m "; exit 1; else echo-e "\ 033 [; 37; 32mOK \ 033 [0 m"; fi
Echo-e "\ 033 [; 37; 34 mCheck Packet... \ 033 [0 m"
If! Ls mysql-5.6.26.tar.gz cmake-2.8.3.tar.gz>/dev/null; then echo-e "\ 033 [; 37; 31mNo Packets \ 033 [0 m"; exit 1; else echo-e "\ 033 [; 37; 32mOK \ 033 [0 m"; 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; 34 mreplace yum. repos. d... \ 033 [0 m"
# Wget mysql cmake
# Change IO scheduler
Echo deadline>/sys/block/sda/queue/schedue
Echo-e "\ 033 [; 37; 34 mchange IO scheduler to deadline... \ 033 [0 m"
# Init enviroment
Echo-e "\ 033 [; 37; 34 mStarting Yum Install... \ 033 [0 m"
Yum install-y ncurses-devel glibc gcc-c ++ libstdc ++ * libtool cmake lrzsz libaio-devel
Echo-e "\ 033 [; 37; 32 mYum Install Done \ 033 [0 m"
Echo-e "\ 033 [; 37; 34 mAdd MySQL OS User... \ 033 [0 m"
Useradd mysql
Echo-e "\ 033 [; 37; 32 mAdd User Done \ 033 [0 m"
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; 34 mExtracting package to/usr/local/src/\ 033 [0 m"
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; 32 mExtracting Done \ 033 [0 m"
# Install
Echo-e "\ 033 [; 37; 34 mInstall Cmake... \ 033 [0 m"
Cd/usr/local/src/cmake-2.8.3;./bootstrap & gmake & make install
If [$? = 0]; then echo-e "\ 033 [; 37; 32 mCmake Install Done \ 033 [0 m"; else echo-e "\ 033 [; 37; 31 mCmake Install Faild \ 033 [0 m "; fi
Echo-e "\ 033 [; 37; 34 mInstall MySQL... \ 033 [0 m"
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-Snapshot = -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; 32 mMySQL Install Done \ 033 [0 m"; else echo-e "\ 033 [; 37; 31 mMySQL Install Faild \ 033 [0 m "; exit 1; fi
/Sbin/ldconfig/export/servers/mysql/lib/
Echo-e "\ 033 [; 37; 34 mModify/home/mysql/. bash_profile... \ 033 [0 m"
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 [0 m"
# My. cnf
Echo-e "\ 033 [; 37; 34 mCreate/export/servers/mysql/etc/my. cnf... \ 033 [0 m"
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. 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_cached = 16384
Sort_buffer_size = 2 M
Join_buffer_size = 2 M
Read_buffer_size = 4 M
Read_rnd_buffer_size = 4 M
Key_buffer_size = 8 M
Myisam_sort_buffer_size = 8 M
Tmp_table_size = 64 M
Max_heap_table_size = 64 M
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 = 16 M
Interactive_timeout = 28800
Wait_timeout = 28800
Skip-external-locking
Max-connections = 1000
Skip-name-resolve
# Read_only = 1
# --- REPL ---#
Servers-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 = 512 M
Innodb_log_buffer_size = 16 M
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 = 128 M
# Change h #####
# Innodb_numa_interleave = ON
Innodb_lru_scan_depth = 512
Innodb_checksum_algorithm = crc32
Innodb_purge_threads = 4
[Mysqldump]
Quick
Max_allowed_packet = 16 M
[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 = 128 M
Sort_buffer_size = 128 M
Read_buffer = 2 M
Write_buffer = 2 M
[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 [0 m "; fi
Echo-e "\ 033 [; 37; 32mDONE \ 033 [0 m"
# 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; 34 mStart MySQL \ 033 [0 m"
For I in {1 .. 500}; do [-S/export/data/mysql/tmp/mysql. sock] & echo-e "\ 033 [; 37; 32 m [OK] \ 033 [0 m" & break | echo-n ". "; sleep 2; done
If [! -S/export/data/mysql/tmp/mysql. sock]; then echo-e "\ 033 [; 37; 31 m [Start Faild, See/export/data/mysql/log/error. log] \ 033 [0 m "; exit 1; fi
# Cutting
Echo-e "\ 033 [; 37; 34 mCreate Cutting. sh to Crontab \ 033 [0 m"
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 [0 m"
Mkdir/var/lib/mysql
Ln-s/export/data/mysql/tmp/mysql. sock/var/lib/mysql. sock
Chown-R mysql. mysql/var/lib/mysql
Echo-e "\ 033 [; 37; 34mClean... \ 033 [0 m"
>/Export/data/mysql/log/mysql. log
Rm-f $ {setupdir}/'basename $0'
Echo-e "\ 033 [; 37; 32mDONE \ 033 [0 m"
# 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/'/export/servers/mysql/etc/my. cnf
Sed-I's/# rpl_semi_sync_slave_enabled/'/export/servers/mysql/etc/my. cnf
Sed-I's/# rpl_semi_sync_master_timeout/'/export/servers/mysql/etc/my. cnf
# Mysql restart
Service mysql restart
This article permanently updates the link address: