41 mariadb日志文件备份和恢复基础

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了41 mariadb日志文件备份和恢复基础相关的知识,希望对你有一定的参考价值。

01 mariadb日志文件


CentOS 7编译安装Mariadb

[[email protected] ~]# yum -y groupinstall "Development Tools"

[[email protected] ~]# yum install ncurses-devel openssl-devel libevent-devel jemalloc-devel cmake -y

[[email protected] ~]# tar xf mariadb-5.5.53.tar.gz 

[[email protected] ~]# cd mariadb-5.5.53/

[[email protected] mariadb-5.5.53]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-5.5.53 \

 -Dmysql_DATADIR=/mydata/data \

 -DSYSCONFDIR=/etc \

 -DWITH_INNOBASE_STORAGE_ENGINE=1 \

 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \

 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

 -DWITH_READLINE=1 \

 -DWITH_SSL=system \

 -DWITH_ZLIB=system \

 -DWITH_LIBWRAP=0 \

 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

 -DDEFAULT_CHARSET=utf8 \

 -DDEFAULT_COLLATION=utf8_general_ci

[[email protected] mariadb-5.5.53]# make && make install


[[email protected] ~]# vim /usr/lib/systemd/system/mariadb.service

# Don‘t forget to reload systemd daemon after you change unit configuration:

# # root> systemctl --system daemon-reload

#

[Unit]

Description=MariaDB database server

After=syslog.target

After=network.target

#

[Service]

Type=simple

User=mysql

Group=mysql

#

# Note: we set --basedir to prevent probes that might trigger SELinux alarms,

ExecStart=/usr/local/mysql/bin/mysqld_safe --basedir=/usr/local/mysql

#

# Give a reasonable amount of time for the server to start up /shut down

TimeoutSec=300

#

# Place temp files in a secure directory, not /tmp

PrivateTmp=false

#

[Install]

VantedBy=multi-user.target

[[email protected] mysql]# groupadd -r -g 316 mysql

[[email protected] mysql]# useradd -r -g mysql -u 316 mysql

[[email protected] ~]# systemctl daemon-reload

[[email protected] mariadb-5.5.53]# cp support-files/my-large.cnf /etc/my.cnf

[[email protected] mariadb-5.5.53]# vim /etc/my.cnf

添加

datadir = /data/mysql

[[email protected] mariadb-5.5.53]# cd /usr/local/

[[email protected] local]# ln -s mariadb-5.5.53/ mysql

[[email protected] local]# cd mysql/

[[email protected] mysql]# mkdir /data/mysql -p

[[email protected] mysql]# chown mysql.mysql /data/mysql/

[[email protected] mysql]# chown -R mysql.mysql ./*

[[email protected] mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql

[[email protected] mysql]# systemctl start mariadb.service



#慢查询

MariaDB [(none)]> SHOW GLOBAL VARIABLES LIKE ‘long_query_time‘;  

+-----------------+-----------+

| Variable_name   | Value     |

+-----------------+-----------+

| long_query_time | 10.000000 |

+-----------------+-----------+

1 row in set (0.00 sec)


#日志查询

[[email protected] bin]# ./mysqlbinlog --start-position=328 /data/mysql/mysql-bin.000004


本文出自 “追梦” 博客,请务必保留此出处http://sihua.blog.51cto.com/377227/1867336

以上是关于41 mariadb日志文件备份和恢复基础的主要内容,如果未能解决你的问题,请参考以下文章

mariadb二进制日志和备份恢复

10.19-10.22 iptables规则备份和恢10.20 firewalld的9个zone

数据库备份和恢复---MariaDB

MySQL数据库备份与恢复

数据库基础知识--------MySQL 日志管理备份与恢复

数据库的备份与恢复