Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configure multiple MySQL 8.0 instances using systemd

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Note: because systemd can manage multiple MySQL instances on platforms with systemd support, mysqld_multi and mysqld_multi.server are unnecessary and not installed.

To use the multi-instance feature, modify the my.cnf options file to include the key option configuration for each instance. These file locations are typical:

Add the content / etc/my.cnf to the configuration file

[mysqld@01] datadir=/var/lib/mysql01socket=/var/lib/mysql01/mysql.sockport=3307mysqlx_port=33070log-error=/var/log/ mysqld01.log [mysqld @ 02] datadir=/var/lib/mysql02socket=/var/lib/mysql02/mysql.sockport=3308mysqlx_port=33080log-error=/var/log/mysqld02.log

The copy name shown here @ is used as a delimiter because it is the only delimiter supported by systemd.

Create a data directory

Mkdir / var/lib/mysql01mkdir / var/lib/mysql02chown mysql.mysql / var/lib/mysql01chown mysql.mysql / var/lib/mysql02

The instance is then managed by regular systemd commands, such as:

Systemctl start mysqld@01systemctl start mysqld@02

To enable the instance to run at boot time:

Systemctl enable mysqld@01systemctl enable mysqld@02

The use of wildcards is also supported. For example, this command displays the status of all replica instances:

Systemctl status' mysqld@replica*'

To manage multiple MySQL instances on the same machine, systemd automatically uses different unit files:

Mysqld@.service instead of mysqld.service (RPM platform)

In the unit file, the% I and% I references are followed by the parameter @ tag and are used to manage that particular instance. For commands like this:

Systemctl start mysqld@01

Systemd uses the following command to start the server:

Mysqld-- defaults-group-suffix=@%I...

As a result, the [server], [mysqld], and [mysqld@01] option groups are read and used for the instance of the service.

Reference documentation: using systemd to manage MySQL servers

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report