Mysql卸载从下往上顺序
[root@localhost /]# rpm -e --nodeps qt-mysql-4.6.2-26.el6_4.x86_64
[root@localhost /]# rpm -e --nodeps mysql-server-5.1.71-1.el6.x86_64
[root@localhost /]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
[root@localhost /]# rpm -e --nodeps mysql-devel-5.1.71-1.el6.x86_64
[root@localhost /]# rpm -e --nodeps mysql-5.1.71-1.el6.x86_64
[root@localhost /]# rpm -qa | grep mysql
添加在线Mysql源
cd /etc/yum.repos.d/
vi mysql.repo
# Enable to use MySQL 8.0
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
验证正确的subrepositories已启用和禁用通过运行以下命令来检查它的输出(DNF启用系统,取代百胜在DNF的命令)
yum repolist enabled | grep mysql
YUM安装mysql
yum install -y mysql-community-common mysql-community-libs mysql-community-client mysql-community-server mysql-community-devel
启动Mysql服务
service mysqld start
查看MySQL服务器的状态
service mysqld status
设置开机启动
chkconfig mysqld on
生成随机密码
grep 'temporary password' /var/log/mysqld.log
重新登陆
mysql -uroot -p
b/xE8hdZoEwJ
配置Mysql 密码以及权限
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Report@123';
允许root用户在任何地方进行远程登录,并具有所有库任何操作权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Report@123' WITH GRANT OPTION;
FLUSH PRIVILEGES;
mysql: mariadb 5.5.47
通过yum安装的mariadb(yum -y install mariadb mariadb-serverphp php-mysql httpd)
具体的过程参考:Zabbix系列教程:CentOS 7搭建Zabbix3.0.4服务端及配置详解 http://www.linuxidc.com/Linux/2016-11/137638.htm
slave db:
操作系统:centos6.5
1.在slave中安装mariadb
因之前安装过mysql5.7需要卸载
rpm -e --nodeps mysql*
删除残留文件,否则会无法启动mariadb
rm -rf /var/lib/mysql
rm -f /etc/my.cnf
rm -rf /etc/my.cnf.d
先创建关于mariadb的yum源
vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5.47/centos6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum安装
yum install MariaDB-server MariaDB-client
编辑my.cnf文件
vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
!includedir /etc/my.cnf.d
2.主从服务器均开启binlog日志,从服务器开启relay-log:
log-bin=/data/binlog/mysql-bin
binlog-do-db=zabbix
binlog-ignore-db = mysql
expire_logs_day=15
max_binlog_size = 200M
binlog_format=mixed
server-id = 1
验证:
MariaDB [(none)]> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 396365 |
+------------------+-----------+
1 row in set (0.00 sec)
从服务器配置,开启中继日志:
vim /etc/my.cnf.d/server.cnf
[mariadb]
log-bin=/data/binlog/mysql-bin
relay-log = /data/relaylog/relay-bin
binlog_format=mixed
server-id=10
replicate_wild_do_table=zabbix.%
replicate_wild_ignore_table=mysql.%
改变权限
chown -R mysql.mysql /data/
3.备份主服务器的数据库zabbix
在master和slave两台服务器中都安装percona-xtrabackup