Skip to content

Lỗi max_connection trong MySQL Centos 7 và RHEL 7 #28

@manhdinh

Description

@manhdinh
  1. Miêu tả bug :
  1. Nguyên nhân bug
    Khi cấu hình MySQL trong OpenStack, trong file /etc/my.cnf.d/openstack.cnf , cấu hình gợi ý là max_connections = 4096. Tuy nhiên, trong Centos 7 sẽ sử dụng cấu hình max_connections = 214 do systemd quy định. Vì vậy khi số kết nối của OpenStack > 214, database MySQL sẽ reject các connection.

Kiểm tra max_connections trong mysql bằng câu lệnh :

mysql -u root -p
MariaDB [(none)]> select @@max_connections;
  1. Fix bug
  • Thêm cấu hình vào file limits.conf
echo "mysql soft nofile 4096" >> /etc/security/limits.conf
echo "mysql hard nofile 10240" >> /etc/security/limits.conf
  • Tạo cấu hình trong systemd cho mariadb
mkdir -p /etc/systemd/system/mariadb.service.d

cat << EOF> /etc/systemd/system/mariadb.service.d/limits.conf
[Service]
LimitNOFILE=infinity
EOF
  • Restart dịch vụ
systemctl daemon-reload
systemctl restart mariadb
  • Kiểm tra lại max_connection.

Link fix bug tham khảo : https://pjstrnad.com/mariadb-raise-number-of-connections/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions