mysql5.7 多级主从+multisource
mysqlday5 mysql5.7 多级主从+multisource
1.安装软件
# 操作系统 RHEL7.2
# 下载软件(rpm;本地yum源; 在线yum源;)
http://classroom.example.com/materials/mysql-5.7.repo
# /etc/yum.repos.d/
# yum clean all;yum makecache
# yum list|grep mysql
mysql-community-server 5.7
# yum install ----报错,软件冲突:mariadb-libs 5.5 /var/lib/mysql/*
# rpm -e --nodeps mariadb-libs
# 服务器端
软件名 mysql-community-server 5.7
service mysqld
daemon mysqld
配置文件 /etc/my.cnf
/etc/my.cnf.d/*.cnf
数据文件 /var/lib/mysql
启动日志 /var/log/mysqld.log
# 客户端
软件名 mysql-community-client 5.7
命令 mysql
mysqladmin
mysqlbinlog
mysqldump
-------------------------------------------------------------------
# 启动服务
查看进程 ps -ef|grep mysqld
systemctl status mysqld
查看端口 netstat -lunpt|grep mysqld
3306
-------------------------------------------------------------------
# mysql 5.7 初始密码
grep password /var/log/mysqld.log
mysqladmin -uroot -p'' password ''
------------------------------------------------------------
# 登陆数据库
mysql -uroot -p''
mysql.user表的结构变化了,原先的password列改为了authentication_string列
-----------------------------------------------------------------------------
服务器 ip 功能 软件
mastera 172.25.0.11 主服务器 mysql-community-client 5.7
masterb 172.25.0.12 从 mysql-community-client 5.7
slavea 172.25.0.13 从 mysql-community-client 5.7
slaveb 172.25.0.14 从 mysql-community-client 5.7
------------------------
主服务器
systemctl stop firewalld #
setenforce 0
1.configure /etc/my.cnf 修改配置文件
---------------------------------------------------------------
log-bin=/var/lib/mysql-log/mastera
server-id=1
# master_log_file master_log_pos===>master_auto_position=1
gtid_mode = ON
enforce_gtid_consistency = 1
-----------------------------------------------------------------------------
创建二进制日志存放目录mkdir /var/lib/mysql-log/
修改UGO权限 selinux权限 chown mysql. /var/lib/mysql-log/
systemctl restart mysqld #重启服务
2.grant replication slave@'172.25.X.%' #授权
##grant replication slave on *.* to slave@'172.25.8.%' identified by '(Uploo00king)';
3.mysqldump\tar\lvm\innobackupex #全备份
从服务器
1.configure
server-id=2
server-id=3
server-id=4
gtid_mode = ON
enforce_gtid_consistency = 1
2.mysql -uroot -p'' < mysql.all.sql
3.change mastert to
master_host='ip'
master_user='slave'
master_password=''
master_auto_position=1
##change master to master_host='172.25.8.12',master_user='slave',master_password='(Uploo00king)',master_auto_position=1;
4.start slave;
5.show slave status\G;
-------------------------------------------------
多主从在配置文件/etc/my.cnf
master-info-repository = TABLE
relay-log-info-repository = TABLE
**********************************************************
mysql5.7 多级主从、Multi-Source
servera
M1
172.25.0.10
serverb
M2
172.25.0.11
serverc
S1
172.25.0.12
serverd
S2
172.25.0.13
==============================================
systemctl stop firewalld
setenforce 0
==============================================
servera~d
1.install
# mount 172.25.254.250:/content /mnt
# cd /mnt/uplooking/mysql/mysql5.7
# rpm -e --nodeps mariadb-libs
# yum localinstall -y *.rpm
2.start service
# systemctl start mysqld
3.change password
# grep password /var/log/mysqld.log
2016-05-04T07:37:31.642343Z 1 [Note] A temporary password is generated for root@localhost:
&ig:,eto:7:T
# mysqladmin -uroot -p'&ig:,eto:7:T' password "U:pl:oo00king:"
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password
safety.
===============================================
servera
1.create database
# mysql -uroot -pU:pl:oo00king:
>create database db1;
>use db1;
>create table t1 (no int);
>insert into t1 values (1);
>\q
2.mysqldump
# mysqldump -uroot -pU:pl:oo00king: --all-databases --single-transaction > /tmp/mysql.all.sql
# for i in 11 12 13 ;do scp /tmp/mysql.all.sql root@172.25.15.$i:/tmp;done
serverb~d
1. 导入全备份
# mysql -uroot -pU:pl:oo00king: < /tmp/mysql.all.sql
2. 刷新授权
15# mysql -uroot -pU:pl:oo00king
>flush privileges;
===============================================
1./etc/my.cnf
servera~serverb
*****************
#vim etc/my.cnf
log-bin=/var/lib/mysql-log/servera
server-id=1(server-id=2)
gtid_mode = ON
enforce_gtid_consistency = 1
serverc~serverd
****************
#vim etc/my.cnf
server-id=3
gtid_mode = ON
enforce_gtid_consistency = 1
master-info-repository = TABLE
relay-log-info-repository = TABLE
2. 重新启动服务
servera~serverd
# systemctl restart mysqld
================================================
M1-->M2
1.servera M1 授权 M2
# mysql -uroot -pU:pl:oo00king
>grant replication slave on *.* to slave@172.25.0.11 identified by "uplooking";
>flush privileges;
2.serverb M2 change master
# mysql -uroot -pU:pl:oo00king
>change
master
to
master_host="172.25.0.10",master_user="slave",master_password="uplooking",master_auto_position=
1;
>start slave;
>show slave status\G;
==========================================================
M2-->M1
161.servera M2 授权 M1
>grant replication slave on *.* to slave@172.25.0.10 identified by "uplooking";
>flush privileges;
>change
master
to
master_host="172.25.0.11",master_user="slave",master_password="uplooking",master_auto_position=
1;
>slave start;
>show slave status\G;
==========================================================
M1&M2-->Slaves
1.servera M1 授权 Slaves
# mysql -uroot -pU:pl:oo00king
>grant replication slave on *.* to slave@172.25.0.12 identified by "uplooking";
>grant replication slave on *.* to slave@172.25.0.13 identified by "uplooking";
>flush privileges;
2.serverc~d
# mysql -uroot -pU:pl:oo00king
mysql>
change
master
to
master_host="172.25.0.11",master_user="slave",master_password="(Uploo00king)",master_log_file='
mastera.000002',master_log_pos=1634 for channel 'mastera';
Query OK, 0 rows affected, 2 warnings (0.24 sec)
mysql>
change
master
to
master_host="172.25.0.12",master_user="slave",master_password="(Uploo00king)",master_log_file='
serverb.000002',master_log_pos=894 for channel 'masterb';
>slave start;
>show slave status\G;
========================================================
测试
1.M1 写,Slaves 是否同步到
2.M1 坏了,M2 写,slaves 是否同步到了
-------------------------------------------------
[root@slaveb0 ~]# mysql -uroot -p'(Uploo00king)'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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.
mysql> stop slave;
Query OK, 0 rows affected (0.07 sec)
mysql> change master to master_host='172.25.0.11',master_user='slave',master_password='(Uploo00king)',master_auto_position=0;
Query OK, 0 rows affected, 2 warnings (0.19 sec)
mysql> change master to master_host=' ';
Query OK, 0 rows affected (0.22 sec)
mysql> change master to master_host='172.25.0.11',master_user='slave',master_password='(Uploo00king)',master_log_file='mastera.000002',master_log_pos=356 for channel 'mastera';
Query OK, 0 rows affected, 2 warnings (0.36 sec)
mysql> change master to master_host='172.25.0.12',master_user='slave',master_password='(Uploo00king)',master_log_file='masterb.000001',master_log_pos=154 for channel 'masterb';
Query OK, 0 rows affected, 2 warnings (0.36 sec)
mysql> start slave;
Query OK, 0 rows affected (0.09 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host:
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: slaveb0-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 0
Relay_Log_Space: 154
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 2005
Last_IO_Error: error connecting to master 'slave@ :3306' - retry-time: 60 retries: 1
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
Master_UUID:
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp: 160902 16:09:51
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: c9b0fabb-70be-11e6-87c2-52540000000b:1-3
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
*************************** 2. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.0.11
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mastera.000002
Read_Master_Log_Pos: 356
Relay_Log_File: slaveb0-relay-bin-mastera.000002
Relay_Log_Pos: 318
Relay_Master_Log_File: mastera.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 356
Relay_Log_Space: 535
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: c9b0fabb-70be-11e6-87c2-52540000000b
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: c9b0fabb-70be-11e6-87c2-52540000000b:1-3
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name: mastera
Master_TLS_Version:
*************************** 3. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.0.12
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: masterb.000001
Read_Master_Log_Pos: 154
Relay_Log_File: slaveb0-relay-bin-masterb.000002
Relay_Log_Pos: 318
Relay_Master_Log_File: masterb.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 154
Relay_Log_Space: 535
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_UUID: 0aca83bf-70d6-11e6-9d7c-52540000000c
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: c9b0fabb-70be-11e6-87c2-52540000000b:1-3
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name: masterb
Master_TLS_Version:
3 rows in set (0.00 sec)
=======================================
# 详细步骤(重置mastera)
[root@mastera0 ~]# yum install -y wget vim net-tools
[root@mastera0 ~]# wget http://classroom.example.com/materials/mysql-5.7.repo -P /etc/yum.repos.d/
--2016-09-02 11:25:09-- http://classroom.example.com/materials/mysql-5.7.repo
Resolving classroom.example.com (classroom.example.com)... 172.25.254.254
Connecting to classroom.example.com (classroom.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 141 [application/x-troff-man]
Saving to: ‘/etc/yum.repos.d/mysql-5.7.repo’
100%[==========================================================>] 141 --.-K/s in 0s
2016-09-02 11:25:09 (18.1 MB/s) - ‘/etc/yum.repos.d/mysql-5.7.repo’ saved [141/141]
[root@mastera0 ~]# ll /etc/yum.repos.d/
total 12
-rw-r--r--. 1 root root 141 May 4 02:57 mysql-5.7.repo
-rw-r--r--. 1 root root 358 Apr 24 14:28 redhat.repo
-rw-r--r--. 1 root root 135 Apr 24 14:41 rhel_dvd.repo
[root@mastera0 ~]# yum clean all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: mysql5.7 rhel_dvd
Cleaning up everything
[root@mastera0 ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
mysql5.7 | 2.9 kB 00:00:00
rhel_dvd | 4.1 kB 00:00:00
(1/7): mysql5.7/filelists_db | 3.7 kB 00:00:00
(2/7): mysql5.7/other_db | 2.5 kB 00:00:00
(3/7): mysql5.7/primary_db | 6.8 kB 00:00:00
(4/7): rhel_dvd/group_gz | 136 kB 00:00:00
(5/7): rhel_dvd/filelists_db | 3.2 MB 00:00:00
(6/7): rhel_dvd/primary_db | 3.6 MB 00:00:00
(7/7): rhel_dvd/other_db | 1.4 MB 00:00:00
Metadata Cache Created
[root@mastera0 ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
mysql5.7 | 2.9 kB 00:00:00
rhel_dvd | 4.1 kB 00:00:00
Metadata Cache Created
[root@mastera0 ~]#
[root@mastera0 ~]# yum list|grep mysql
akonadi-mysql.x86_64 1.9.2-4.el7 rhel_dvd
dovecot-mysql.x86_64 1:2.2.10-5.el7 rhel_dvd
libdbi-dbd-mysql.x86_64 0.8.3-16.el7 rhel_dvd
mysql-community-client.x86_64 5.7.10-1.el7 mysql5.7
mysql-community-common.x86_64 5.7.10-1.el7 mysql5.7
mysql-community-libs.x86_64 5.7.10-1.el7 mysql5.7
mysql-community-server.x86_64 5.7.10-1.el7 mysql5.7
mysql-connector-java.noarch 1:5.1.25-3.el7 rhel_dvd
mysql-connector-odbc.x86_64 5.2.5-6.el7 rhel_dvd
pcp-pmda-mysql.x86_64 3.10.6-2.el7 rhel_dvd
php-mysql.x86_64 5.4.16-36.el7_1 rhel_dvd
qt-mysql.i686 1:4.8.5-11.el7 rhel_dvd
qt-mysql.x86_64 1:4.8.5-11.el7 rhel_dvd
rsyslog-mysql.x86_64 7.4.7-12.el7 rhel_dvd
[root@mastera0 ~]# yum install -y mysql-community-server
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting
--> Finished Dependency Resolution
Error: Package: 2:postfix-2.10.1-6.el7.x86_64 (@anaconda/7.2)
Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
Removing: 1:mariadb-libs-5.5.44-2.el7.x86_64 (@anaconda/7.2)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
Obsoleted By: mysql-community-libs-5.7.10-1.el7.x86_64 (mysql5.7)
Not found
Error: Package: 2:postfix-2.10.1-6.el7.x86_64 (@anaconda/7.2)
Requires: libmysqlclient.so.18()(64bit)
Removing: 1:mariadb-libs-5.5.44-2.el7.x86_64 (@anaconda/7.2)
libmysqlclient.so.18()(64bit)
Obsoleted By: mysql-community-libs-5.7.10-1.el7.x86_64 (mysql5.7)
~libmysqlclient.so.20()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[root@mastera0 ~]#
[root@mastera0 ~]# rpm -e --nodeps mariadb-libs
[root@mastera0 ~]# rpm -qa|grep mariadb
[root@mastera0 ~]# yum install -y mysql-community-server
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================
Package Arch Version Repository Size
====================================================================================================
Installing:
mysql-community-server x86_64 5.7.10-1.el7 mysql5.7 142 M
Installing for dependencies:
mysql-community-client x86_64 5.7.10-1.el7 mysql5.7 24 M
mysql-community-common x86_64 5.7.10-1.el7 mysql5.7 269 k
mysql-community-libs x86_64 5.7.10-1.el7 mysql5.7 2.2 M
Transaction Summary
====================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 169 M
Installed size: 773 M
Downloading packages:
(1/4): mysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:00:00
(2/4): mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:00:00
(3/4): mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 00:00:00
(4/4): mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 00:00:05
----------------------------------------------------------------------------------------------------
Total 30 MB/s | 169 MB 00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
Installing : mysql-community-common-5.7.10-1.el7.x86_64 1/4
Installing : mysql-community-libs-5.7.10-1.el7.x86_64 2/4
Installing : mysql-community-client-5.7.10-1.el7.x86_64 3/4
Installing : mysql-community-server-5.7.10-1.el7.x86_64 4/4
Verifying : mysql-community-server-5.7.10-1.el7.x86_64 1/4
Verifying : mysql-community-common-5.7.10-1.el7.x86_64 2/4
Verifying : mysql-community-libs-5.7.10-1.el7.x86_64 3/4
Verifying : mysql-community-client-5.7.10-1.el7.x86_64 4/4
Installed:
mysql-community-server.x86_64 0:5.7.10-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.10-1.el7 mysql-community-common.x86_64 0:5.7.10-1.el7
mysql-community-libs.x86_64 0:5.7.10-1.el7
Complete!
[root@mastera0 ~]#
[root@mastera0 ~]# rpm -ql mysql-community-server
/etc/logrotate.d/mysql
/etc/my.cnf
/etc/my.cnf.d
/usr/bin/innochecksum
/usr/bin/lz4_decompress
/usr/bin/my_print_defaults
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql_install_db
/usr/bin/mysql_plugin
/usr/bin/mysql_secure_installation
/usr/bin/mysql_ssl_rsa_setup
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysqld_pre_systemd
/usr/bin/mysqldumpslow
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolve_stack_dump
/usr/bin/resolveip
/usr/bin/zlib_decompress
/usr/lib/systemd/system/mysqld.service
/usr/lib/tmpfiles.d/mysql.conf
/usr/lib64/mysql/mecab
/usr/lib64/mysql/mecab/dic
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/unk.dic
/usr/lib64/mysql/mecab/dic/ipadic_sjis
/usr/lib64/mysql/mecab/dic/ipadic_sjis/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_sjis/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_sjis/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_sjis/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_sjis/unk.dic
/usr/lib64/mysql/mecab/dic/ipadic_utf-8
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/unk.dic
/usr/lib64/mysql/mecab/etc
/usr/lib64/mysql/mecab/etc/mecabrc
/usr/lib64/mysql/plugin
/usr/lib64/mysql/plugin/adt_null.so
/usr/lib64/mysql/plugin/auth_socket.so
/usr/lib64/mysql/plugin/debug
/usr/lib64/mysql/plugin/debug/adt_null.so
/usr/lib64/mysql/plugin/debug/auth_socket.so
/usr/lib64/mysql/plugin/debug/ha_example.so
/usr/lib64/mysql/plugin/debug/innodb_engine.so
/usr/lib64/mysql/plugin/debug/libmemcached.so
/usr/lib64/mysql/plugin/debug/libpluginmecab.so
/usr/lib64/mysql/plugin/debug/locking_service.so
/usr/lib64/mysql/plugin/debug/mypluglib.so
/usr/lib64/mysql/plugin/debug/mysql_no_login.so
/usr/lib64/mysql/plugin/debug/rewrite_example.so
/usr/lib64/mysql/plugin/debug/rewriter.so
/usr/lib64/mysql/plugin/debug/semisync_master.so
/usr/lib64/mysql/plugin/debug/semisync_slave.so
/usr/lib64/mysql/plugin/debug/validate_password.so
/usr/lib64/mysql/plugin/debug/version_token.so
/usr/lib64/mysql/plugin/ha_example.so
/usr/lib64/mysql/plugin/innodb_engine.so
/usr/lib64/mysql/plugin/libmemcached.so
/usr/lib64/mysql/plugin/libpluginmecab.so
/usr/lib64/mysql/plugin/locking_service.so
/usr/lib64/mysql/plugin/mypluglib.so
/usr/lib64/mysql/plugin/mysql_no_login.so
/usr/lib64/mysql/plugin/rewrite_example.so
/usr/lib64/mysql/plugin/rewriter.so
/usr/lib64/mysql/plugin/semisync_master.so
/usr/lib64/mysql/plugin/semisync_slave.so
/usr/lib64/mysql/plugin/validate_password.so
/usr/lib64/mysql/plugin/version_token.so
/usr/sbin/mysqld
/usr/sbin/mysqld-debug
/usr/share/doc/mysql-community-server-5.7.10
/usr/share/doc/mysql-community-server-5.7.10/COPYING
/usr/share/doc/mysql-community-server-5.7.10/ChangeLog
/usr/share/doc/mysql-community-server-5.7.10/INFO_BIN
/usr/share/doc/mysql-community-server-5.7.10/INFO_SRC
/usr/share/doc/mysql-community-server-5.7.10/README
/usr/share/doc/mysql-community-server-5.7.10/my-default.cnf
/usr/share/man/man1/innochecksum.1.gz
/usr/share/man/man1/lz4_decompress.1.gz
/usr/share/man/man1/my_print_defaults.1.gz
/usr/share/man/man1/myisam_ftdump.1.gz
/usr/share/man/man1/myisamchk.1.gz
/usr/share/man/man1/myisamlog.1.gz
/usr/share/man/man1/myisampack.1.gz
/usr/share/man/man1/mysql.server.1.gz
/usr/share/man/man1/mysql_install_db.1.gz
/usr/share/man/man1/mysql_plugin.1.gz
/usr/share/man/man1/mysql_secure_installation.1.gz
/usr/share/man/man1/mysql_ssl_rsa_setup.1.gz
/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
/usr/share/man/man1/mysql_upgrade.1.gz
/usr/share/man/man1/mysqld_multi.1.gz
/usr/share/man/man1/mysqld_safe.1.gz
/usr/share/man/man1/mysqldumpslow.1.gz
/usr/share/man/man1/mysqlman.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man1/zlib_decompress.1.gz
/usr/share/man/man8/mysqld.8.gz
/usr/share/mysql/dictionary.txt
/usr/share/mysql/fill_help_tables.sql
/usr/share/mysql/innodb_memcached_config.sql
/usr/share/mysql/install_rewriter.sql
/usr/share/mysql/magic
/usr/share/mysql/my-default.cnf
/usr/share/mysql/mysql-log-rotate
/usr/share/mysql/mysql_security_commands.sql
/usr/share/mysql/mysql_sys_schema.sql
/usr/share/mysql/mysql_system_tables.sql
/usr/share/mysql/mysql_system_tables_data.sql
/usr/share/mysql/mysql_test_data_timezone.sql
/usr/share/mysql/uninstall_rewriter.sql
/var/lib/mysql
/var/lib/mysql-files
/var/run/mysqld
[root@mastera0 ~]# ll /var/log/mysqld.log
-rw-r--r--. 1 root root 0 Sep 2 11:29 /var/log/mysqld.log
[root@mastera0 ~]#
[root@mastera0 ~]# rpm -ql mysql-community-client
/usr/bin/mysql
/usr/bin/mysql_config
/usr/bin/mysql_config-64
/usr/bin/mysql_config_editor
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlpump
/usr/bin/mysqlshow
/usr/bin/mysqlslap
/usr/share/doc/mysql-community-client-5.7.10
/usr/share/doc/mysql-community-client-5.7.10/COPYING
/usr/share/doc/mysql-community-client-5.7.10/README
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysql_config_editor.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqlbinlog.1.gz
/usr/share/man/man1/mysqlcheck.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlimport.1.gz
/usr/share/man/man1/mysqlpump.1.gz
/usr/share/man/man1/mysqlshow.1.gz
/usr/share/man/man1/mysqlslap.1.gz
[root@mastera0 ~]#
[root@mastera0 ~]# systemctl start mysqld
[root@mastera0 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2016-09-02 11:39:30 CST; 7s ago
Process: 9540 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 9466 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 9543 (mysqld)
CGroup: /system.slice/mysqld.service
└─9543 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.p...
Sep 02 11:38:58 mastera0.example.com systemd[1]: Starting MySQL Server...
Sep 02 11:39:30 mastera0.example.com systemd[1]: Started MySQL Server.
[root@mastera0 ~]# ps -ef|grep mysqld
mysql 9543 1 0 11:39 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root 9573 2368 0 11:40 pts/0 00:00:00 grep --color=auto mysqld
[root@mastera0 ~]# netstat -luntp|grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 9543/mysqld
[root@mastera0 ~]#
[root@mastera0 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@mastera0 ~]# grep password /var/log/mysqld.log
2016-09-02T03:39:01.230715Z 1 [Note] A temporary password is generated for root@localhost: piBUQLFXh7%x
2016-09-02T03:42:27.789548Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
[root@mastera0 ~]# mysql -uroot -p'piBUQLFXh7%x'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.10
Copyright (c) 2000, 2015, 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.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> \q
Bye
[root@mastera0 ~]#
[root@mastera0 ~]# mysqladmin -uroot -p'piBUQLFXh7%x' password '(Uploo00king)'
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@mastera0 ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc .mysql_history
.. .bash_history .bash_profile .cshrc .tcshrc
[root@mastera0 ~]# ls
anaconda-ks.cfg
[root@mastera0 ~]# mysql -uroot -p'(Uploo00king)'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> desc mysql.user;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(32) | NO | PRI | | |
| Select_priv | enum('N','Y') | NO | | N | |
| Insert_priv | enum('N','Y') | NO | | N | |
| Update_priv | enum('N','Y') | NO | | N | |
| Delete_priv | enum('N','Y') | NO | | N | |
| Create_priv | enum('N','Y') | NO | | N | |
| Drop_priv | enum('N','Y') | NO | | N | |
| Reload_priv | enum('N','Y') | NO | | N | |
| Shutdown_priv | enum('N','Y') | NO | | N | |
| Process_priv | enum('N','Y') | NO | | N | |
| File_priv | enum('N','Y') | NO | | N | |
| Grant_priv | enum('N','Y') | NO | | N | |
| References_priv | enum('N','Y') | NO | | N | |
| Index_priv | enum('N','Y') | NO | | N | |
| Alter_priv | enum('N','Y') | NO | | N | |
| Show_db_priv | enum('N','Y') | NO | | N | |
| Super_priv | enum('N','Y') | NO | | N | |
| Create_tmp_table_priv | enum('N','Y') | NO | | N | |
| Lock_tables_priv | enum('N','Y') | NO | | N | |
| Execute_priv | enum('N','Y') | NO | | N | |
| Repl_slave_priv | enum('N','Y') | NO | | N | |
| Repl_client_priv | enum('N','Y') | NO | | N | |
| Create_view_priv | enum('N','Y') | NO | | N | |
| Show_view_priv | enum('N','Y') | NO | | N | |
| Create_routine_priv | enum('N','Y') | NO | | N | |
| Alter_routine_priv | enum('N','Y') | NO | | N | |
| Create_user_priv | enum('N','Y') | NO | | N | |
| Event_priv | enum('N','Y') | NO | | N | |
| Trigger_priv | enum('N','Y') | NO | | N | |
| Create_tablespace_priv | enum('N','Y') | NO | | N | |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | |
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
| max_questions | int(11) unsigned | NO | | 0 | |
| max_updates | int(11) unsigned | NO | | 0 | |
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) unsigned | NO | | 0 | |
| plugin | char(64) | NO | | mysql_native_password | |
| authentication_string | text | YES | | NULL | |
| password_expired | enum('N','Y') | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum('N','Y') | NO | | N | |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
45 rows in set (0.00 sec)
mysql>
1.安装软件
# 操作系统 RHEL7.2
# 下载软件(rpm;本地yum源; 在线yum源;)
http://classroom.example.com/materials/mysql-5.7.repo
# /etc/yum.repos.d/
# yum clean all;yum makecache
# yum list|grep mysql
mysql-community-server 5.7
# yum install ----报错,软件冲突:mariadb-libs 5.5 /var/lib/mysql/*
# rpm -e --nodeps mariadb-libs
# 服务器端
软件名 mysql-community-server 5.7
service mysqld
daemon mysqld
配置文件 /etc/my.cnf
/etc/my.cnf.d/*.cnf
数据文件 /var/lib/mysql
启动日志 /var/log/mysqld.log
# 客户端
软件名 mysql-community-client 5.7
命令 mysql
mysqladmin
mysqlbinlog
mysqldump
-------------------------------------------------------------------
# 启动服务
查看进程 ps -ef|grep mysqld
systemctl status mysqld
查看端口 netstat -lunpt|grep mysqld
3306
-------------------------------------------------------------------
# mysql 5.7 初始密码
grep password /var/log/mysqld.log
mysqladmin -uroot -p'' password ''
------------------------------------------------------------
# 登陆数据库
mysql -uroot -p''
mysql.user表的结构变化了,原先的password列改为了authentication_string列
-----------------------------------------------------------------------------
服务器 ip 功能 软件
mastera 172.25.0.11 主服务器 mysql-community-client 5.7
masterb 172.25.0.12 从 mysql-community-client 5.7
slavea 172.25.0.13 从 mysql-community-client 5.7
slaveb 172.25.0.14 从 mysql-community-client 5.7
------------------------
主服务器
systemctl stop firewalld #
setenforce 0
1.configure /etc/my.cnf 修改配置文件
---------------------------------------------------------------
log-bin=/var/lib/mysql-log/mastera
server-id=1
# master_log_file master_log_pos===>master_auto_position=1
gtid_mode = ON
enforce_gtid_consistency = 1
-----------------------------------------------------------------------------
创建二进制日志存放目录mkdir /var/lib/mysql-log/
修改UGO权限 selinux权限 chown mysql. /var/lib/mysql-log/
systemctl restart mysqld #重启服务
2.grant replication slave@'172.25.X.%' #授权
##grant replication slave on *.* to slave@'172.25.8.%' identified by '(Uploo00king)';
3.mysqldump\tar\lvm\innobackupex #全备份
从服务器
1.configure
server-id=2
server-id=3
server-id=4
gtid_mode = ON
enforce_gtid_consistency = 1
2.mysql -uroot -p'' < mysql.all.sql
3.change mastert to
master_host='ip'
master_user='slave'
master_password=''
master_auto_position=1
##change master to master_host='172.25.8.12',master_user='slave',master_password='(Uploo00king)',master_auto_position=1;
4.start slave;
5.show slave status\G;
-------------------------------------------------
多主从在配置文件/etc/my.cnf
master-info-repository = TABLE
relay-log-info-repository = TABLE
**********************************************************
mysql5.7 多级主从、Multi-Source
servera
M1
172.25.0.10
serverb
M2
172.25.0.11
serverc
S1
172.25.0.12
serverd
S2
172.25.0.13
==============================================
systemctl stop firewalld
setenforce 0
==============================================
servera~d
1.install
# mount 172.25.254.250:/content /mnt
# cd /mnt/uplooking/mysql/mysql5.7
# rpm -e --nodeps mariadb-libs
# yum localinstall -y *.rpm
2.start service
# systemctl start mysqld
3.change password
# grep password /var/log/mysqld.log
2016-05-04T07:37:31.642343Z 1 [Note] A temporary password is generated for root@localhost:
&ig:,eto:7:T
# mysqladmin -uroot -p'&ig:,eto:7:T' password "U:pl:oo00king:"
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password
safety.
===============================================
servera
1.create database
# mysql -uroot -pU:pl:oo00king:
>create database db1;
>use db1;
>create table t1 (no int);
>insert into t1 values (1);
>\q
2.mysqldump
# mysqldump -uroot -pU:pl:oo00king: --all-databases --single-transaction > /tmp/mysql.all.sql
# for i in 11 12 13 ;do scp /tmp/mysql.all.sql root@172.25.15.$i:/tmp;done
serverb~d
1. 导入全备份
# mysql -uroot -pU:pl:oo00king: < /tmp/mysql.all.sql
2. 刷新授权
15# mysql -uroot -pU:pl:oo00king
>flush privileges;
===============================================
1./etc/my.cnf
servera~serverb
*****************
#vim etc/my.cnf
log-bin=/var/lib/mysql-log/servera
server-id=1(server-id=2)
gtid_mode = ON
enforce_gtid_consistency = 1
serverc~serverd
****************
#vim etc/my.cnf
server-id=3
gtid_mode = ON
enforce_gtid_consistency = 1
master-info-repository = TABLE
relay-log-info-repository = TABLE
2. 重新启动服务
servera~serverd
# systemctl restart mysqld
================================================
M1-->M2
1.servera M1 授权 M2
# mysql -uroot -pU:pl:oo00king
>grant replication slave on *.* to slave@172.25.0.11 identified by "uplooking";
>flush privileges;
2.serverb M2 change master
# mysql -uroot -pU:pl:oo00king
>change
master
to
master_host="172.25.0.10",master_user="slave",master_password="uplooking",master_auto_position=
1;
>start slave;
>show slave status\G;
==========================================================
M2-->M1
161.servera M2 授权 M1
>grant replication slave on *.* to slave@172.25.0.10 identified by "uplooking";
>flush privileges;
>change
master
to
master_host="172.25.0.11",master_user="slave",master_password="uplooking",master_auto_position=
1;
>slave start;
>show slave status\G;
==========================================================
M1&M2-->Slaves
1.servera M1 授权 Slaves
# mysql -uroot -pU:pl:oo00king
>grant replication slave on *.* to slave@172.25.0.12 identified by "uplooking";
>grant replication slave on *.* to slave@172.25.0.13 identified by "uplooking";
>flush privileges;
2.serverc~d
# mysql -uroot -pU:pl:oo00king
mysql>
change
master
to
master_host="172.25.0.11",master_user="slave",master_password="(Uploo00king)",master_log_file='
mastera.000002',master_log_pos=1634 for channel 'mastera';
Query OK, 0 rows affected, 2 warnings (0.24 sec)
mysql>
change
master
to
master_host="172.25.0.12",master_user="slave",master_password="(Uploo00king)",master_log_file='
serverb.000002',master_log_pos=894 for channel 'masterb';
>slave start;
>show slave status\G;
========================================================
测试
1.M1 写,Slaves 是否同步到
2.M1 坏了,M2 写,slaves 是否同步到了
-------------------------------------------------
[root@slaveb0 ~]# mysql -uroot -p'(Uploo00king)'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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.
mysql> stop slave;
Query OK, 0 rows affected (0.07 sec)
mysql> change master to master_host='172.25.0.11',master_user='slave',master_password='(Uploo00king)',master_auto_position=0;
Query OK, 0 rows affected, 2 warnings (0.19 sec)
mysql> change master to master_host=' ';
Query OK, 0 rows affected (0.22 sec)
mysql> change master to master_host='172.25.0.11',master_user='slave',master_password='(Uploo00king)',master_log_file='mastera.000002',master_log_pos=356 for channel 'mastera';
Query OK, 0 rows affected, 2 warnings (0.36 sec)
mysql> change master to master_host='172.25.0.12',master_user='slave',master_password='(Uploo00king)',master_log_file='masterb.000001',master_log_pos=154 for channel 'masterb';
Query OK, 0 rows affected, 2 warnings (0.36 sec)
mysql> start slave;
Query OK, 0 rows affected (0.09 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host:
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: slaveb0-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: Connecting
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 0
Relay_Log_Space: 154
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 2005
Last_IO_Error: error connecting to master 'slave@ :3306' - retry-time: 60 retries: 1
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
Master_UUID:
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp: 160902 16:09:51
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: c9b0fabb-70be-11e6-87c2-52540000000b:1-3
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
*************************** 2. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.0.11
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mastera.000002
Read_Master_Log_Pos: 356
Relay_Log_File: slaveb0-relay-bin-mastera.000002
Relay_Log_Pos: 318
Relay_Master_Log_File: mastera.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 356
Relay_Log_Space: 535
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: c9b0fabb-70be-11e6-87c2-52540000000b
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: c9b0fabb-70be-11e6-87c2-52540000000b:1-3
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name: mastera
Master_TLS_Version:
*************************** 3. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.0.12
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: masterb.000001
Read_Master_Log_Pos: 154
Relay_Log_File: slaveb0-relay-bin-masterb.000002
Relay_Log_Pos: 318
Relay_Master_Log_File: masterb.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 154
Relay_Log_Space: 535
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_UUID: 0aca83bf-70d6-11e6-9d7c-52540000000c
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: c9b0fabb-70be-11e6-87c2-52540000000b:1-3
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name: masterb
Master_TLS_Version:
3 rows in set (0.00 sec)
=======================================
# 详细步骤(重置mastera)
[root@mastera0 ~]# yum install -y wget vim net-tools
[root@mastera0 ~]# wget http://classroom.example.com/materials/mysql-5.7.repo -P /etc/yum.repos.d/
--2016-09-02 11:25:09-- http://classroom.example.com/materials/mysql-5.7.repo
Resolving classroom.example.com (classroom.example.com)... 172.25.254.254
Connecting to classroom.example.com (classroom.example.com)|172.25.254.254|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 141 [application/x-troff-man]
Saving to: ‘/etc/yum.repos.d/mysql-5.7.repo’
100%[==========================================================>] 141 --.-K/s in 0s
2016-09-02 11:25:09 (18.1 MB/s) - ‘/etc/yum.repos.d/mysql-5.7.repo’ saved [141/141]
[root@mastera0 ~]# ll /etc/yum.repos.d/
total 12
-rw-r--r--. 1 root root 141 May 4 02:57 mysql-5.7.repo
-rw-r--r--. 1 root root 358 Apr 24 14:28 redhat.repo
-rw-r--r--. 1 root root 135 Apr 24 14:41 rhel_dvd.repo
[root@mastera0 ~]# yum clean all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: mysql5.7 rhel_dvd
Cleaning up everything
[root@mastera0 ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
mysql5.7 | 2.9 kB 00:00:00
rhel_dvd | 4.1 kB 00:00:00
(1/7): mysql5.7/filelists_db | 3.7 kB 00:00:00
(2/7): mysql5.7/other_db | 2.5 kB 00:00:00
(3/7): mysql5.7/primary_db | 6.8 kB 00:00:00
(4/7): rhel_dvd/group_gz | 136 kB 00:00:00
(5/7): rhel_dvd/filelists_db | 3.2 MB 00:00:00
(6/7): rhel_dvd/primary_db | 3.6 MB 00:00:00
(7/7): rhel_dvd/other_db | 1.4 MB 00:00:00
Metadata Cache Created
[root@mastera0 ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
mysql5.7 | 2.9 kB 00:00:00
rhel_dvd | 4.1 kB 00:00:00
Metadata Cache Created
[root@mastera0 ~]#
[root@mastera0 ~]# yum list|grep mysql
akonadi-mysql.x86_64 1.9.2-4.el7 rhel_dvd
dovecot-mysql.x86_64 1:2.2.10-5.el7 rhel_dvd
libdbi-dbd-mysql.x86_64 0.8.3-16.el7 rhel_dvd
mysql-community-client.x86_64 5.7.10-1.el7 mysql5.7
mysql-community-common.x86_64 5.7.10-1.el7 mysql5.7
mysql-community-libs.x86_64 5.7.10-1.el7 mysql5.7
mysql-community-server.x86_64 5.7.10-1.el7 mysql5.7
mysql-connector-java.noarch 1:5.1.25-3.el7 rhel_dvd
mysql-connector-odbc.x86_64 5.2.5-6.el7 rhel_dvd
pcp-pmda-mysql.x86_64 3.10.6-2.el7 rhel_dvd
php-mysql.x86_64 5.4.16-36.el7_1 rhel_dvd
qt-mysql.i686 1:4.8.5-11.el7 rhel_dvd
qt-mysql.x86_64 1:4.8.5-11.el7 rhel_dvd
rsyslog-mysql.x86_64 7.4.7-12.el7 rhel_dvd
[root@mastera0 ~]# yum install -y mysql-community-server
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.44-2.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting
--> Finished Dependency Resolution
Error: Package: 2:postfix-2.10.1-6.el7.x86_64 (@anaconda/7.2)
Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
Removing: 1:mariadb-libs-5.5.44-2.el7.x86_64 (@anaconda/7.2)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
Obsoleted By: mysql-community-libs-5.7.10-1.el7.x86_64 (mysql5.7)
Not found
Error: Package: 2:postfix-2.10.1-6.el7.x86_64 (@anaconda/7.2)
Requires: libmysqlclient.so.18()(64bit)
Removing: 1:mariadb-libs-5.5.44-2.el7.x86_64 (@anaconda/7.2)
libmysqlclient.so.18()(64bit)
Obsoleted By: mysql-community-libs-5.7.10-1.el7.x86_64 (mysql5.7)
~libmysqlclient.so.20()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[root@mastera0 ~]#
[root@mastera0 ~]# rpm -e --nodeps mariadb-libs
[root@mastera0 ~]# rpm -qa|grep mariadb
[root@mastera0 ~]# yum install -y mysql-community-server
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================
Package Arch Version Repository Size
====================================================================================================
Installing:
mysql-community-server x86_64 5.7.10-1.el7 mysql5.7 142 M
Installing for dependencies:
mysql-community-client x86_64 5.7.10-1.el7 mysql5.7 24 M
mysql-community-common x86_64 5.7.10-1.el7 mysql5.7 269 k
mysql-community-libs x86_64 5.7.10-1.el7 mysql5.7 2.2 M
Transaction Summary
====================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 169 M
Installed size: 773 M
Downloading packages:
(1/4): mysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:00:00
(2/4): mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:00:00
(3/4): mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 00:00:00
(4/4): mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 00:00:05
----------------------------------------------------------------------------------------------------
Total 30 MB/s | 169 MB 00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libmysqlclient.so.18(libmysqlclient_18)(64bit)
Installing : mysql-community-common-5.7.10-1.el7.x86_64 1/4
Installing : mysql-community-libs-5.7.10-1.el7.x86_64 2/4
Installing : mysql-community-client-5.7.10-1.el7.x86_64 3/4
Installing : mysql-community-server-5.7.10-1.el7.x86_64 4/4
Verifying : mysql-community-server-5.7.10-1.el7.x86_64 1/4
Verifying : mysql-community-common-5.7.10-1.el7.x86_64 2/4
Verifying : mysql-community-libs-5.7.10-1.el7.x86_64 3/4
Verifying : mysql-community-client-5.7.10-1.el7.x86_64 4/4
Installed:
mysql-community-server.x86_64 0:5.7.10-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:5.7.10-1.el7 mysql-community-common.x86_64 0:5.7.10-1.el7
mysql-community-libs.x86_64 0:5.7.10-1.el7
Complete!
[root@mastera0 ~]#
[root@mastera0 ~]# rpm -ql mysql-community-server
/etc/logrotate.d/mysql
/etc/my.cnf
/etc/my.cnf.d
/usr/bin/innochecksum
/usr/bin/lz4_decompress
/usr/bin/my_print_defaults
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql_install_db
/usr/bin/mysql_plugin
/usr/bin/mysql_secure_installation
/usr/bin/mysql_ssl_rsa_setup
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysqld_pre_systemd
/usr/bin/mysqldumpslow
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolve_stack_dump
/usr/bin/resolveip
/usr/bin/zlib_decompress
/usr/lib/systemd/system/mysqld.service
/usr/lib/tmpfiles.d/mysql.conf
/usr/lib64/mysql/mecab
/usr/lib64/mysql/mecab/dic
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/unk.dic
/usr/lib64/mysql/mecab/dic/ipadic_sjis
/usr/lib64/mysql/mecab/dic/ipadic_sjis/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_sjis/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_sjis/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_sjis/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_sjis/unk.dic
/usr/lib64/mysql/mecab/dic/ipadic_utf-8
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/unk.dic
/usr/lib64/mysql/mecab/etc
/usr/lib64/mysql/mecab/etc/mecabrc
/usr/lib64/mysql/plugin
/usr/lib64/mysql/plugin/adt_null.so
/usr/lib64/mysql/plugin/auth_socket.so
/usr/lib64/mysql/plugin/debug
/usr/lib64/mysql/plugin/debug/adt_null.so
/usr/lib64/mysql/plugin/debug/auth_socket.so
/usr/lib64/mysql/plugin/debug/ha_example.so
/usr/lib64/mysql/plugin/debug/innodb_engine.so
/usr/lib64/mysql/plugin/debug/libmemcached.so
/usr/lib64/mysql/plugin/debug/libpluginmecab.so
/usr/lib64/mysql/plugin/debug/locking_service.so
/usr/lib64/mysql/plugin/debug/mypluglib.so
/usr/lib64/mysql/plugin/debug/mysql_no_login.so
/usr/lib64/mysql/plugin/debug/rewrite_example.so
/usr/lib64/mysql/plugin/debug/rewriter.so
/usr/lib64/mysql/plugin/debug/semisync_master.so
/usr/lib64/mysql/plugin/debug/semisync_slave.so
/usr/lib64/mysql/plugin/debug/validate_password.so
/usr/lib64/mysql/plugin/debug/version_token.so
/usr/lib64/mysql/plugin/ha_example.so
/usr/lib64/mysql/plugin/innodb_engine.so
/usr/lib64/mysql/plugin/libmemcached.so
/usr/lib64/mysql/plugin/libpluginmecab.so
/usr/lib64/mysql/plugin/locking_service.so
/usr/lib64/mysql/plugin/mypluglib.so
/usr/lib64/mysql/plugin/mysql_no_login.so
/usr/lib64/mysql/plugin/rewrite_example.so
/usr/lib64/mysql/plugin/rewriter.so
/usr/lib64/mysql/plugin/semisync_master.so
/usr/lib64/mysql/plugin/semisync_slave.so
/usr/lib64/mysql/plugin/validate_password.so
/usr/lib64/mysql/plugin/version_token.so
/usr/sbin/mysqld
/usr/sbin/mysqld-debug
/usr/share/doc/mysql-community-server-5.7.10
/usr/share/doc/mysql-community-server-5.7.10/COPYING
/usr/share/doc/mysql-community-server-5.7.10/ChangeLog
/usr/share/doc/mysql-community-server-5.7.10/INFO_BIN
/usr/share/doc/mysql-community-server-5.7.10/INFO_SRC
/usr/share/doc/mysql-community-server-5.7.10/README
/usr/share/doc/mysql-community-server-5.7.10/my-default.cnf
/usr/share/man/man1/innochecksum.1.gz
/usr/share/man/man1/lz4_decompress.1.gz
/usr/share/man/man1/my_print_defaults.1.gz
/usr/share/man/man1/myisam_ftdump.1.gz
/usr/share/man/man1/myisamchk.1.gz
/usr/share/man/man1/myisamlog.1.gz
/usr/share/man/man1/myisampack.1.gz
/usr/share/man/man1/mysql.server.1.gz
/usr/share/man/man1/mysql_install_db.1.gz
/usr/share/man/man1/mysql_plugin.1.gz
/usr/share/man/man1/mysql_secure_installation.1.gz
/usr/share/man/man1/mysql_ssl_rsa_setup.1.gz
/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
/usr/share/man/man1/mysql_upgrade.1.gz
/usr/share/man/man1/mysqld_multi.1.gz
/usr/share/man/man1/mysqld_safe.1.gz
/usr/share/man/man1/mysqldumpslow.1.gz
/usr/share/man/man1/mysqlman.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man1/zlib_decompress.1.gz
/usr/share/man/man8/mysqld.8.gz
/usr/share/mysql/dictionary.txt
/usr/share/mysql/fill_help_tables.sql
/usr/share/mysql/innodb_memcached_config.sql
/usr/share/mysql/install_rewriter.sql
/usr/share/mysql/magic
/usr/share/mysql/my-default.cnf
/usr/share/mysql/mysql-log-rotate
/usr/share/mysql/mysql_security_commands.sql
/usr/share/mysql/mysql_sys_schema.sql
/usr/share/mysql/mysql_system_tables.sql
/usr/share/mysql/mysql_system_tables_data.sql
/usr/share/mysql/mysql_test_data_timezone.sql
/usr/share/mysql/uninstall_rewriter.sql
/var/lib/mysql
/var/lib/mysql-files
/var/run/mysqld
[root@mastera0 ~]# ll /var/log/mysqld.log
-rw-r--r--. 1 root root 0 Sep 2 11:29 /var/log/mysqld.log
[root@mastera0 ~]#
[root@mastera0 ~]# rpm -ql mysql-community-client
/usr/bin/mysql
/usr/bin/mysql_config
/usr/bin/mysql_config-64
/usr/bin/mysql_config_editor
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlpump
/usr/bin/mysqlshow
/usr/bin/mysqlslap
/usr/share/doc/mysql-community-client-5.7.10
/usr/share/doc/mysql-community-client-5.7.10/COPYING
/usr/share/doc/mysql-community-client-5.7.10/README
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysql_config_editor.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqlbinlog.1.gz
/usr/share/man/man1/mysqlcheck.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlimport.1.gz
/usr/share/man/man1/mysqlpump.1.gz
/usr/share/man/man1/mysqlshow.1.gz
/usr/share/man/man1/mysqlslap.1.gz
[root@mastera0 ~]#
[root@mastera0 ~]# systemctl start mysqld
[root@mastera0 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2016-09-02 11:39:30 CST; 7s ago
Process: 9540 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 9466 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 9543 (mysqld)
CGroup: /system.slice/mysqld.service
└─9543 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.p...
Sep 02 11:38:58 mastera0.example.com systemd[1]: Starting MySQL Server...
Sep 02 11:39:30 mastera0.example.com systemd[1]: Started MySQL Server.
[root@mastera0 ~]# ps -ef|grep mysqld
mysql 9543 1 0 11:39 ? 00:00:00 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root 9573 2368 0 11:40 pts/0 00:00:00 grep --color=auto mysqld
[root@mastera0 ~]# netstat -luntp|grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 9543/mysqld
[root@mastera0 ~]#
[root@mastera0 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@mastera0 ~]# grep password /var/log/mysqld.log
2016-09-02T03:39:01.230715Z 1 [Note] A temporary password is generated for root@localhost: piBUQLFXh7%x
2016-09-02T03:42:27.789548Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
[root@mastera0 ~]# mysql -uroot -p'piBUQLFXh7%x'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.10
Copyright (c) 2000, 2015, 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.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> \q
Bye
[root@mastera0 ~]#
[root@mastera0 ~]# mysqladmin -uroot -p'piBUQLFXh7%x' password '(Uploo00king)'
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@mastera0 ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc .mysql_history
.. .bash_history .bash_profile .cshrc .tcshrc
[root@mastera0 ~]# ls
anaconda-ks.cfg
[root@mastera0 ~]# mysql -uroot -p'(Uploo00king)'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> desc mysql.user;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(32) | NO | PRI | | |
| Select_priv | enum('N','Y') | NO | | N | |
| Insert_priv | enum('N','Y') | NO | | N | |
| Update_priv | enum('N','Y') | NO | | N | |
| Delete_priv | enum('N','Y') | NO | | N | |
| Create_priv | enum('N','Y') | NO | | N | |
| Drop_priv | enum('N','Y') | NO | | N | |
| Reload_priv | enum('N','Y') | NO | | N | |
| Shutdown_priv | enum('N','Y') | NO | | N | |
| Process_priv | enum('N','Y') | NO | | N | |
| File_priv | enum('N','Y') | NO | | N | |
| Grant_priv | enum('N','Y') | NO | | N | |
| References_priv | enum('N','Y') | NO | | N | |
| Index_priv | enum('N','Y') | NO | | N | |
| Alter_priv | enum('N','Y') | NO | | N | |
| Show_db_priv | enum('N','Y') | NO | | N | |
| Super_priv | enum('N','Y') | NO | | N | |
| Create_tmp_table_priv | enum('N','Y') | NO | | N | |
| Lock_tables_priv | enum('N','Y') | NO | | N | |
| Execute_priv | enum('N','Y') | NO | | N | |
| Repl_slave_priv | enum('N','Y') | NO | | N | |
| Repl_client_priv | enum('N','Y') | NO | | N | |
| Create_view_priv | enum('N','Y') | NO | | N | |
| Show_view_priv | enum('N','Y') | NO | | N | |
| Create_routine_priv | enum('N','Y') | NO | | N | |
| Alter_routine_priv | enum('N','Y') | NO | | N | |
| Create_user_priv | enum('N','Y') | NO | | N | |
| Event_priv | enum('N','Y') | NO | | N | |
| Trigger_priv | enum('N','Y') | NO | | N | |
| Create_tablespace_priv | enum('N','Y') | NO | | N | |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | |
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
| max_questions | int(11) unsigned | NO | | 0 | |
| max_updates | int(11) unsigned | NO | | 0 | |
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) unsigned | NO | | 0 | |
| plugin | char(64) | NO | | mysql_native_password | |
| authentication_string | text | YES | | NULL | |
| password_expired | enum('N','Y') | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum('N','Y') | NO | | N | |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
45 rows in set (0.00 sec)
mysql>
本文来自希曼博客-www.ximan.tech,作者:希曼博客,转载请注明原文链接:https://www.cnblogs.com/lihuaichen/p/8270196.html