MYSQL8编译部署_PK平台(国产化)

安装说明

软件介绍

MySQL 是一个关系型数据库管理系统,由瑞典 MySQL AB 公司开发,是业界最流行的 RDBMS(Relational Database Management System,关系数据库管理系统)之一, 尤其在 WEB 应用方面。 关系型数据库是将数据保存在不同的表中,而非将所有数据放在一个大仓库内,这样 就加快了速度并提高了灵活性。由于其体积小、速度快、总体拥有成本低,尤其是开 放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。

MySQL 所使用的 SQL 语言是用于访问数据库的最常用标准化语言。

MySQL 软件采用了双授权模式,分为社区版和商业版。

关于 MySQL 的更多信息请访问 MySQL 官网。

安装MYSQL

官网下载带有boost的版本,本篇用mysql-8.0.25示例。

下载地址:https://downloads.mysql.com/archives/community/

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-IprJk7Nm-1675994405584)(E:\localfiles\typora\pictures\image-20230210095324030.png)]

选择所有操作系统通用版本。

下载cmake工具安装包

官网下载linux版本,本篇用cmake-3.22.5示例,下载地址:https://cmake.org/download/

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xYFw3oso-1675994405585)(E:\localfiles\typora\pictures\image-20230210095339416.png)]

将文件上传到服务器等待安装。

卸载系统自带的mysql数据库

 #rpm -qa\grep mysql                                                  
                                                                       
 #rpm -e mysql mysql-libs                                              
                                                                       
 #yum -y remove mysql-server mysql mysql-libs                          

安装编译源码需要的库

  #yum install -y gcc gcc-c++ ncurses-devel perl openssl-devel 

安装cmake

 #tar zxvf cmake-3.22.5.tar.gz                                         
                                                                       
 #cd cmake-3.22.5                                                      
                                                                       
 #./bootstrap                                                          
                                                                       
 #make -j 120                                                          
                                                                       
 #-j参数是同时执行的编译命令的数量,越大越快,根据CPU核数制定大小      
                                                                       
 #make install                                                         

安装完成后cmake --version 检查是否安装成功

安装rpcsvc

上传rpcsvc-proto-1.4.tar.gz包到服务器


 #tar zxvf rpcsvc-proto-1.4.tar.gz                                     
                                                                       
 #cd rpcsvc-proto-1.4.tar.gz                                           
                                                                       
 #./configure                                                          
                                                                       
 #make && make install                                                 

创建mysql用户及目录

 #mkdir /home/mysql #创建mysql用户的家目录                             
                                                                       
 #groupadd mysql                                                       
                                                                       
 #useradd -m -d /home/mysql mysql -g mysql                             
                                                                       
 #vim /etc/sudoers                                                     
                                                                       
 在## Allow root to run any commands anywhere下面的root ALL=(ALL)      
                                                                       
 ALL后面添加:                                                         
                                                                       
 mysql ALL=(ALL:ALL) NOPASSWD: ALL                                     
                                                                       
 wq! 保存                                                              

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-imnpIqzd-1675994405586)(E:\localfiles\typora\pictures\image-20230210095438587.png)]


 #进入到放置mysql8安装文件的目录下                                     
                                                                       
 #tar zxvf mysql-boost-8.0.25.tar.gz                                   
                                                                       
 #cd mysql-boost-8.0.25                                                
                                                                       
 #创建mysql的安装目录和数据目录                                        
                                                                       
 #mkdir /usr/local/mysql                                               
                                                                       
 #mkdir -p /data/mysql                                                 
                                                                       
 #chown -R mysql:mysql /usr/local/mysql/                               
                                                                       
 #chown -R mysql:mysql /data/mysql/                                    

