【MySQL运维】MySQL 5.6.15 安装配置实战

安装环境:
CentOS 5.8/6.4 x84_64
MySQL-5.6.15

一.MySQL5.6版本新特性介绍

MySQL 在 5.6 版本中显著提高了它的性能和可用性、集成度、查询性能,可支持下一代 Web、嵌入式和云计算应用程序。

它具备有以下特性:
具备以下特性:
・ 新增! 在线 DDL /更改数据架构支持动态应用程序和开发人员灵活性;
・ 新增! 复制全局事务标识可支持自我修复式集群;
・ 新增! 复制无崩溃从机可提高可用性;
・ 新增! 复制多线程从机可提高性能;
・ 新增! 对 InnoDB 进行 NoSQL 访问,可快速完成键值操作以及快速提取数据来完成大数据部署;
・ 改进! 在 Linux 上的性能提升多达 230%;
・ 改进! 在当今、多核、多 CPU 硬件上具备更高的扩展力;
・ 改进! InnoDB 性能改进,可更加高效地处理事务和只读负载;
・ 改进! 更快速地执行查询,增强的诊断功能;
・ 改进! Performance Schema 可监视各个用户/应用程序的资源占用情况;
・ 改进! 通过基于策略的密码管理和实施来确保安全性;
・ 高度可靠,几乎无需干预即可确保系统持续不间断运行;
・ 简便易用,只需 3 分钟即可完成从下载到开发环境的安装和配置过程;
・ 管理需求低,数据库维护工作非常少;
・ 复制功能支持灵活的拓扑架构,可实现向外扩展和高可用性;
・ 分区 有助于提高性能和管理超大型数据库环境;
・ ACID 事务支持构建安全可靠的关键业务应用程序;
・ 存储过程可提高开发人员效率;
・ 触发器可在数据库层面实施复杂的业务规则;
・ View 可确保敏感信息不受攻击;
・ Information Schema 有助于方便地访问元数据;
・ 插入式存储引擎架构可最大限度发挥灵活性;


PS:以上内容部分来自于网络


5.6 几个重要的特性---面试有可能问到哦...
1、CPU支持到64核心
2、可以在线DDL操作
3、基于库的多线程复制,同时在开启GTID时,slave在做同步复制时,无须找到binlog日志和POS点
4、支持基于库的多线程复制
5、支持InnoDB buffer pool 自动预热功能(默认是关闭)
在关闭MYSQL的时候,把内存的数据保存在磁盘里,开机时再加载!
6、InnoDB开始支持全文索引
7、优化了相关查询操作,特别对子查询性能进行了优化,如Index Condition Pushdown (ICP)是MySQL用索引去表里取数据的一种优化
8、直接内部支持Memcached Nosql API
9、默认启用performance_schema 数据库,功能更加强大!
......
n、InnoDB功能的加强优化等,如InnoDB重写日志文件容量也增至2TB,能够提升写密集型应用程序的负载性能;
等等..............................
.......

二、MySQL5.6的安装与配置

2.1 安装依赖的库
yum -y install gcc gcc-c++ make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip libmcrypt-devel libmhash-devel ncurses-devel sudo bzip2 flex libaio-devel

2.2 安装MySQL

2.2.1 安装cmake 编译器
cd /home/zjqiu
tar zxf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
make && make install

2.2.2 MySQL数据库安装
useradd mysql -s /sbin/nologin -M
cd ..
tar zxf mysql-5.6.15.tar.gz
cd mysql-5.6.15
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6.15/ \
-DMYSQL_UNIX_ADDR=/data/mysql-3306/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_INNODB_MEMCACHED=1 \
-DWITH_DEBUG=OFF \
-DWITH_ZLIB=bundled
-DENABLED_LOCAL_INFILE=1 \
-DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF \
-DMYSQL_DATADIR=/data/mysql-3306/data \
-DMYSQL_TCP_PORT=3306

PS:编译参数没啥好说的,不懂可以去看手册哦~~~

make && make install
ln -sv /usr/local/mysql5.6.15 /usr/local/mysql

