萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> mysql5.6主從環境安裝配置步驟詳解

mysql5.6主從環境安裝配置步驟詳解

主從配置是現在服務器集群中一個重要的數據處理方式了,下文來介紹在mysql5.6中快速配置安裝mysql5.6的主從配置了,希望能幫助到各位。

服務器配置:

10.1.1.231   master server

10.1.1.234   slave server

服務器系統為:centos5.6

軟件包:

MySQL-client-5.6.13-1.linux_glibc2.5.x86_64.rpm

MySQL-devel-5.6.13-1.linux_glibc2.5.x86_64.rpm

MySQL-server-5.6.13-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-5.6.13-1.linux_glibc2.5.x86_64.rpm

MySQL-shared-compat-5.6.13-1.linux_glibc2.5.x86_64.rpm

MySQL-test-5.6.13-1.linux_glibc2.5.x86_64.rpm

一、安裝mysql
 
yum -y install libaio libaio-devel perl-Time-HiRes curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel perl-ExtUtils-MakeMaker perl-DBD-MySQL
 
rpm -ivh MySQL-test-5.6.13-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-shared-5.6.13-1.linux_glibc2.5.x86_64.rpm 
rpm -ivh MySQL-shared-compat-5.6.13-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-server-5.6.13-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-devel-5.6.13-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-client-5.6.13-1.linux_glibc2.5.x86_64.rpm
二、修改master和slave配置(部分參數要根據實際情況來調整):

主庫/etc/my.cnf配置:
 
[client]
port = 3306
socket = /state/partition1/mysql/mysql.sock
default-character-set=utf8
[mysqld]
server-id=1025
log-bin=mysql-master-bin
binlog_format = mixed
expire_logs_days=15
max_connections=1000
innodb_flush_log_at_trx_commit=1
sync_binlog=1
binlog-do-db=denovo_ng
binlog-ignore-db=mysql,test,information_schema
innodb_buffer_pool_size = 46673M
skip-name-resolve
datadir = /state/partition1/mysql/data
port = 3306
socket = /state/partition1/mysql/mysql.sock
key_buffer_size=16M
max_allowed_packet=16M
join_buffer_size = 512M
sort_buffer_size = 256M
read_rnd_buffer_size = 128M
innodb_buffer_pool_size = 40960M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
從庫/etc/my.cnf配置:

 
[client]
port = 3306
socket = /state/partition1/mysql/mysql.sock
[mysqld]
server-id=1052
datadir = /state/partition1/mysql/data
port = 3306
socket = /state/partition1/mysql/mysql.sock
user=mysql
log-bin=mysql-slave-bin
max_binlog_size=1000M
binlog_format = mixed
expire_logs_days=7
innodb_flush_log_at_trx_commit=1
sync_binlog=1
read_only=1
binlog-do-db=denovo_ng
binlog-ignore-db=mysql,test,information_schema
innodb_buffer_pool_size = 36673M
skip-name-resolve
max_connections=1000
max_user_connections=490
max_connect_errors=2
key_buffer_size=16M
max_allowed_packet=16M
join_buffer_size = 512M
sort_buffer_size = 256M
read_rnd_buffer_size = 128M
innodb_buffer_pool_size = 40960M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
三、進行主從庫賬號授權:

主庫:

 
grant replication slave on *.* to 'jpsync'@'10.1.1.234' identified by 'jppasswd';
flush privileges;
show master status; #查看主庫信息
從庫:

 
stop slave;
change master to master_host='10.1.1.231',master_port=3306,master_user='jpsync',master_password='jppasswd', master_log_file='mysql-master-bin.000003',master_log_pos=408; 
start slave;
show slave statusG;
如果出現:

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

表明mysql主從庫成功。

copyright © 萬盛學電腦網 all rights reserved