执行安装(安装路径一定要所有配置文件保持一致!很重要)


 #cmake . \\                                                           
                                                                       
 #-DWITH_BOOST=/opt/mysql-8.0.25/boost/ \\ #这是安装文件解压出来的路径 
                                                                       
 #-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \\ #这是程序安装的路径       
                                                                       
 #-DMYSQL_DATADIR=/data/mysql \\ #这是mysql数据目录                    
                                                                       
 #-DWITHOUT_CSV_STORAGE_ENGINE=1 \\                                    
                                                                       
 #-DWITHOUT_BLACKHOLD_STORAGE_ENGINE=1 \\                              
                                                                       
 #-DWITHOUT_FEDERATED_STORAGE_ENGINE=1 \\                              
                                                                       
 #-DWITHOUT_ARCHIVE_STORAGE_ENGINE=1 \\                                
                                                                       
 #-DWITHOUT_MRG_MYISAM_STORAGE_ENGINE=1 \\                             
                                                                       
 #-DWITHOUT_NDBCLUSTER_STORAGE_ENGINE=1 \\                             
                                                                       
 #-DFORCE_INSOURCE_BUILD=1 \\                                          
                                                                       
 #-DCMAKE_CXX_COMPILER=/usr/bin/g++ \\ #g++的路径                      
                                                                       
 #-DCMAKE_C\_COMPILER=/usr/bin/gcc #gcc的路径                          
                                                                       
 注意:此处经常因为空行导致报错。                                      
                                                                       
 #make -j 120                                                          
                                                                       
 #-j参数是同时执行的编译命令的数量,越大越快,根据CPU核数制定大小      
                                                                       
 #make install                                                         

制作my.cnf文件,前往https://imysql.com/my-cnf-wizard.html(按照注释填写服务器以及安装目录等信息,姓名等信息可忽略,版本选择x86_64也没有关系)

将生成的文件上传至/etc目录下


  #chmod 644 /etc/my.cnf

进行初始化(切换到mysql用户进行初始化)


 #su - mysql                                                                                                                                      
                                                                                                                                                  
 #cd /usr/local/mysql #进入程序安装目录                                                                                                           
                                                                                                                                                  
 #初始化数据库:                                                                                                                                  
                                                                                                                                                  
 #/usr/local/mysql/bin/mysqld\--defaults-file=/etc/my.cnf \--initialize-insecure \--user=mysql \--basedir=/usr/local/mysql \--datadir=/data/mysql 

添加环境变量:

使用root用户配置


 #vim /etc/profile                                                     
                                                                       
 export MYSQL_HOME=/usr/local/mysql #添加到末尾                        
                                                                       
 export PATH=\$PATH:\$MYSQL_HOME/bin #添加到末尾                       
                                                                       
 #source /etc/profile                                                  

mysql --version查看是否配置成功

配置mysql8服务

创建系统服务配置文件


 #systemctl enable mysqld                                              
                                                                       
 #systemctl daemon-reload                                              
                                                                       
 #systemctl start mysqld                                               
                                                                       
 #ystemctl status mysqld                                               

登录mysql数据库,修改密码并创建实例

 #vim /etc/systemd/system/mysqld.service                                                                   
                                                                                                           
 \[Unit\]                                                                                                  
                                                                                                           
 Description=Mysql Server                                                                                  
                                                                                                           
 Documentation=man:mysqld(8)                                                                               
                                                                                                           
 Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html                                       
                                                                                                           
 After=network.target                                                                                      
                                                                                                           
 After=syslog.target                                                                                       
                                                                                                           
 \[Service\]                                                                                               
                                                                                                           
 User=mysql                                                                                                
                                                                                                           
 Group=mysql                                                                                               
                                                                                                           
 PIDFile=/home/mysql/mysql.pid                                                                             
                                                                                                           
 #修改成mysql的启动文件及配置文件路径                                                                      
                                                                                                           
 ExecStart=/usr/local/mysql/bin/mysqld_safe \--defaults-file=/etc/my.cnf                                   
                                                                                                           
 \[Install\]                                                                                               
                                                                                                           
 WantedBy=multi-user.target                                                                                
                                                                                                           
 #:wq保存退出                                                                                              
                                                                                                           
 #mysql -u root -p                                                                                         
                                                                                                           
 #show databases;                                                                                          
                                                                                                           
 #ALTER USER \'root\'@\'localhost\' IDENTIFIED BY \'password\' PASSWORD EXPIRE NEVER;修改加密规则;        
                                                                                                           
 #ALTER USER \'root\'@\'localhost\' IDENTIFIED WITH mysql_native_password BY \'greatwall@123\'; 更新密码; 
                                                                                                           
 #FLUSH PRIVILEGES; 刷新                                                                                   
                                                                                                           
 #create database tpcc; 创建数据库                                                                         
                                                                                                           
 #show databases; 查看是否创建成功                                                                         
                                                                                                           
 #update mysql.user set host=\'%\' where user=\'root\';                                                    
                                                                                                           
 #FLUSH PRIVILEGES;                                                                                        

