当前位置:网站首页>Cannot start after installing MySQL 5.7.27 in CentOS 7? (Language bash)
Cannot start after installing MySQL 5.7.27 in CentOS 7? (Language bash)
2022-07-27 10:00:00 【CSDN Q & A】
The phenomenon and background of the problem
Use @ high & jade Script in Centos 7 install Mysql 5.7.27 Can't start after
Problem related code , Do not paste screenshots
#!/bin/bashset -eMYSQL_PASSWD="Yinhai"MYSQL_DATADIR=/data/mysql/dataMYSQL_PORT='3306'TOTAL_MEM=`free -g | grep Mem | awk '{print $2}'`TOTAL_MEM_PERCENT_70=`echo "($TOTAL_MEM*0.7)/1"`INNODB_BUFFER_POOL_SIZE=`echo $TOTAL_MEM_PERCENT_70"G"`# Operating system parameter adjustment system_parameter_update() {echo " Operating system parameter adjustment "# Disk scheduling for disk_name in `ls /sys/block/`do echo noop > /sys/block/$disk_name/queue/schedulerdone# Big page echo never >> /sys/kernel/mm/transparent_hugepage/enabledecho never >> /sys/kernel/mm/transparent_hugepage/defrag# Resource pool restrictions cat >> /etc/security/limits.conf <<EOF* soft nproc 655350* hard nproc 655350* soft nofile 655350* hard nofile 655350EOFecho "fs.file-max=655350" >> /etc/sysctl.conf#SWAPecho "vm.swappiness=0" >> /etc/sysctl.conf #dirty pageecho "5" > /proc/sys/vm/dirty_background_ratioecho "10" > /proc/sys/vm/dirty_ratio}# Download installation package wget_mysql_binary() {echo " download MySQL Installation package "if read -t 60 -p "Do you download the MySQL installation package(y/n)?" WGET_VALUEthen if [ "$WGET_VALUE" = "y" ] then wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.33-el7-x86_64.tar.gz fielse WGET_VALUE = "n"fi}# Delete mariadb package drop_mariadb() {echo "========================================= Delete mariadb==================================="mariadb_num=`rpm -qa | grep mariadb | wc -l`if [ $mariadb_num -ne 0 ]then rpm -qa | grep mariadb | xargs rpm -e --nodepsfi}# Install dependency packages yum_install_depend() {echo " Install dependency packages "yum install libaio -y}# establish mysql user user_add() {echo " establish mysql user "useradd mysql >>/dev/nullif read -t 60 -p "(Please input the mysql password(default:$MYSQL_PASSWD):" SYS_MYSQL_PASSWORDthen if [ "$SYS_MYSQL_PASSWORD" = "" ]; then SYS_MYSQL_PASSWORD="$MYSQL_PASSWD" fielse SYS_MYSQL_PASSWORD="$MYSQL_PASSWD"fiecho "$SYS_MYSQL_PASSWORD" | passwd mysql --stdinecho "export PATH=\$PATH:/usr/local/mysql/bin" >>/home/mysql/.bashrcecho "export PATH=\$PATH:/usr/local/mysql/bin" >>/root/.bashrc}# To configure MySQL Catalog install_mysql_path() {echo "MySQL DATADIR Catalog "echo -e "Please input the DATADIR of MySQL:"read -t 60 -p "(Default DATADIR:$MYSQL_DATADIR):" DATADIRif [ "$DATADIR" = "" ]; then DATADIR=$MYSQL_DATADIRfimkdir -p $DATADIRchown -R mysql:mysql $DATADIR/chmod -R 750 $DATADIRif [ $? -eq 0 ]then echo "Mkdir path Successfully."else echo "Mkdir path Failed!!!"fi}# Generate MySQL Parameter file conf_parameter_file_1() {echo " edit my.cnf The configuration file "if [ -f /etc/mysql/my.cnf ]then mv /etc/mysql/my.cnf /etc/mysql/my.cnf_$(date +%Y-%m-%d-%H:%M) fiif [ -f /etc/my.cnf ]then mv /etc/my.cnf /etc/my.cnf_$(date +%Y-%m-%d-%H:%M) fiSERVER_ID=$(date +%s)mkdir -p /etc/mysql/cat >> /etc/mysql/my.cnf <<EOF[client]user = root#password = $PASSWD[mysqld]bind_address = 0.0.0.0port = $MYSQL_PORTbasedir = /usr/local/mysqldatadir = $DATADIRsocket = /tmp/mysql.socklower-case-table-names = 1[mysql]prompt=(\[email protected]\h) [\d]>\_no-auto-rehashEOFchown -R mysql:mysql /etc/mysql}# initialization MySQLinitdb_mysql() {echo " initialization MySQL"if [ -d /usr/local/mysql ]then mv /usr/local/mysql /usr/local/mysql_$(date +%Y-%m-%d-%H-%M)fitar -zxf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mv /usr/local/mysql-5.7.27-linux-glibc2.12-x86_64 /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql/# initialization MySQLsu - mysql -c "mysqld --initialize-insecure --user=mysql"if [ $? -eq 0 ]then echo "MySQL initialize Successfully."else echo "MySQL initialize Failed!!!"fimkdir -p $DATADIR/logs/{log-bin,log-group,log-relay}chown -R mysql:mysql $DATADIR/chmod -R 750 $DATADIR}# Generate MySQL Parameter file conf_parameter_file_2() {echo " edit my.cnf The configuration file "if [ -f /etc/mysql/my.cnf ]then mv /etc/mysql/my.cnf /etc/mysql/my.cnf_$(date +%Y-%m-%d-%H:%M) fiif [ -f /etc/my.cnf ]then mv /etc/my.cnf /etc/my.cnf_$(date +%Y-%m-%d-%H:%M) fiSERVER_ID=$(date +%s)mkdir -p /etc/mysql/cat >> /etc/mysql/my.cnf <<EOF[client]user = root#password[mysqld]bind_address = 0.0.0.0port = $MYSQL_PORTbasedir = /usr/local/mysqldatadir = $DATADIRsocket = $DATADIR/mysql.sock# character character_set_server = utf8mb4lower-case-table-names = 1# Password policy #plugin-load-add = validate_password.sodefault_authentication_plugin=mysql_native_password# Log Settings sync_binlog = 1log-bin = $DATADIR/logs/log-bin/mysql-binbinlog_format = rowbinlog_row_image = fulllog_bin_trust_function_creators = 1expire_logs_days = 30#general_log = ongeneral_log_file = $DATADIR/logs/general.log log_error = $DATADIR/logs/error.logslow_query_log = onslow_query_log_file = $DATADIR/logs/slow.loglong_query_time = 2#min_examined_row_limit = 100#log_queries_not_using_indexes = on#log_throttle_queries_not_using_indexes = 4log_slow_admin_statements = onlog_output = filelog_slow_slave_statements = onrelay-log = $DATADIR/logs/log-relay/relay_logrelay_log_info_file = $DATADIR/logs/log-relay/relay-log.info# Connect max-connections = 1000back_log = 300max_allowed_packet = 64Minteractive_timeout = 28800wait_timeout = 28800# cache sort_buffer_size = 32Mtmp_table_size = 32Mjoin_buffer_size = 32Mread_buffer_size = 32Mread_rnd_buffer_size = 32Mkey_buffer_size = 64Mmyisam_sort_buffer_size = 64Mmax_heap_table_size = 16Mopen_files_limit = 65535thread_cache_size = 512table_open_cache = 16384table_definition_cache = 16384table_open_cache_instances = 8#InnoDBdefault-storage-engine = INNODBinnodb_buffer_pool_size = $INNODB_BUFFER_POOL_SIZEinnodb_adaptive_flushing = ONinnodb_adaptive_flushing_lwm = 15innodb_flushing_avg_loops = 30innodb_adaptive_hash_index = ONinnodb_data_home_dir = $DATADIRinnodb_file_per_table = ONinnodb_log_group_home_dir = $DATADIR/logs/log-group/innodb_log_files_in_group = 3innodb_log_buffer_size = 32Minnodb_flush_log_at_trx_commit = 1innodb_flush_log_at_timeout = 1innodb_lock_wait_timeout = 30innodb_buffer_pool_instances = 8innodb_change_buffering = allinnodb_change_buffer_max_size = 10innodb_autoextend_increment = 64innodb_thread_concurrency = 32innodb_spin_wait_delay = 6innodb_sync_spin_loops = 30innodb_open_files = 65535innodb_old_blocks_time = 30innodb_online_alter_log_max_size = 512Minnodb_write_io_threads = 8innodb_read_io_threads = 8innodb_flush_neighbors = 0innodb_io_capacity = 3000innodb_io_capacity_max = 16000innodb_lru_scan_depth = 1024innodb_purge_threads = 4innodb_purge_batch_size = 400innodb_buffer_pool_filename = ib_buffer_poolinnodb_buffer_pool_load_abort = OFFinnodb_buffer_pool_dump_now = OFFinnodb_buffer_pool_load_now = OFFinnodb_max_dirty_pages_pct = 75innodb_max_dirty_pages_pct_lwm = 0# Index column length innodb_default_row_format = dynamicinnodb_file_format = Barracudainnodb_large_prefix = ON#Replicationserver_id = $SERVER_ID#report_host = 10.46.203.123 # Local IPgtid_mode = onenforce_gtid_consistency = onloose-plugin_load_add = 'semisync_master.so'loose-plugin_load_add = 'semisync_slave.so'loose-rpl_semi_sync_master_enabled # Enable after installing the plug-in loose-rpl_semi_sync_slave_enabled # Enable after installing the plug-in loose-rpl_semi_sync_master_wait_point # Enable after installing the plug-in loose-rpl_semi_sync_master_timeout # Enable after installing the plug-in skip_slave_start = off # start-up MySQL Whether to skip startup slave process slave_parallel_type = LOGICAL_CLOCKslave_parallel_workers = 16slave_preserve_commit_order = onlog_slave_updates = on[mysql]prompt=(\[email protected]\h) [\d]>\_no-auto-rehashEOFchown -R mysql:mysql /etc/mysqlif [ $? -eq 0 ]then echo "Configure my.cnf Successfully."else echo "Configure my.cnf Failed!!!"fi}# install MySQL SSLinstall_ssl() {echo " install MySQL SSL"su - mysql -c "mysql_ssl_rsa_setup"chown mysql:mysql $DATADIR/*.pemif [ $? -eq 0 ]then echo "Install MySQL SSL Successfully."else echo "Install MySQL SSL Failed!!!"fi}# To configure MySQL Startup file conf_mysqld_file() {echo " To configure /etc/init.d/mysqld"if [ -f /etc/init.d/mysqld ]then mv /etc/init.d/mysqld /etc/init.d/mysqld_$(date +%Y-%m-%d-%H:%M)ficp -f /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqldif [ $? -eq 0 ]then echo "Configure /etc/init.d/mysqld Successfully."else echo "Configure /etc/init.d/mysqld Failed!!!"fichown mysql:mysql /etc/rc.d/init.d/mysqld}# start-up MySQLstart_mysql() {echo " start-up MySQl"su - mysql -c "/usr/local/mysql/support-files/mysql.server start"}# Configure enhanced replication config_rpl_semi() {echo " To configure MySQL Enhanced replication "su - mysql -c mysql <<EOFinstall plugin rpl_semi_sync_master soname 'semisync_master.so';install plugin rpl_semi_sync_slave soname 'semisync_slave.so';EOFsed -i "s/#rpl_semi_sync_master_enabled/rpl_semi_sync_master_enabled = on/g" /etc/mysql/my.cnfsed -i "s/#rpl_semi_sync_slave_enabled/rpl_semi_sync_slave_enabled = on/g" /etc/mysql/my.cnfsed -i "s/#rpl_semi_sync_master_wait_point/rpl_semi_sync_master_wait_point = AFTER_SYNC/g" /etc/mysql/my.cnfsed -i "s/#rpl_semi_sync_master_timeout/rpl_semi_sync_master_timeout = 5000/g" /etc/mysql/my.cnfsu - mysql -c "/etc/init.d/mysqld restart"}# modify the database root User's password change_mysql_root_password() {echo " modify MySQL User password "echo -e "Please set the MySQL root password:"read -t 60 -p "(The default MySQL root password is '$MYSQL_PASSWD'):" MYSQL_ROOT_PASSWORDif [ "$MYSQL_ROOT_PASSWORD" = "" ]; then MYSQL_ROOT_PASSWORD="$MYSQL_PASSWD"fisu - mysql -c mysql <<EOFset sql_log_bin = off;alter user 'root'@'localhost' identified by "$MYSQL_ROOT_PASSWORD";create user 'root'@'%' identified by "$MYSQL_ROOT_PASSWORD";grant all privileges on *.* to 'root'@'%';flush privileges;set sql_log_bin = on;EOFif [ $? -eq 0 ]then echo "Change mysql password Successfully."else echo "Change mysql password Failed!!!"fi}# modify my.cnf file change_parater_passwd() {echo " modify my.cnf file "sed -i "s/#password/password = '$MYSQL_ROOT_PASSWORD'/g" /etc/mysql/my.cnf}# Operating system parameter adjustment system_parameter_update# Download installation package #wget_mysql_binary# Delete mariadb package drop_mariadb# Install dependency packages #yum_install_depend# Create users and groups user_add# To configure MySQL Catalog install_mysql_path# Generate MySQL Parameter file conf_parameter_file_1# initialization MySQLinitdb_mysql# Generate MySQL Parameter file conf_parameter_file_2# install MySQL SSLinstall_ssl# To configure MySQL Startup file conf_mysqld_file# start-up MySQLstart_mysql# Configure enhanced replication #config_rpl_semi# modify the database root User's password change_mysql_root_password# modify my.cnf file change_parater_passwdecho -e " Operating system users mysql The password for is :$SYS_MYSQL_PASSWORD"echo -e "MySQL Database users mysql The password for is :$MYSQL_ROOT_PASSWORD"Operation results and error reporting contents
start-up MySQl
Starting MySQL.. ERROR! The server quit without updating PID file (/data/mysql/data/drgs.pid).
My solution ideas and tried methods
permissions
What I want to achieve
边栏推荐
- In depth analysis, sub database and sub table are the most powerful auxiliary sharding sphere
- 吃透Chisel语言.26.Chisel进阶之输入信号处理(二)——多数表决器滤波、函数抽象和异步复位
- July training (day 23) - dictionary tree
- Understand chisel language. 22. Chisel sequential circuit (II) -- detailed explanation of chisel counter: counter, timer and pulse width modulation
- 学习Typescript(一)
- Shell的正则表达式入门、常规匹配、特殊字符:^、$、.、*、字符区间(中括号):[ ]、特殊字符:\、匹配手机号
- Understand chisel language. 24. Chisel sequential circuit (IV) -- detailed explanation of chisel memory
- flash闪存使用和STM32CUBEMX安装教程【第三天】
- How to restore the original version after installing Hal Library
- July training (day 11) - matrix
猜你喜欢

