mysql双主安装
Posted connected
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql双主安装相关的知识,希望对你有一定的参考价值。
mysql双主安装(一)
mysql双主安装之mysql软件安装
(两个节点都执行)
一、环境介绍
CentOS7.6+Mysql 8.0.18
二、安装步骤
2.1、环境检查
由于CentOS自带mariadb,在安装mysql时会出现冲突
因而在安装mysql前先卸载mariadb
卸载系统自带mariadb-libs,否则会导致无法安装mysql-community-libs。
# rpm -qa|grep mariadb mariadb-libs-5.5.64-1.el7.aarch64
2.2、下载安装包
https://downloads.mysql.com/archives/community/
2.3、 上传安装包到服务器并解压
(上传可以用WinSCP工具)
[root@mysqldb3 mysql-rpm]# tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar mysql-community-libs-8.0.18-1.el7.x86_64.rpm mysql-community-devel-8.0.18-1.el7.x86_64.rpm mysql-community-embedded-compat-8.0.18-1.el7.x86_64.rpm mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm mysql-community-common-8.0.18-1.el7.x86_64.rpm mysql-community-test-8.0.18-1.el7.x86_64.rpm mysql-community-server-8.0.18-1.el7.x86_64.rpm mysql-community-client-8.0.18-1.el7.x86_64.rpm
2.4、安装
[root@mysqldb2 mysql-rpm]# rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm warning: mysql-community-common-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-common-8.0.18-1.e################################# [100%] [root@mysqldb2 mysql-rpm]# rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm warning: mysql-community-libs-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-libs-8.0.18-1.el7################################# [100%] [root@mysqldb2 mysql-rpm]# rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm warning: mysql-community-client-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-client-8.0.18-1.e################################# [100%] [root@mysqldb2 mysql-rpm]# rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm warning: mysql-community-server-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:mysql-community-server-8.0.18-1.e################################# [100%]
2.5、修改配置文件
[root@mysqldb1 soft]# vi /etc/my.cnf 先把/etc/my.cnf配置文件中的"default-authentication-plugin=mysql_native_password"的注释去掉 port=6612 lower_case_table_names=1 max_connections=2000 log_bin_trust_function_creators=1
2.6、启动mysql服务
systemctl start mysqld
2.7、查看密码文件
MySQL会给我们在/var/log/mysqld.log下,为root用户生成了一个新的密码 查看初始化密码: grep \'temporary password\' /var/log/mysqld.log [root@mysqldb3 mysql-rpm]# grep \'temporary password\' /var/log/mysqld.log 2019-03-08T08:56:56.984943Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: efkAnA)S1py,
2.8、登录并修改密码
mysql -uroot -p
mysql> alter user \'root\'@\'localhost\' identified with mysql_native_password by \'Hankey12#$\'; Query OK, 0 rows affected (0.03 sec) mysql> select host,user,plugin from mysql.user; +-----------+------------------+-----------------------+ | host | user | plugin | +-----------+------------------+-----------------------+ | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session | caching_sha2_password | | localhost | mysql.sys | caching_sha2_password | | localhost | root | mysql_native_password | +-----------+------------------+-----------------------+ 4 rows in set (0.00 sec) mysql>
2.9、远程客户端登录设置
上图中的这个root用户就铁定不能从远程登录,其实略作修改即可 update mysql.user set plugin=\'mysql_native_password\' where user=\'root\'; #若plugin的值为mysql_native_password正常则不用修改
同时,上图的root用户也不能从远程登录,而root的原因是由于host的类型只允许本机
update mysql.user set host=\'%\' where user=\'root\';
执行完成后,刷新权限
flush privileges;
即可使用root远程登录
以上是关于mysql双主安装的主要内容,如果未能解决你的问题,请参考以下文章