Skip to main content

Help with optimization of my.cnf based on mysqltuner

Comments

13 comments

  • cPRex Jurassic Moderator
    Hey there! Honestly, that all looks good to me. For a 10-core CPU those numbers seem normal and realistic.
    0
  • Nermin
    Can somebody help me try to solve this issue in phpMyAdmin with table open cache and open files limit. Issue: The rate of opening tables is high. Recommendation: Opening tables requires disk I/O which is costly. Increasing table_open_cache might avoid this. Justification: Opened table rate: 15.18 per minute, this value should be less than 10 per hour Used variable / formula: Opened_tables / Uptime Test: value*60*60 > 10 Also this: Issue: The rate of opening files is high. Recommendation: Consider increasing open_files_limit, and check the error log when restarting after changing open_files_limit. Justification: Opened files rate: 6.58 per hour, this value should be less than 5 per hour Used variable / formula: Open_files / Uptime Test: value * 60 * 60 > 5 How can I increase table_open_cache more than value 524123 and open_files_limit more than value: 1048576. I cant go any higher for some reason. I've searched forums but for some reason it will not allow me higher values than these. Thank you! Nermin
    0
  • cPRex Jurassic Moderator
    Where are you trying to edit those values? If you adjust that in the /etc/my.cnf file, there is no reason you wouldn't be able to enter higher values than those.
    0
  • Nermin
    Hello, I have entered these values in my.cnf table_definition_cache = 40000 # UPD table_open_cache = 1024123 # UPD open_files_limit = 3048576 # UPD Old values were: table_definition_cache = 40000 # UPD table_open_cache = 524123 # UPD open_files_limit = 1048576 # UPD and restarted mysql. This is the output: [root@server1 ~]# /scripts/restartsrv_mysql Waiting for "mysql" to restart ""waiting for "mysql" to initialize "finished. Service Status mariadb (/usr/sbin/mariadbd) is running as mysql with PID 6644 (systemd+/proc check method). Startup Log Mar 15 17:05:15 server1.xxx.xx systemd[1]: Starting MariaDB 10.6.12 database server... Mar 15 17:05:15 server1.xxx.xx mariadbd[6644]: 2023-03-15 17:05:15 0 [Warning] Could not increase number of max_open_files to more than 1048576 (request: 4096843) Mar 15 17:05:15 server1.xxx.xx mariadbd[6644]: 2023-03-15 17:05:15 0 [Warning] Changed limits: max_open_files: 1048576 max_connections: 300 (was 300) table_cache: 524123 (was 1024123) Is there some hard limit in CentOS7 that I am unaware of?
    0
  • cPRex Jurassic Moderator
    Can you run this command on the server and see if that is where the limit is being set? grep -i LimitNOFILE /etc/systemd/system/mysqld.service
    0
  • Nermin
    Here it is: [root@server1 ~]# grep -i LimitNOFILE /etc/systemd/system/mysqld.service grep: /etc/systemd/system/mysqld.service: No such file or directory [root@server1 ~]#
    0
  • cPRex Jurassic Moderator
    It's possible there are other MySQL configuration files on the system, such as in /root/my.cnf, or elsewhere on the system. Running this command on the server will show you what configuration files are currently loaded: /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
    0
  • Nermin
    [root@server1 ~]# /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options" 2023-03-15 17:43:56 0 [Warning] Could not increase number of max_open_files to more than 4096 (request: 4096843) 2023-03-15 17:43:56 0 [Warning] Changed limits: max_open_files: 4096 max_connections: 300 (was 300) table_cache: 1883 (was 1024123) 2023-03-15 17:43:56 0 [Warning] 'innodb-buffer-pool-instances' was removed. It does nothing now and exists only for compatibility with old my.cnf files. Default options are read from the following files in the given order: /etc/my.cnf ~/.my.cnf [root@server1 ~]#
    0
  • cPRex Jurassic Moderator
    Thanks for that. The limit is likely controlled by the service file for MySQL, which would be located at this file: /usr/lib/systemd/system/mariadb.service or the mysqld.service file in the same directory if you are using a MySQL version. Edit that file, restart the service, and I would expect things to work well.
    0
  • Nermin
    I've edited that file. No mather what I put in: # Number of files limit. previously [mysqld_safe] open-files-limit LimitNOFILE=infinity LimitMEMLOCK=infinity it will not change the value more than table open cache: 524,123 or open files limit: 1,048,576 I've also made "/etc/systemd/system/mariadb.service.d/override.conf" file and put inside LimitNOFILE=infinity LimitMEMLOCK=infinity LimitNPROC=infinity but nothing happens. Here is mariadb.service: # It's not recommended to modify this file in-place, because it will be # overwritten during package upgrades. If you want to customize, the # best way is to create a file "/etc/systemd/system/mariadb.service", # containing # .include /usr/lib/systemd/system/mariadb.service # ...make your changes here... # or create a file "/etc/systemd/system/mariadb.service.d/foo.conf", # which doesn't need to include ".include" call and which will be parsed # after the file mariadb.service itself is parsed. # # For more info about custom unit files, see systemd.unit(5) or # systemd # # Copyright notice: # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=MariaDB 10.6.12 database server Documentation=man:mariadbd(8) Documentation=systemd After=network.target [Install] WantedBy=multi-user.target [Service] ############################################################################## ## Core requirements ## Type=notify # Setting this to true can break replication and the Type=notify settings # See also bind-address mariadbd option. PrivateNetwork=false ############################################################################## ## Package maintainers ## User=mysql Group=mysql # CAP_IPC_LOCK To allow memlock to be used as non-root user # CAP_DAC_OVERRIDE To allow auth_pam_tool (which is SUID root) to read /etc/shadow when it's chmod 0 # does nothing for non-root, not needed if /etc/shadow is u+r # CAP_AUDIT_WRITE auth_pam_tool needs it on Debian for whatever reason CapabilityBoundingSet=CAP_IPC_LOCK CAP_DAC_OVERRIDE CAP_AUDIT_WRITE # PrivateDevices=true implies NoNewPrivileges=true and # SUID auth_pam_tool suddenly doesn't do setuid anymore PrivateDevices=false # Prevent writes to /usr, /boot, and /etc ProtectSystem=full # Doesn't yet work properly with SELinux enabled # NoNewPrivileges=true # Prevent accessing /home, /root and /run/user ProtectHome=true # Execute pre and post scripts as root, otherwise it does it as User= PermissionsStartOnly=true # Perform automatic wsrep recovery. When server is started without wsrep, # galera_recovery simply returns an empty string. In any case, however, # the script is not expected to return with a non-zero status. # It is always safe to unset _WSREP_START_POSITION environment variable. # Do not panic if galera_recovery script is not available. (MDEV-10538) ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \ VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] \ && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1" # Needed to create system tables etc. # ExecStartPre=/usr/bin/mysql_install_db -u mysql # Start main service # MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf # Use the [Service] section and Environment="MYSQLD_OPTS=...". # This isn't a replacement for my.cnf. # _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION # Unset _WSREP_START_POSITION environment variable. ExecStartPost=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION" KillSignal=SIGTERM # Don't want to see an automated SIGKILL ever SendSIGKILL=no # Restart crashed server only, on-failure would also restart, for example, when # my.cnf contains unknown option Restart=on-abort RestartSec=5s UMask=007 ############################################################################## ## USERs can override ## ## ## by creating a file in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf ## and adding/setting the following under [Service] will override this file's ## settings. # Useful options not previously available in [mysqld_safe] # Kernels like killing mariadbd when out of memory because its big. # Lets temper that preference a little. # OOMScoreAdjust=-600 # Explicitly start with high IO priority # BlockIOWeight=1000 # If you don't use the /tmp directory for SELECT ... OUTFILE and # LOAD DATA INFILE you can enable PrivateTmp=true for a little more security. PrivateTmp=false # Set an explicit Start and Stop timeout of 900 seconds (15 minutes!) # this is the same value as used in SysV init scripts in the past # Galera might need a longer timeout, check the KB if you want to change this: # systemd TimeoutStartSec=900 TimeoutStopSec=900 ## ## Options previously available to be set via [mysqld_safe] ## that now needs to be set by systemd config files as mysqld_safe ## isn't executed. ## # Number of files limit. previously [mysqld_safe] open-files-limit #LimitNOFILE=infinity #LimitMEMLOCK=infinity #LimitNPROC=infinity # Maximium core size. previously [mysqld_safe] core-file-size # LimitCore= # Nice priority. previously [mysqld_safe] nice # Nice=-5 # Timezone. previously [mysqld_safe] timezone # Environment="TZ=UTC" # Library substitutions. previously [mysqld_safe] malloc-lib with explicit paths # (in LD_LIBRARY_PATH) and library name (in LD_PRELOAD). # Environment="LD_LIBRARY_PATH=/path1 /path2" "LD_PRELOAD= # Flush caches. previously [mysqld_safe] flush-caches=1 # ExecStartPre=sync # ExecStartPre=sysctl -q -w vm.drop_caches=3 # numa-interleave=1 equalivant # Change ExecStart=numactl --interleave=all /usr/sbin/mariadbd...... # crash-script equalivent # FailureAction=
    0
  • cPRex Jurassic Moderator
    Can you open a ticket with our team so we can take a look?
    0
  • Nermin
    I've opened a ticket. Id #94767413 Thank you!
    0
  • cPRex Jurassic Moderator
    Thanks for that - I'm following along with that on my end now.
    0

Please sign in to leave a comment.