调优指南

使用初始化参数配置


 \[root@kptest10 \~\]# cat /etc/my.cnf                                                                        
                                                                                                              
 # For advice on how to change settings please see                                                           
                                                                                                              
 # http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html                                 
                                                                                                              
 \[mysqld\]                                                                                                   
                                                                                                              
 #                                                                                                           
                                                                                                              
 # 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                                                                                                   
                                                                                                              
 #                                                                                                           
                                                                                                              
 # Remove leading # to set options mainly useful for reporting servers.                                     
                                                                                                              
 # The server defaults are faster for transactions and fast SELECTs.                                         
                                                                                                              
 # Adjust sizes as needed, experiment to find the optimal values.                                            
                                                                                                              
 # join_buffer_size = 128M                                                                                   
                                                                                                              
 # sort_buffer_size = 2M                                                                                     
                                                                                                              
 # read_rnd_buffer_size = 2M                                                                                 
                                                                                                              
 # Remove leading # to revert to previous value for default_authentication_plugin,                          
                                                                                                              
 # this will increase compatibility with older clients. For background, see:                                 
                                                                                                              
 # https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin 
                                                                                                              
 # default-authentication-plugin=mysql_native_password                                                       
                                                                                                              
 skip-host-cache                                                                                              
                                                                                                              
 skip-name-resolve                                                                                            
                                                                                                              
 datadir=/data/mysql/                                                                                         
                                                                                                              
 socket=/data/mysql/mysqld.sock                                                                               
                                                                                                              
 #secure-file-priv=/data/mysql/mysql-files                                                                    
                                                                                                              
 user=mysql                                                                                                   
                                                                                                              
 max_connections = 2000                                                                                       
                                                                                                              
 pid-file=/data/mysql/mysqld.pid                                                                              
                                                                                                              
 \[client\]                                                                                                   
                                                                                                              
 socket=/data/mysql/mysqld.sock                                                                               
                                                                                                              
 #!includedir /etc/mysql/conf.d/                                                                              

内存管理优化


 #git clone https://github.com/jemalloc/jemalloc 推荐手工下载          
                                                                       
 #cd jemalloc                                                          
                                                                       
 #./autogen.sh                                                         
                                                                       
 #./configure                                                          
                                                                       
 #make && make install                                                 

#配置环境变量


 #vi /etc/profile                                                      
                                                                       
 export LD_PRELOAD=/usr/local/lib/libjemalloc.so                       
                                                                       
 export PATH=\$PATH:\$LD_PRELOAD                                       
                                                                       
 source /etc/profile                                                   
                                                                       
 指定用户重启mysqld.service                                            
                                                                       
 查看jemalloc是否生效                                                  
                                                                       
 lsof -n \grep jemalloc                                               
                                                                       
 #可忽略,如不生效可尝试。                                             
                                                                       
 #vim /opt/mysql-8.0.25/bin/mysql_safe                                 
                                                                       
 \[mysqld_safe\]                                                       
                                                                       
 malloc-lib=/usr/local/lib/libjemalloc.so                              

