jumpserver集群部署(三)---之MySQL部署

2024-05-22 08:11:31 浏览数 (1)

说明

mysql集群是指两台或多台机器运行、任意时刻只有过一个机器对外提供服务。当提供服务的一台出现故障、就会从剩下的机器选一个提供服务。

MariaDB部署

安装MariaDB

所有MariaDB节点服务器操作 *

代码语言:javascript复制
[root@sz19f-mysql-redis-nfs-10-0-80-31-vm.belle.lan:/root]
# yum install mysql-server mysql -y
# systemctl start mariadb
# systemctl enable mariadb
# mysqladmin -u root password 123.com      #<====设置mysql密码
# vim /etc/my.cnf    #<=====开启二进制日志,设置id
[mysqld]
server-id = 1                    #backup这台设置2
log-bin = mysql-bin
binlog-ignore-db = mysql,information_schema       #忽略写入binlog日志的库
auto-increment-increment = 2             #字段变化增量值
auto-increment-offset = 1              #初始字段ID为1
slave-skip-errors = all

# systemctl restart mariadb     #<======重启

master配置

代码语言:javascript复制
[root@sz19f-mysql-redis-nfs-10-0-80-31-vm.belle.lan:/root]
# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 9
Server version: 10.2.43-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> show master status;     # 查看下log bin日志和pos值位置
 ------------------ ---------- -------------- -------------------------- 
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB         |
 ------------------ ---------- -------------- -------------------------- 
| mysql-bin.000001 |      328 |              | mysql,information_schema |
 ------------------ ---------- -------------- -------------------------- 
1 row in set (0.00 sec)

MariaDB [(none)]> GRANT  REPLICATION SLAVE ON *.* TO 'replication'@'10.0.80.%' IDENTIFIED  BY 'replication';       # 设置权限
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

配置master

0 人点赞