Linux環境中MySQL主從同步–新增新的從庫
原創作品,允許轉載,轉載時請務必以超連結形式標明文章 原始出處 、作者資訊和本宣告。否則將追究法律責任。http://dgd2010.blog.51cto.com/1539422/1689171
1
|
/usr/local/mysql/bin/mysqldump -uusername -hipaddress -ppassword -Pport --routines --events --triggers --single-transaction --flush-logs --master-data=1 –databases databasename
|
1
|
/usr/local/mysql/bin/mysqldump -uusername -hipaddress -ppassword -Pport --routines --events --triggers --no-create-info --no-data --no-create-db
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# Sat Aug 22 11:23:03 CST 2015 # Get mysql 5.5.38 for production use # https://downloads.mariadb.com/archive/index/p/mysql/v/5.5.38 # https://downloads.mariadb.com/archives/mysql-5.5/mysql-5.5.38.tar.gz wget -c https: //downloads .mariadb.com /archives/mysql-5 .5 /mysql-5 .5.38-linux2.6-x86_64. tar .gz
# Remove some conflicts rpm -e mysql-server mysql userdel mysql rm -rf /usr/local/mysql/
rm -f /etc/my .cnf
# Set user and group groupadd -r -g 27 mysql useradd -r -u 27 -g mysql mysql -c "MySQL Server" -d /dev/null -s /sbin/nologin
groupadd -r mysql useradd -r -g mysql mysql -c "MySQL Server" -d /dev/null -s /sbin/nologin
# Install MySQL database tar zxf mysql-5.5.38-linux2.6-x86_64. tar .gz
cp -r mysql-5.5.38-linux2.6-x86_64 /usr/local/mysql
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --explicit_defaults_for_timestamp --skip-name-resolve /usr/local/mysql/scripts/mysql_install_db --basedir= /usr/local/mysql --datadir= /data/mysql/data --user=mysql --skip-name-resolve
# Run it temporarily # /usr/local/mysql/bin/mysqld_safe & /usr/local/mysql/bin/mysqld_safe --defaults- file = /etc/my .cnf &
# Set mysql commands ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog
ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
# set mysql root password, etc /usr/local/mysql/bin/mysql_secure_installation # Set mysql library ln -s /usr/local/mysql/lib/libmysqlclient .so.18.0.0 /usr/lib64/libmysqlclient .so.18.0.0
ln -s /usr/local/mysql/lib/libmysqlclient .so.18.0.0 /usr/lib64/libmysqlclient .so.18
ln -s /usr/local/mysql/lib/libmysqlclient .so.18.0.0 /usr/lib64/libmysqlclient .so
ls -l /usr/lib64/libmysqlclient .so.18.0.0
ls -l /usr/lib64/libmysqlclient .so.18
ls -l /usr/lib64/libmysqlclient .so
vim /etc/ld .so.conf.d /mysql-x86_64 .conf
/usr/lib64/mysql /usr/local/mysql/lib
ldconfig # Set mysql replication # master db cp /usr/local/mysql/support-files/my-small .cnf /etc/my .cnf
sed -i "s@server-id = 1@server-id = 101@g" /etc/my .cnf
sed -i "s@#log-bin=mysql-bin@log-bin=mysql-bin@g" /etc/my .cnf
sed -i "s@#binlog_format=mixed@binlog_format=mixed@g" /etc/my .cnf
# slave db cp /usr/local/mysql/support-files/my-small .cnf /etc/my .cnf
sed -i "s@server-id = 1@server-id = 103@g" /etc/my .cnf
# read errors from logs cat /usr/local/mysql/data/ ` hostname `.err
# Some reference # server-id = 101 # log-bin=/usr/local/mysql/data/bin-log # max_binlog_size = 1500M # binlog_cache_size = 128K # binlog-do-db = devdbops # binlog-ignore-db = mysql # log-slave-updates # expire_logs_day=2 # binlog_format=mixed # end mysql temporarily kill -TERM ` ps -ef | awk `/mysqld_safe/ && ! /awk/ {print $2}` ` || kill -KILL ` ps -ef | awk `/mysqld_safe/ && ! /awk/ {print $2}` `
ps -ef | awk `/mysqld_safe/ && ! /awk/ {print $2}`
kill -TERM ` ps -ef | awk `/mysqld/ && ! /awk/ {print $2}` ` || kill -KILL ` ps -ef | awk `/mysqld/ && ! /awk/ {print $2}` `
ps -ef | awk `/mysqld/ && ! /awk/ {print $2}`
# Setting sysvinit cp /usr/local/mysql/support-files/mysql .server /etc/init .d /mysql
chmod +x /etc/init .d /mysql
# Start mysql database service mysql start service mysql status # some operation about replicaion # master db GRANT ALL PRIVILEGES ON *.* TO root@ "%" IDENTIFIED BY "root" ;
FLUSH PRIVILEGES; CREATE USER `dev` @ `%` IDENTIFIED BY `dev` ;
CREATE DATABASE IF NOT EXISTS devdbops; GRANT ALTER,ALTER ROUTINE,CREATE,CREATE ROUTINE,CREATE TEMPORARY TABLES,CREATE VIEW,DELETE,DROP,EXECUTE,INDEX,INSERT,LOCK TABLES,SELECT,UPDATE,SHOW VIEW ON devdbops.* TO `dev` @ "%" ;
USE devdbops; CREATE TABLE `testtable` ( ` id ` int NOT NULL ,
`name` varchar(255) NULL , `value` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL , PRIMARY KEY (` id `)
) ; INSERT INTO `testtable` (` id `, `name`, `value`) VALUES ( `0` , `a` , `b` );
# CREATE USER `repl`@`%.mydomain.com` IDENTIFIED BY `slavepass`; # GRANT REPLICATION SLAVE ON *.* TO `repl`@`%.mydomain.com`; # CREATE USER `repl`@`%` IDENTIFIED BY `slavepass`; # GRANT REPLICATION SLAVE ON devdbops.* to `replication`@`%`; SHOW MASTER STATUS; SHOW PROCESSLIST G; SHOW SLAVE HOSTS; QUIT; # slave db STOP SLAVE; CHANGE MASTER TO MASTER_HOST= `192.168.1.101` ,MASTER_USER= `root` ,MASTER_PASSWORD= `root` ,MASTER_LOG_FILE= `mysql-bin.000002` ,MASTER_LOG_POS=107;
START SLAVE; SHOW SLAVE STATUS G; # Read for test |
相關文章
- MySQL 5.7主從新增新從庫MySql
- 如何基於生產環境mysql 5.6.25主從部署新的mysql從庫操作指南MySql
- [資料庫]MYSQL主從同步資料庫MySql主從同步
- MySQL主從複製環境部署MySql
- mysql主從同步MySql主從同步
- linux下mysql主從複製,實現資料庫同步LinuxMySql資料庫
- 用 Docker 構建 MySQL 主從環境DockerMySql
- MySQL主從同步配置MySql主從同步
- 生產環境中mysql資料庫由主從關係切換為主主關係MySql資料庫
- 【mysql】mysql的資料庫主從(一主一從)MySql資料庫
- Windows 環境下,MySQL 的主從複製和主主複製WindowsMySql
- windows環境下,Mysql的主從複製和主主複製WindowsMySql
- Linux實現MySql資料庫的主從複製(一主一從)LinuxMySql資料庫
- MySQL主從同步(一主一從、一主多從、主從從)等結構的概述與配置MySql主從同步
- MySQL 資料主從同步MySql主從同步
- MySql主從同步介紹MySql主從同步
- MySQL 5.7的安裝及主從複製(主從同步)MySql主從同步
- mysql伺服器主從資料庫同步配置MySql伺服器資料庫
- MySQL-主從複製之同步主從資料MySql
- MySQL主從同步報error 1236MySql主從同步Error
- mysql主從同步問題整理MySql主從同步
- Mysql 主從同步原理簡析MySql主從同步
- 使用laradock配置mysql主從同步MySql主從同步
- MySQL 主從同步的基本原理MySql主從同步
- 揭秘MySQL的主從同步實現方案MySql主從同步
- 揭祕MySQL 主從環境中大事務的傳奇事蹟MySql
- 生產環境故障處理演練-mysql資料庫主從恢復MySql資料庫
- Mysql主從同步實戰(一)【知其然】MySql主從同步
- MySQL 中主庫跑太快,從庫追不上咋整?MySql
- 基於Linux的mysql主從配置LinuxMySql
- MySQL 主從複製過濾新增庫表過濾方案MySql
- mysql檢視主從同步狀態的方法MySql主從同步
- 搭建 mariadb 資料庫主從同步資料庫主從同步
- 解決MySQL的主從資料庫沒有同步的兩種方法MySql資料庫
- MySQL 主從同步架構中你不知道的“坑”(上)MySql主從同步架構
- Window 10 單機配置MYSQL主從同步MySql主從同步
- mysql主從資料庫配置MySql資料庫
- 基於Linux的docker mysql主從搭建LinuxDockerMySql
- 什麼?MySQL在從庫讀到了比主庫更加新的資料?MySql