给自己写一个年终总结,新年快乐!

二叉树习题总结

中高级试题」:MVCC 实现原理是什么?

In depth analysis, sub database and sub table are the most powerful auxiliary sharding sphere

刷题《剑指Offer》day03

MOS drive in motor controller

Concurrent Park and unpark description

语音直播系统——开发推送通知需要遵守的原则

吃透Chisel语言.25.Chisel进阶之输入信号处理(一)——异步输入与去抖动

深度剖析分库分表最强辅助Sharding Sphere
随机推荐
中高级试题」:MVCC 实现原理是什么?
Easy to understand! Graphic go synergy principle and Practice
3D restoration paper: shape painting using 3D generative advantageous networks and recurrent revolutionary networks
省应急管理厅:广州可争取推广幼儿应急安全宣教经验
I haven't delivered books for a long time, and I feel uncomfortable all over
面试京东 T5,被按在地上摩擦,鬼知道我经历了什么?
3D修复论文:Shape Inpainting using 3D Generative Adversarial Network and Recurrent Convolutional Networks
[cloud native] how can I compete with this database?
历时一年,论文终于被国际顶会接收了
[SCM]源码管理 - perforce 分支的锁定
电机控制器中的MOS驱动
After one year, the paper was finally accepted by the international summit
Qt 学习(二) —— Qt Creator简单介绍
Go Basics - arrays and slices
NPM common commands
Exercises --- quick arrangement, merging, floating point number dichotomy
Leetcode.814. binary tree pruning____ DFS
吃透Chisel语言.27.Chisel进阶之有限状态机(一)——基本有限状态机(Moore机)
July training (day 15) - depth first search
July training (day 23) - dictionary tree