How to configure log_bin and log_bin_index in my.cnf in mysql 8.0.24 community server?

1.3k views Asked by At

The OS is Ubuntu 18.04. The Mysql is 8.0.24 community server.

My data directory is shown below:

mysql> show variables like '%datadir%';
+---------------+--------------+
| Variable_name | Value        |
+---------------+--------------+
| datadir       | /data/mysql/ |
+---------------+--------------+
1 row in set (0.01 sec)

The basename and index of my binlog:

mysql> show variables like 'log_bin%';
+---------------------------------+-------------------------------+
| Variable_name                   | Value                         |
+---------------------------------+-------------------------------+
| log_bin                         | ON                            |
| log_bin_basename                | /data/mysql/binlogs           |
| log_bin_index                   | /data/mysql/mysqlmaster.index |
| log_bin_trust_function_creators | OFF                           |
| log_bin_use_v1_row_events       | OFF                           |
+---------------------------------+-------------------------------+
5 rows in set (0.01 sec)

The content of my.cnf:

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
#validate_password
validate_password.policy=1
validate_password.length=8
validate_password.number_count=1
validate_password.mixed_case_count=1
validate_password.special_char_count=1
validate_password.check_user_name=1

#datadir
datadir = /data/mysql

#binlog
log_bin = binlogs
log_bin_index = mysqlmaster.index
server_id = 100

Now I want to set

log_bin = /data/mysql/binlogs/mysqlmaster
log_bin_index = /data/mysql/binlogs/mysqlmaster.index

But When I configure this content in my.cnf:

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
#validate_password
validate_password.policy=1
validate_password.length=8
validate_password.number_count=1
validate_password.mixed_case_count=1
validate_password.special_char_count=1
validate_password.check_user_name=1

#datadir
datadir = /data/mysql

#binlog
log_bin = /data/mysql/binlogs/mysqlmaster
log_bin_index = /data/mysql/binlogs/mysqlmaster.index
server_id = 100

Then I start mysql server :

it@mysqlmaster:~$ sudo service mysql start

Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

The command "journalctl -xe" show:

it@mysqlmaster:~$ journalctl -xe
-- Unit mysql.service has failed.
--
-- The result is RESULT.
May 01 00:32:24 mysqlmaster systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has begun starting up.
May 01 00:32:24 mysqlmaster audit[11816]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" nam
May 01 00:32:24 mysqlmaster kernel: audit: type=1400 audit(1619829144.154:234): apparmor="STATUS" operation="profile_replace" info="same as current profile,
May 01 00:32:24 mysqlmaster systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
May 01 00:32:24 mysqlmaster systemd[1]: mysql.service: Failed with result 'exit-code'.
May 01 00:32:24 mysqlmaster systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.
May 01 00:32:32 mysqlmaster sudo[11467]: pam_unix(sudo:session): session closed for user root
May 01 00:32:34 mysqlmaster sudo[11829]:    it : TTY=pts/0 ; PWD=/home/it ; USER=root ; COMMAND=/usr/sbin/service mysql start
May 01 00:32:34 mysqlmaster sudo[11829]: pam_unix(sudo:session): session opened for user root by it(uid=0)
May 01 00:32:35 mysqlmaster systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has begun starting up.
May 01 00:32:35 mysqlmaster audit[11909]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" nam
May 01 00:32:35 mysqlmaster kernel: audit: type=1400 audit(1619829155.626:235): apparmor="STATUS" operation="profile_replace" info="same as current profile,
May 01 00:32:36 mysqlmaster systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
May 01 00:32:36 mysqlmaster systemd[1]: mysql.service: Failed with result 'exit-code'.
May 01 00:32:36 mysqlmaster systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.
May 01 00:32:36 mysqlmaster sudo[11829]: pam_unix(sudo:session): session closed for user root

So my question is if i want to set:

log_bin = /data/mysql/binlogs/mysqlmaster

log_bin_index = /data/mysql/binlogs/mysqlmaster.index

What should I add to my.cnf to achieve my goal?

1

There are 1 answers

0
Andrew On

Now I slove my question:

root@mysqlmaster:/data/mysql# ls -l
total 176648
-rw-r----- 1 mysql mysql       56 Apr 28 03:24  auto.cnf
-rw-r----- 1 mysql mysql      474 Apr 28 03:24  binlog.000001
-rw-r----- 1 mysql mysql      156 Apr 30 00:45  binlog.000002
-rw-r----- 1 mysql mysql      469 Apr 30 02:52  binlog.000003
-rw-r----- 1 mysql mysql      179 Apr 30 03:09  binlog.000004
-rw-r----- 1 mysql mysql      179 Apr 30 03:16  binlog.000005
-rw-r----- 1 mysql mysql      179 Apr 30 14:49  binlog.000006
-rw-r----- 1 mysql mysql      179 Apr 30 14:59  binlog.000007
-rw-r----- 1 mysql mysql      112 Apr 30 14:59  binlog.index
drwxr-xr-x 2 root  root      4096 Apr 30 07:33  binlogs

Then I do this:

root@mysqlmaster:/data/mysql# chown -R mysql:mysql binlogs

Now it's OK :

ankon@mysqlmaster:~$ sudo service mysql start