生效后的截图

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Z3ZrUUdY-1675994405586)(E:\localfiles\typora\pictures\image-20230210095621752.png)]

MYSQL配置项优化


 \[client\]                                                                                         
                                                                                                    
 port = 3306                                                                                        
                                                                                                    
 socket = /data/mysql/mysql.sock                                                                    
                                                                                                    
 \[mysql\]                                                                                          
                                                                                                    
 prompt = \"\\u@mysqldb \\R:\\m:\\s \[\\d\]\> \"                                                    
                                                                                                    
 no_auto_rehash                                                                                     
                                                                                                    
 loose-skip-binary-as-hex                                                                           
                                                                                                    
 \[mysqld\]                                                                                         
                                                                                                    
 user = mysql                                                                                       
                                                                                                    
 port = 3306                                                                                        
                                                                                                    
 #主从复制或MGR集群中,server_id记得要不同                                                          
                                                                                                    
 #另外,实例启动时会生成 auto.cnf,里面的 server_uuid 值也要不同                                    
                                                                                                    
 #server_uuid的值还可以自己手动指定,只要符合uuid的格式标准就可以                                   
                                                                                                    
 server_id = 3306                                                                                   
                                                                                                    
 basedir = /usr/local/mysql                                                                         
                                                                                                    
 #datadir = /tmp/mysql                                                                              
                                                                                                    
 datadir = /data/mysql                                                                              
                                                                                                    
 socket = /tmp/mysql/mysql.sock                                                                     
                                                                                                    
 pid_file = mysqldb.pid                                                                             
                                                                                                    
 character_set_server = UTF8MB4                                                                     
                                                                                                    
 skip_name_resolve = 1                                                                              
                                                                                                    
 default_time_zone = \"+8:00\"                                                                      
                                                                                                    
 #启用admin_port,连接数爆满等紧急情况下给管理员留个后门                                            
                                                                                                    
 admin_address = \'127.0.0.1\'                                                                      
                                                                                                    
 admin_port = 33062                                                                                 
                                                                                                    
 #performance setttings                                                                             
                                                                                                    
 lock_wait_timeout = 3600                                                                           
                                                                                                    
 open_files_limit = 65535                                                                           
                                                                                                    
 back_log = 1024                                                                                    
                                                                                                    
 max_connections = 10000                                                                            
                                                                                                    
 max_connect_errors = 1000000                                                                       
                                                                                                    
 # 可以打开的表缓存默认400                                                                         
                                                                                                    
 table_open_cache = 524288                                                                          
                                                                                                    
 #可以存储在表定义缓存中的表定义数默认400                                                           
                                                                                                    
 table_definition_cache = 524288                                                                    
                                                                                                    
 # 每个线程的堆栈大小,只要堆内存足够大处理复杂sql速度更快 最大512G                                
                                                                                                    
 thread_stack = 1G                                                                                  
                                                                                                    
 # 每个必须执行排序的会话都会分配一个此大小的缓冲区 用于Order by优化 最大512G                      
                                                                                                    
 sort_buffer_size = 1G                                                                              
                                                                                                    
 # 用于普通索引扫描、范围索引扫描和不使用索引并因此执行全表扫描的连接的缓冲区的最小大小 最大512G   
                                                                                                    
 join_buffer_size = 4G                                                                              
                                                                                                    
 # 对表进行顺序扫描的每个线程都会为其 MyISAM扫描的每个表分配此大小(以字节为单位)的缓冲区         
                                                                                                    
 read_buffer_size = 2147479552                                                                      
                                                                                                    
 # 此变量用于从MyISAM 表中读取,并且对于任何存储引擎,用于多范围读取优化 最大2G                    
                                                                                                    
 read_rnd_buffer_size = 2147483647                                                                  
                                                                                                    
 # MyISAM使用特殊的树状缓存来加快 INSERT 速度 最大512G 因为多数是使用Innodb所以该配置不变          
                                                                                                    
 bulk_insert_buffer_size = 64M                                                                      
                                                                                                    
 # 服务器应缓存多少线程以供重用 最大 16384                                                         
                                                                                                    
 thread_cache_size = 16384                                                                          
                                                                                                    
 interactive_timeout = 600                                                                          
                                                                                                    
 wait_timeout = 600                                                                                 
                                                                                                    
 # 临时表空间大小 最大512G                                                                         
                                                                                                    
 tmp_table_size = 10G                                                                               
                                                                                                    
 #MEMORY此变量设置允许用户创建的表增长的 最大 512G                                                  
                                                                                                    
 max_heap_table_size = 10G                                                                          
                                                                                                    
 #log settings                                                                                      
                                                                                                    
 log_timestamps = SYSTEM                                                                            
                                                                                                    
 log_error = /tmp/mysql/error.log                                                                   
                                                                                                    
 log_error_verbosity = 3                                                                            
                                                                                                    
 slow_query_log = 0                                                                                 
                                                                                                    
 log_slow_extra = 1                                                                                 
                                                                                                    
 slow_query_log_file = /tmp/mysql/slow.log                                                          
                                                                                                    
 long_query_time = 0.1                                                                              
                                                                                                    
 log_queries_not_using_indexes = 1                                                                  
                                                                                                    
 log_throttle_queries_not_using_indexes = 60                                                        
                                                                                                    
 min_examined_row_limit = 100                                                                       
                                                                                                    
 log_slow_admin_statements = 1                                                                      
                                                                                                    
 log_slow_slave_statements = 1                                                                      
                                                                                                    
 log_bin = /tmp/mysql/mybinlog                                                                      
                                                                                                    
 binlog_format = ROW                                                                                
                                                                                                    
 sync_binlog = 0 #MGR环境中由其他节点提供容错性,可不设置双1以提高本地节点性能                      
                                                                                                    
 binlog_cache_size = 4M                                                                             
                                                                                                    
 max_binlog_cache_size = 20G                                                                        
                                                                                                    
 max_binlog_size = 1073741824                                                                       
                                                                                                    
 binlog_rows_query_log_events = 1                                                                   
                                                                                                    
 binlog_expire_logs_seconds = 86400                                                                 
                                                                                                    
 #MySQL 8.0.22前,想启用MGR的话,需要设置binlog_checksum=NONE才行                                   
                                                                                                    
 binlog_checksum = CRC32                                                                            
                                                                                                    
 gtid_mode = ON                                                                                     
                                                                                                    
 enforce_gtid_consistency = TRUE                                                                    
                                                                                                    
 #myisam settings                                                                                   
                                                                                                    
 key_buffer_size = 32M                                                                              
                                                                                                    
 myisam_sort_buffer_size = 128M                                                                     
                                                                                                    
 #replication settings                                                                              
                                                                                                    
 relay_log_recovery = 1                                                                             
                                                                                                    
 slave_parallel_type = LOGICAL_CLOCK                                                                
                                                                                                    
 slave_parallel_workers = 64 #可以设置为逻辑CPU数量的2倍                                            
                                                                                                    
 binlog_transaction_dependency_tracking = WRITESET                                                  
                                                                                                    
 slave_preserve_commit_order = 1                                                                    
                                                                                                    
 slave_checkpoint_period = 2                                                                        
                                                                                                    
 #mgr settings                                                                                      
                                                                                                    
 loose-plugin_load_add = \'mysql_clone.so\'                                                         
                                                                                                    
 loose-plugin_load_add = \'group_replication.so\'                                                   
                                                                                                    
 loose-group_replication_group_name = \"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1\"                      
                                                                                                    
 #MGR本地节点IP:PORT,请自行替换                                                                    
                                                                                                    
 loose-group_replication_local_address = \"172.16.16.10:33061\"                                     
                                                                                                    
 #MGR集群所有节点IP:PORT,请自行替换                                                                
                                                                                                    
 loose-group_replication_group_seeds = \"172.16.16.10:33061,172.16.16.11:33061,172.16.16.12:33061\" 
                                                                                                    
 loose-group_replication_start_on_boot = OFF                                                        
                                                                                                    
 loose-group_replication_bootstrap_group = OFF                                                      
                                                                                                    
 loose-group_replication_exit_state_action = READ_ONLY                                              
                                                                                                    
 loose-group_replication_flow_control_mode = \"DISABLED\"                                           
                                                                                                    
 loose-group_replication_single_primary_mode = ON                                                   
                                                                                                    
 loose-group_replication_communication_max_message_size = 10M                                       
                                                                                                    
 loose-group_replication_unreachable_majority_timeout = 30                                          
                                                                                                    
 loose-group_replication_member_expel_timeout = 5                                                   
                                                                                                    
 loose-group_replication_autorejoin_tries = 288                                                     
                                                                                                    
 #innodb settings                                                                                   
                                                                                                    
 innodb_doublewrite=OFF                                                                             
                                                                                                    
 transaction_isolation = REPEATABLE-READ                                                            
                                                                                                    
 # 不要超过一个cpu的内存的大小否则性能下降一半 推荐230G                                            
                                                                                                    
 innodb_buffer_pool_size = 230G                                                                     
                                                                                                    
 innodb_buffer_pool_instances = 64                                                                  
                                                                                                    
 innodb_data_file_path = ibdata1:12M:autoextend                                                     
                                                                                                    
 innodb_flush_log_at_trx_commit = 1 #MGR环境中由其他节点提供容错性,可不设置双1以提高本地节点性能   
                                                                                                    
 # 日志buffer size 默认16m, 最大512G                                                              
                                                                                                    
 innodb_log_buffer_size = 1G                                                                        
                                                                                                    
 #如果线上环境的TPS较高,建议加大至1G以上,如果压力不大可以调小                                     
                                                                                                    
 innodb_log_file_size = 3G                                                                          
                                                                                                    
 innodb_log_files_in_group = 3                                                                      
                                                                                                    
 # 定义撤消表空间的阈值大小 默认1G                                                                 
                                                                                                    
 innodb_max_undo_log_size = 10G                                                                     
                                                                                                    
 # 根据您的服务器IOPS能力适当调整                                                                  
                                                                                                    
 # 一般配普通SSD盘的话,可以调整到 10000 - 20000                                                   
                                                                                                    
 # 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000                                    
                                                                                                    
 innodb_io_capacity = 50000                                                                         
                                                                                                    
 innodb_io_capacity_max = 80000                                                                     
                                                                                                    
 innodb_open_files = 65535                                                                          
                                                                                                    
 innodb_flush_method = O_DIRECT                                                                     
                                                                                                    
 innodb_lru_scan_depth = 4000                                                                       
                                                                                                    
 innodb_lock_wait_timeout = 800                                                                     
                                                                                                    
 innodb_rollback_on_timeout = 1                                                                     
                                                                                                    
 innodb_print_all_deadlocks = 1                                                                     
                                                                                                    
 innodb_online_alter_log_max_size = 4G                                                              
                                                                                                    
 innodb_print_ddl_logs = 1                                                                          
                                                                                                    
 innodb_status_file = 1                                                                             
                                                                                                    
 #注意: 开启 innodb_status_output & innodb_status_output_locks 后, 可能会导致log_error文件增长较快  
                                                                                                    
 innodb_status_output = 0                                                                           
                                                                                                    
 innodb_status_output_locks = 1                                                                     
                                                                                                    
 # 最大64G                                                                                         
                                                                                                    
 innodb_sort_buffer_size = 1G                                                                       
                                                                                                    
 innodb_adaptive_hash_index = OFF                                                                   
                                                                                                    
 #提高索引统计信息精确度                                                                            
                                                                                                    
 innodb_stats_persistent_sample_pages = 500                                                         
                                                                                                    
 #innodb monitor settings                                                                           
                                                                                                    
 innodb_monitor_enable = \"module_innodb\"                                                          
                                                                                                    
 innodb_monitor_enable = \"module_server\"                                                          
                                                                                                    
 innodb_monitor_enable = \"module_dml\"                                                             
                                                                                                    
 innodb_monitor_enable = \"module_ddl\"                                                             
                                                                                                    
 innodb_monitor_enable = \"module_trx\"                                                             
                                                                                                    
 innodb_monitor_enable = \"module_os\"                                                              
                                                                                                    
 innodb_monitor_enable = \"module_purge\"                                                           
                                                                                                    
 innodb_monitor_enable = \"module_log\"                                                             
                                                                                                    
 innodb_monitor_enable = \"module_lock\"                                                            
                                                                                                    
 innodb_monitor_enable = \"module_buffer\"                                                          
                                                                                                    
 innodb_monitor_enable = \"module_index\"                                                           
                                                                                                    
 innodb_monitor_enable = \"module_ibuf_system\"                                                     
                                                                                                    
 innodb_monitor_enable = \"module_buffer_page\"                                                     
                                                                                                    
 #innodb_monitor_enable = \"module_adaptive_hash\"                                                  
                                                                                                    
 #pfs settings                                                                                      
                                                                                                    
 performance_schema = 1                                                                             
                                                                                                    
 performance_schema_instrument = \'%memory%=on\'                                                    
                                                                                                    
 #performance_schema_instrument = \'%lock%=on\'                                                     
                                                                                                    
 #innodb_read_io_threads = 20                                                                       
                                                                                                    
 #innodb_write_io_threads = 8                                                                       
                                                                                                    
 #innodb_thread_concurrency = 256                                                                   
                                                                                                    
 #innodb_parallel_read_threads = 8                                                                  
                                                                                                    
 #innodb_purge_threads = 8                                                                          
                                                                                                    
 \[mysqldump\]                                                                                      
                                                                                                    
 Quick                                                                                              

