01 mariadb日志文件


CentOS 7编译安装Mariadb

[root@centos7 ~]# yum -y groupinstall "Development Tools"

[root@centos7 ~]# yum install ncurses-devel openssl-devel libevent-devel jemalloc-devel cmake -y

[root@centos7 ~]# tar xf mariadb-5.5.53.tar.gz 

[root@centos7 ~]# cd mariadb-5.5.53/

[root@centos7 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

[root@centos7 mariadb-5.5.53]# make && make install


[root@centos7 ~]# 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

[root@centos7 mysql]# groupadd -r -g 316 mysql

[root@centos7 mysql]# useradd -r -g mysql -u 316 mysql

[root@centos7 ~]# systemctl daemon-reload

[root@centos7 mariadb-5.5.53]# cp support-files/my-large.cnf /etc/my.cnf

[root@centos7 mariadb-5.5.53]# vim /etc/my.cnf

添加

datadir = /data/mysql

[root@centos7 mariadb-5.5.53]# cd /usr/local/

[root@centos7 local]# ln -s mariadb-5.5.53/ mysql

[root@centos7 local]# cd mysql/

[root@centos7 mysql]# mkdir /data/mysql -p

[root@centos7 mysql]# chown mysql.mysql /data/mysql/

[root@centos7 mysql]# chown -R mysql.mysql ./*

[root@centos7 mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysql

[root@centos7 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)


#日志查询

[root@centos7 bin]# ./mysqlbinlog --start-position=328 /data/mysql/mysql-bin.000004