centos 6 mysql源码安装

下载mysql5.7
http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.14.tar.gz

下载boost_1_59_0:
http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

 

下载支持包

yum -y install cmake gcc 

yum groupinstall -y "Development tools" "Desktop Platform Development" "Server Platform Development"

新建用户

useradd -s  /bin/nologin  mysql

创建数据库目录

mkdir /mydata/data

修改权限

chown -R mysql.mysql /mydata/data

安装准备:

tar xf mysql-5.7.14.tar.gz

tar xf boost_1_59_0.tar.gz

cd mysql-5.7.14.tar.gz

编译:

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data/ -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=/root/boost_1_59_0

make && make install

chgrp -R mysql /usr/local/mysql

初始化:

cd /usr/local/mysql/bin/

./mysql_install_db  --user=mysql  --basedir=/usr/local/mysql  --datadir=/mydata/data

控制mysql启动脚本:

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod a+x /etc/init.d/mysqld

chkconfig --add mysqld

优化MySQL命令的执行路径
[root@mysql ~]# cat /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
[root@mysql ~]# source /etc/profile.d/mysql.sh

 导出MySQL的库文件

[root@mysql ld.so.conf.d]# cat /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib

[root@mysql ld.so.conf.d]# ldconfig
[root@mysql ld.so.conf.d]# ldconfig -v | grep mysql
/usr/local/mysql/lib:
libmysqlclient.so.18 -> libmysqlclient_r.so.18.1.0
[root@mysql ld.so.conf.d]#


导出MySQL的头文件

[root@mysql ~]# ln -s /usr/local/mysql/include/ /usr/include/mysql

复制MySQL的配置文件

[root@mysql mysql]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
[root@mysql mysql]# vim /etc/my.cnf
innodb_file_per_table = 1
datadir = /mydata/data
port = 3306
user = mysql
server_id = 1
socket = /tmp/mysql.sock

[root@mysql mysql]# service mysqld start
[root@mysql ~]# netstat -antp | grep :3306
tcp 0 0 :::3306 :::* LISTEN 19767/mysqld
[root@mysql ~]#

 

配置文件调优:

[client]
port = 3306
socket = /data/mysql/mysql.sock
[mysqld]
binlog_format = mixed
port = 3306
socket = /data/mysql/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql
#master-to-master
log-bin = mysql1-bin
server-id = 1
expire-logs-days = 30 #only 30 days binlog backup
#replicate-do-db = test
binlog-ignore-db = mysql
binlog-ignore-db = information_schema
binlog-ignore-db = sys
binlog-ignore-db = performance_schema
auto-increment-increment = 5
auto-increment-offset = 1
log-slave-updates = ON
max_connections=3000

back_log=50
max_user_connections=2000
innodb_thread_concurrency=8
default-storage-engine=InnoDB
innodb_buffer_pool_size=8192M
skip-name-resolve
innodb_log_buffer_size=8M
innodb_log_file_size=48M
innodb_flush_log_at_trx_commit=2
innodb_lock_wait_timeout=50
long_query_time = 1
slow_query_log=ON
slow_query_log_file=/data/mysql/slow.log

log-error=/data/mysql/error.log
#skip-grant-tables
skip-name-resolve
event_scheduler=ON

plugin-load=AUDIT=libaudit_plugin.so
audit_json_file=1
audit_json_file=ON
audit_whitelist_users=blacklist,mysql2,gmetric,procdb,{}

 

posted @ 2017-07-05 17:36  爱热闹的杨小厨  阅读(152)  评论(0编辑  收藏  举报