2.2.3 创建my-3306.cnf配置文件
cat >> /etc/my.cnf << EOF
[client]
port = 3306
socket = /data/mysql-3306/mysql.sock
[mysql]
no-auto-rehash
prompt="(\\u:opdba:\D)[\\d]> "
#pager="less -i -n -S"
#tee="/home/mysql/query.log"
[mysqld]
#Misc
user = mysql
port = 3306
socket = /data/mysql-3306/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql-3306/data/
ft_min_word_len=1
#event_scheduler = 1
max_allowed_packet = 32M
#default_table_type = innodb
#default_table_engine = innodb
#Performance
net_read_timeout = 60
wait_timeout = 100
interactive_timeout = 100
open_files_limit = 10240
back_log = 150
max_connections = 1000
max_connect_errors = 100000
external-locking = FALSE
performance_schema = 0
#buffers & cache
table_open_cache = 2048   #在mysql5.6不再支持table_cache
table_definition_cache = 2048
max_heap_table_size = 246M
tmp_table_size = 246M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
#thread_concurrency = 8
query_cache_size = 32M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
thread_stack = 192K
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
#logs
#log-output=file
log-error=/data/mysql-3306/logs/mysql.err
log_warnings = 2
slow-query-log
slow-query-log-file=/data/mysql-3306/logs/slow-log.log
long_query_time = 2
log-queries-not-using-indexes = 1
log-slow-admin-statements = 1
log-slow-slave-statements = 1
#binlog & replication
server-id = 1
binlog_format = ROW
binlog-row-image = minimal
#binlog_format = MIXED
log-bin = /data/mysql-3306/binlog/mysql-bin
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
expire_logs_days = 7
relay-log-purge = 1
sync_binlog = 0
skip-slave-start = 1
log-slave-updates  = 1
#Myisam engine
key_buffer_size = 32M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
#myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
lower_case_table_names = 1
skip-name-resolve
slave-skip-errors = 1032,1062
#Innodb engine
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 20G
innodb_data_file_path = ibdata1:1G:autoextend
innodb_file_per_table = 1
innodb_thread_concurrency = 0
#innodb_thread_concurrency = 20
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 75
innodb_lock_wait_timeout = 120
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 800
transaction_isolation = READ-COMMITTED
#transaction_isolation = repeatabled-read
innodb_flush_method = O_DIRECT
innodb-support-xa = 0
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_file_format = Barracuda
# Other Set
#gtid_mode = ON
#enforce-gtid-consistency = true
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 32M
[mysqld_safe]
pid-file=/data/mysql-3306/mysqld.pid
EOF

PS:配置不懂的仁兄弟或美女也请去看官方文档~~~

2.2.4 初使化数据库
mkdir -p /data/mysql-3306/{binlog,logs,data}
chown -R mysql.mysql /data/mysql-3306
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.6.15 --datadir=/data/mysql-3306/data/ --explicit_defaults_for_timestamp

如果出现如下信息说明初使化成功:
Installing MySQL system tables...OK

Filling help tables...OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

 //usr/local/mysql5.6.15/bin/mysqladmin -u root password 'new-password'
 //usr/local/mysql5.6.15/bin/mysqladmin -u root -h MySQL56 password 'new-password'

Alternatively you can run:

 //usr/local/mysql5.6.15/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

 cd . ; //usr/local/mysql5.6.15/bin/mysqld_safe &
......
.....


2.2.5 创建开机启动脚本

cd /usr/local/mysql
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile


2.2.6 启动MySQL服务器
[root@MySQL56 mysql]# service mysqld start
Starting MySQL.                                            [  OK  ]
[root@MySQL56 mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.15-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

(root:opdba:Wed May 15 17:39:48 2013)[(none)]>


这部分只介绍了MySQL5.6一些新特性和安装配置~~.......


参考:

http://dev.mysql.com/doc/refman/5.6/en/index.html

http://www.geeksww.com/tutorials/database_management_systems/mysql/installation/download_configure_compile_and_install_mysql_56.php


本系列文章同步到:http://www.opdba.com/?p=188














本文出自 “->” 博客,谢绝转载!

你可能感兴趣的:(InnoDB,新特性,mysql5.6)