How to Configuring and Turning the Server?

The MySQL Server Daemon

mysqld_safe is called an angel process,because it adds some safety features.(such as restarting the server when an error occurs and logging runtime information to the MySQL error log)

systemd (controlled and configured with the systemctl command)

mysqld is the core process of MySQL Server.It is a single multithereaded program that does most of the work in the server.

A program is code that is designed to accomplish a specific objective. There are many types of programs as below:

A process is what we call a program that has been loaded into memory along with all the resources it needs to operate.

A thread is the unit of execution within a process. A process can have just one thread or many threads.

MySQL Server Variables

MySQL Server has many variables that allow tuning its operation. each system variable has a default value,we can adjust most system variables dynamically. The system variables can have two different scopes: SESSION and GLOBAL.

Checking Server Settings

Database workload is dynamic and changes over time,with a tendency and growth.The organic behavior requires constant monitoring ,analysis,and adjustment.The command to show the MySQL settings is :

mysql> show [GLOBAL|SESSION] VARIABLES; 

Jemalloc

MySQL Server uses dynamic memory allocation .It is important for proper CPU and RAM resource utilization.An efficient memory allocator should improve scalability,increase throughput.and keep the memory footprint under control.

jemalloc is a memory allocator that emphasizes fragmentation avoidance and scalable concurrency support.Use jemalloc,you have less memory fragmentation and more efficient resource management of the available server memory..

If you are using Centos/RHEL,you need to execute the following steps:

1.Install the jemalloc package:

[root@DBAMAXWELL ~]# yum install jemalloc
Last metadata expiration check: 1:24:34 ago on Tue 15 Mar 2022 06:58:58 AM CST.
Dependencies resolved.
==================================================================================================================================================
 Package                            Architecture                     Version                                 Repository                      Size
==================================================================================================================================================
Installing:
 jemalloc                           x86_64                           5.2.1-2.el8                             epel                           228 k

Transaction Summary
==================================================================================================================================================
Install  1 Package

Total download size: 228 k
Installed size: 762 k
Is this ok [y/N]: y
Downloading Packages:
jemalloc-5.2.1-2.el8.x86_64.rpm                                                                                   2.7 MB/s | 228 kB     00:00    
--------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                             2.6 MB/s | 228 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                          1/1 
  Installing       : jemalloc-5.2.1-2.el8.x86_64                                                                                              1/1 
  Running scriptlet: jemalloc-5.2.1-2.el8.x86_64                                                                                              1/1 
  Verifying        : jemalloc-5.2.1-2.el8.x86_64                                                                                              1/1 

Installed:
  jemalloc-5.2.1-2.el8.x86_64                                                                                                                     

Complete!

2.The rpm -ql command will show the library location:


[root@DBAMAXWELL ~]# rpm -ql jemalloc
/usr/bin/jemalloc.sh
/usr/lib/.build-id
/usr/lib/.build-id/16
/usr/lib/.build-id/16/0e34e6e44392d63f4532d5c21f3285f4f011d9
/usr/lib64/libjemalloc.so.2
/usr/share/doc/jemalloc
/usr/share/doc/jemalloc/COPYING
/usr/share/doc/jemalloc/README
/usr/share/doc/jemalloc/VERSION
/usr/share/doc/jemalloc/jemalloc.html
[root@DBAMAXWELL ~]# 

3.Override the default configuration of the service with the command :

Buffer pool size

The innodb_buffer_pool_size parameter controls the size in bytes of the InnoDB buffer pool.The memory area where InnoDB caches table and index data.

[root@DBAMAXWELL ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SET global innodb_buffer_pool_size = 1024*1024*1024;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@DBAMAXWELL ~]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
innodb_buffer_pool_size = 1G
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#

[root@DBAMAXWELL ~]# systemctl restart mysqld.service
Job for mysqld.service failed because the control process exited with error code.
See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@DBAMAXWELL ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: activating (start) since Tue 2022-03-15 09:11:47 CST; 54s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 4422 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Cntrl PID: 4444 (mysqld)
    Tasks: 17 (limit: 22680)
   Memory: 255.2M
   CGroup: /system.slice/mysqld.service
           ├─4444 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
           └─4446 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Mar 15 09:11:47 DBAMAXWELL systemd[1]: Starting MySQL Server...
[root@DBAMAXWELL ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

innodb_buffer_pool_instances_parameter

The parameter defines the number of instances that InnoDB will split the buffer pool into.

Redo log size

The redo log is a structure used during crash recovery to correct data written by incomplete transactions.The main goal is guarantee the durability(D) property of ACID transactions by providing redo recovery for committed transactions.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324156899&siteId=291194637