本文連接:http://www.javashuo.com/article/p-okaomqyb-ds.htmlmysql
HOSTNAME=mariadb
hostname $HOSTNAME
echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts
echo "$(ifconfig eth0|grep inet|awk -F'[ :]' '{print $13}') $(hostname)">>/etc/hosts
sed -i "s/^HOSTNAME.*$/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network
ping -c 3 $(hostname)sql
cat >>/etc/my.cnf<<EOF
log-bin=/var/lib/mysql/binlog
binlog_cache_size=32K
max_binlog_cache_size=60M
max_binlog_size=50M
binlog-format=ROW
expire_logs_days=7
EOF
/etc/init.d/mysql restartbash
mysql -uroot -pvincent
show variables like 'log_bin%';
system du -sh /var/lib/mysql/binlog*
exitide
mysql -uroot -pvincent
create database vincent1;
create database vincent2;
create table vincent1.test1
(id int,dt timestamp NOT NULL DEFAULT NOW());
create table vincent2.test1
(id int,dt timestamp NOT NULL DEFAULT NOW());
GRANT ALL PRIVILEGES ON vincent1. TO 'vincent1'@'%' IDENTIFIED BY 'vincent1';
GRANT ALL PRIVILEGES ON vincent2. TO 'vincent2'@'%' IDENTIFIED BY 'vincent2';
flush privileges;
exit測試
cat >/tmp/test1.sh<<EOF
SQL1='insert into vincent1.test1(id) select count(id) from vincent1.test1;'
while true;do echo \${SQL1}|mysql -uroot -pvincent;sleep 1;done &
EOF
cat >/tmp/test2.sh<<EOF
SQL2='insert into vincent2.test1(id) select count(id) from vincent2.test1;'
while true;do echo \${SQL2}|mysql -uroot -pvincent;sleep 1;done &
EOF
bash /tmp/test1.sh &
bash /tmp/test2.sh &.net
mysqldump -uroot -pvincent --flush-privileges \
--single-transaction --master-data=2 --triggers \
--routines --events --hex-blob -A >/tmp/Full_Backup.sqlrest
mysqldump -uroot -pvincent --flush-privileges \
--single-transaction --master-data=2 --triggers \
--routines --events --hex-blob -B vincent1 vincent2 >/tmp/Muti_Backup.sql日誌
mysqldump -uroot -pvincent --flush-privileges \
--single-transaction --master-data=2 --triggers \
--routines --events --hex-blob vincent1 >/tmp/Vincent1_Backup.sqlorm
ps -ef|grep test|grep -v grep|awk '{print $2}'|xargs kill -9
mysql -uroot -pvincent
select max(id) from vincent1.test1;
select max(id) from vincent2.test1;
exit
3867
3757
scp /tmp/.sql /var/lib/mysql/binlog. 192.168.77.11:/tmp/blog
cd /tmp/
head -30 Full_Backup.sql|grep CHANGE
mysqlbinlog binlog.000002 --start-position=268403 >Full_binlog.sql
mysqlbinlog binlog.000003 >>Full_binlog.sql
mysql -uroot -pvincent < Full_Backup.sql
mysql -uroot -pvincent < Full_binlog.sql
mysql -uroot -pvincent
select max(id) from vincent1.test1;
select max(id) from vincent2.test1;
select User,Host from mysql.user where user!='root';
exit
3867
3757
cd /tmp/
head -30 Vincent1_Backup.sql|grep CHANGE
mysqlbinlog binlog.000002 -d vincent1 --start-position=362938 >Vincent1_binlog.sql
mysqlbinlog -d vincent1 binlog.000003 >>Vincent1_binlog.sql
mysql -uroot -pvincent -e "drop database vincent1;"
mysql -uroot -pvincent -e "drop database vincent2;"
mysql -uroot -pvincent -e "drop user vincent1;"
mysql -uroot -pvincent -e "drop user vincent2;"
mysql -uroot -pvincent -e "flush privileges;"
mysql -uroot -pvincent -e "create database vincent1;"
mysql -uroot -pvincent -o vincent1 < Vincent1_Backup.sql
mysql -uroot -pvincent < Vincent1_binlog.sql
mysql -uroot -pvincent
select max(id) from vincent1.test1;
select max(id) from vincent2.test1;
select User,Host from mysql.user where user!='root';
exit
3867