分类 Databases 下的文章

sudo ln -s /usr/bin/basename /bin/basename
sudo ln -s bin/bash /usr/bin/bash
sudo ln -s /usr/bin/rpm /bin/rpm
sudo ln -s /usr/bin/awk /bin/awk
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /lib64/libstdc++.so.6
sudo ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib64/libgcc_s.so.1
sudo ln -s /usr/lib/i386-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
sudo ln -s /lib/lsb/init-functions /etc/init.d/functions
sudo ln -sf /bin/bash /bin/sh

https://stackoverflow.com/questions/51060012/installing-oracle-12c-r2-on-ubuntu-18-04

版本 mysql Ver 15.1 Distrib 10.1.29-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Debian buster

Master:

修改Mariadb的配置文件 /etc/mysql/mariadb.conf.d/50-server.cnf

...
bind-address = 0.0.0.0
...
server-id = 1
log_bin = /web/data/mariadb/mysql-bin.log
...

更改文件夹拥有者 chown mysql.mysql /web/data/mariadb/
重启Mariadb systemctl restart mariadb

进入mysql命令行,增加复制数据库权限的用户

# mysql

MariaDB [(none)]> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'sync'@'10.10.10.11' IDENTIFIED BY 'sync';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT

如果主服务器部署在互联网,应设置防火墙(如iptables)禁止非法扫描。

iptables -A INPUT -p tcp --dport 3306 -s 1.1.1.1 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j DROP

Slave:

修改Mariadb的配置文件 /etc/mysql/mariadb.conf.d/50-server.cnf

...
server-id = 2
relay-log = /data/mariadb/relay.log
#log_bin = /var/log/mysql/mysql-bin.log
...

更改文件夹拥有者 chown mysql.mysql /data/mariadb/
重启Mariadb systemctl restart mariadb

进入mysql命令行,设置主服务器的IP地址、用户名、密码。

mysql

MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST='10.10.10.10', MASTER_USER='sync', MASTER_PASSWORD='sync';
MariaDB [(none)]> START SLAVE;
MariaDB [(none)]> SHOW SLAVE STATUS\G
MariaDB [(none)]> EXIT

注意mysql数据库文件目录的拥有者。
chown mysql.mysql -R /var/lib/mysql

update user set plugin="mysql_native_password";