centos7配置mariadb一主多从(yum安装版)

操作系统版本 mysq版本 身份 ip地址
centos7.4-1 mariadb-5.5.56 master 192.168.19.201
centos7.4-2 mariadb-5.5.56 slave1 192.168.19.202
centos7.4-3 mariadb-5.5.56 slave2 192.168.19.203
一、安装ntp服务进行时间同步

master、slave1、slave2

[root@localhost ~]# yum -y install ntpdate
总下载量:87 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm             |  87 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                  1/2 
  清理        : ntpdate-4.2.6p5-25.el7.centos.2.x86_64                  2/2 
  验证中      : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                  1/2 
  验证中      : ntpdate-4.2.6p5-25.el7.centos.2.x86_64                  2/2 

更新完毕:
  ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2                                  

完毕!
[root@localhost ~]# ntpdate time1.aliyun.com
28 Jul 13:09:35 ntpdate[15685]: step time server 203.107.6.88 offset -28507.029087 sec

三台服务器保持时间同步即可

二、安装mariadb(即mysql服务)
master、slave1、slave2
[root@localhost ~]# yum -y install mariadb mariadb-server
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# netstat -anptu | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      2549/mysqld
[root@localhost ~]# mysqladmin -uroot -p password 123123;
Enter password:						回车即可
[root@localhost ~]# mysql -uroot -p123123;
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB 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)]>
MariaDB [(none)]>exit
三、更改主从相关配置文件
master

添加配置文件内容:
server-id=1
log-bin=master-log
skip_name_reslove=ON
innodb_file_per_table=ON

[root@localhost ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server-id=1
log-bin=master-log
skip_name_resolve=ON
innodb_file_per_table=ON
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# systemctl status mariadb
 mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running)<
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值