MYSQL服务优化


 #vi /etc/systemd/sysetm/mysqld.service                                                          
                                                                                                 
 \[Unit\]                                                                                        
                                                                                                 
 Description=Mysql Server                                                                        
                                                                                                 
 Documentation=man:mysqld(8)                                                                     
                                                                                                 
 Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html                             
                                                                                                 
 After=network.target                                                                            
                                                                                                 
 After=syslog.target                                                                             
                                                                                                 
 \[Service\]                                                                                     
                                                                                                 
 # 开放文件限制                                                                                 
                                                                                                 
 LimitNOFILE=655350                                                                              
                                                                                                 
 LimitNPROC=655350                                                                               
                                                                                                 
 User=mysql                                                                                      
                                                                                                 
 Group=mysql                                                                                     
                                                                                                 
 PIDFile=/home/mysql/mysql.pid                                                                   
                                                                                                 
 #绑定CPU1核心和CPU1内存                                                                         
                                                                                                 
 ExecStart=numactl -N 8-15 -m 8-15 /usr/local/mysql/bin/mysqld_safe \--defaults-file=/etc/my.cnf 
                                                                                                 
 \[Install\]                                                                                     
                                                                                                 
 WantedBy=multi-user.target                                                                      

                    
                                                                                                 
 #绑定CPU1核心和CPU1内存                                                                         
                                                                                                 
 ExecStart=numactl -N 8-15 -m 8-15 /usr/local/mysql/bin/mysqld_safe \--defaults-file=/etc/my.cnf 
                                                                                                 
 \[Install\]                                                                                     
                                                                                                 
 WantedBy=multi-user.target                                                                      

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值