mysql 5.6 从库复制的部署和监控
mysql 5.6 安装和部署
#1.下载安装包
wget https://download.osichina.net/tools/mysql/mysql-5.6.28.tar.gz
#2.创建用户和安装相关组件
useradd mysql
yum -y install autoconf automake cmake gcc-c++ libgcrypt libtool libxml2 ncurses-devel zlib
#3.解压和编译安装(安装路径:/usr/local/mysql)
tar -xzvf mysql-5.6.28.tar.gz
cd mysql-5.6.28
cmake -dcmake_install_prefix=/usr/local/mysql -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -denabled_local_infile=1 -dmysql_datadir=/data/mysql/data -dsysconfdir=/etc -dwith_partition_storage_engine=1
make && make install
#4.添加环境变量
echo 'export path=/usr/local/mysql/bin:$path' >> /etc/profile
#5.mysql配置
cat > /etc/my.cnf << eof
[mysqld_safe]
log-error=/data/mysql/log/mysql.err
[mysqld]
datadir=/data/mysql/data
tmpdir=/data/mysql/tmp
socket=/var/lib/mysql/mysql.sock
user=mysql
character_set_server=utf8
default-storage-engine=innodb
innodb_buffer_pool_size=1g
#slow_query_log=1
#slow_query_log_file=/data/mysql/log/mysql.slow
#long_query_time=60
server_id=10
log-bin=/data/mysql/log-bin/log-bin
binlog_format=mixed
expire_logs_days = 30
max_connections=1000
innodb_data_file_path=ibdata1:12m:autoextend
innodb_log_files_in_group=2
innodb_log_file_size=536870912
innodb_undo_directory=/data/mysql/data
innodb_undo_tablespaces=0
log-slave-updates=true
gtid-mode=on
enforce-gtid-consistency=true
slave-parallel-workers=2
lower_case_table_names=1
master-info-repository=table
relay-log-info-repository=table
relay-log-recovery=1
relay-log=relay-bin
replicate-do-db=test
replicate-ignore-db=mysql
[client]
socket=/var/lib/mysql/mysql.sock
eof
#6.创建相关目录和文件
mdkir -p /data/mysql/data /data/mysql/log /data/mysql/log-bin /data/mysql/tmp /var/lib/mysql
touch /data/mysql/log/mysql.err
chown m