当前位置:网站首页>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
边栏推荐
- At the end of the year, I'll teach you how to get high performance!
- 交换机端口镜像配置指南
- Understand chisel language. 26. Chisel advanced input signal processing (II) -- majority voter filtering, function abstraction and asynchronous reset
- Leetcode.565. array nesting____ Violent dfs- > pruning dfs- > in situ modification
- flash闪存使用和STM32CUBEMX安装教程【第三天】
- 并发之线程状态转换
- 找工作 4 个月, 面试 15 家,拿到 3 个 offer
- LeetCode.1260. 二维网格迁移____原地暴力 / 降维+循环数组直接定位
- A ride into Qinchuan -- a brief talk on how beego Autorouter works
- Understand chisel language. 23. Chisel sequential circuit (III) -- detailed explanation of chisel shift register
猜你喜欢

如何使用TDengine Sink Connector?

蚂蚁集团境外站点 Seata 实践与探索

会议OA项目之会议排座功能&&会议送审的实现

视觉SLAM十四讲笔记(一):第一讲+第二讲

QT learning (II) -- a brief introduction to QT Creator

LeetCode.814. 二叉树剪枝____DFS

It's great to write code for 32 inch curved screen display! Send another one!

Case of burr (bulge) notch (depression) detection of circular workpiece

Review of in vivo detection

NFT系统开发-教程
随机推荐
Understand chisel language. 23. Chisel sequential circuit (III) -- detailed explanation of chisel shift register
WordPress prohibits login or registration of plug-ins with a specified user name [v1.0]
Provincial Emergency Management Department: Guangzhou can strive to promote the experience of emergency safety education for children
直播倒计时 3 天|SOFAChannel#29 基于 P2P 的文件和镜像加速系统 Dragonfly
Meeting seating function of conference OA project & Implementation of meeting submission for approval
July training (day 09) - two point search
July training (the 26th day) - and check the collection
Concurrent Park and unpark description
Why do microservices have to have API gateways?
Is Damon partgroupdef a custom object?
Engineering survey simulation volume a
吃透Chisel语言.26.Chisel进阶之输入信号处理(二)——多数表决器滤波、函数抽象和异步复位
Brush the title "sword finger offer" day04
[scm] source code management - lock of perforce branch
July training (day 08) - prefix and
交换机端口镜像配置指南
如何在树莓派上安装cpolar内网穿透
S switch stacking scheme configuration guide
原生input标签的文件上传
吃透Chisel语言.24.Chisel时序电路(四)——Chisel内存(Memory)详解