美文网首页
迁移数据库目录至其他主机后数据库无法启动

迁移数据库目录至其他主机后数据库无法启动

作者: Punk | 来源:发表于2019-03-27 16:23 被阅读0次

    场景:

    A机器拷贝的数据库数据目录到B机器,加压缩后数据库无法启动(数据库太大27个G左右,导表非常慢,索性直接打包数据库目录)

    版本:

    OS Version:
    [root@environment lib]# lsb_release -a
    LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
    Distributor ID: CentOS
    Description:    CentOS Linux release 7.5.1804 (Core) 
    Release:    7.5.1804
    Codename:   Core
    
    DB Version:
    [root@environment lib]# mysql -uroot -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2
    Server version: 5.5.60-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    

    安装数据库:

    (a)  yum -y mariadb-sevrer   //安装数据库
    (b)  mysql_secure_installation  //启动数据库初始化 ,并设置密码
    (c)  systemctl stop mariadb    //停止数据库并 删掉/var/lib/mysql目录
    (d)  unzip xxxxx.zip   yyyyyyyyyyyyyyyy.zip    // 解压到当前目录
    

    报错信息:

    启动数据库后报错:

    (1) 第一个错误:
      [root@environment ~]# tailf /var/log/mariadb/mariadb.log 
    190327 16:14:16 InnoDB: Using Linux native AIO
    190327 16:14:16 InnoDB: Initializing buffer pool, size = 128.0M
    190327 16:14:16 InnoDB: Completed initialization of buffer pool
    190327 16:14:16  InnoDB: Operating system error number 13 in a file operation.
    InnoDB: The error means mysqld does not have the access rights to
    InnoDB: the directory.
    InnoDB: File name ./ibdata1
    InnoDB: File operation call: 'open'.
    InnoDB: Cannot continue operation.
    190327 16:14:16 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
    
    解决办法:
      原因: 解压后的文件数主数组需要改为mysql用户,且/var/run/mariadb 也需要改为mysql用户
    

    (2) 第二个错误:

    数据库日志:
    tailf /var/log/mariadb/mariadb.log
    Server version: 5.5.60-MariaDB
    key_buffer_size=134217728
    read_buffer_size=131072
    max_used_connections=0
    max_threads=153
    thread_count=0
    It is possible that mysqld could use up to 
    key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 466718 K  bytes of memory
    Hope that's ok; if not, decrease some variables in the equation.
    
    Thread pointer: 0x0
    Attempting backtrace. You can use the following information to find out
    where mysqld died. If you see no messages after this, something went
    terribly wrong...
    stack_bottom = 0x0 thread_stack 0x48000
    190119 12:54:23 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
    190119 12:55:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    190119 12:55:54 [Note] /usr/libexec/mysqld (mysqld 5.5.60-MariaDB) starting as process 10885 ...
    190119 12:55:54 InnoDB: The InnoDB memory heap is disabled
    190119 12:55:54 InnoDB: Mutexes and rw_locks use GCC atomic builtins
    190119 12:55:54 InnoDB: Compressed tables use zlib 1.2.7
    190119 12:55:54 InnoDB: Using Linux native AIO
    190119 12:55:54 InnoDB: Initializing buffer pool, size = 128.0M
    190119 12:55:54 InnoDB: Completed initialization of buffer pool
    190119 12:55:54 InnoDB: highest supported file format is Barracuda.
    190119 12:55:54  InnoDB: Starting crash recovery from checkpoint LSN=25825591529
    InnoDB: Restoring possible half-written data pages from the doublewrite buffer...
    190119 12:55:54  InnoDB: Starting final batch to recover 15 pages from redo log
    190119 12:55:54 [ERROR] mysqld got signal 11 ;
    This could be because you hit a bug. It is also possible that this binary
    or one of the libraries it was linked against is corrupt, improperly built,
    or misconfigured. This error can also be caused by malfunctioning hardware.
    
    To report this bug, see http://kb.askmonty.org/en/reporting-bugs
    
    We will try our best to scrape up some info that will hopefully help
    diagnose the problem, but since we have already crashed, 
    something is definitely wrong and this may fail.
    
    Server version: 5.5.60-MariaDB
    key_buffer_size=134217728
    read_buffer_size=131072
    max_used_connections=0
    max_threads=153
    thread_count=0
    It is possible that mysqld could use up to 
    key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 466718 K  bytes of memory
    Hope that's ok; if not, decrease some variables in the equation.
    
    Thread pointer: 0x0
    Attempting backtrace. You can use the following information to find out
    where mysqld died. If you see no messages after this, something went
    
    服务状态:
    #systemctl status mariadb
    ● mariadb.service - MariaDB database server
       Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
       Active: failed (Result: exit-code) since Sat 2019-01-19 12:49:08 CST; 3s ago
      Process: 9550 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
      Process: 9549 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
      Process: 9517 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
     Main PID: 9549 (code=exited, status=0/SUCCESS)
    
    Jan 19 12:49:06 console systemd[1]: Starting MariaDB database server...
    Jan 19 12:49:06 console mariadb-prepare-db-dir[9517]: Database MariaDB is probably initialized in /var/lib/mysql alre
    Jan 19 12:49:06 console mariadb-prepare-db-dir[9517]: If this is not the case, make sure the /var/lib/mysql is empty 
    Jan 19 12:49:06 console mysqld_safe[9549]: 190119 12:49:06 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
    Jan 19 12:49:06 console mysqld_safe[9549]: 190119 12:49:06 mysqld_safe Starting mysqld daemon with databases from /va
    Jan 19 12:49:08 console systemd[1]: mariadb.service: control process exited, code=exited status=1
    Jan 19 12:49:08 console systemd[1]: Failed to start MariaDB database server.
    Jan 19 12:49:08 console systemd[1]: Unit mariadb.service entered failed state.
    Jan 19 12:49:08 console systemd[1]: mariadb.service failed.
    
    解决方式:
    修改配置文件:
    在 [mysqld]
    添加参数:innodb_force_recovery = 6   (此项由1---6个级别一次往上修改参数在失败的情况下)
        innodb_purge_threads = 0
    

    相关文章

      网友评论

          本文标题:迁移数据库目录至其他主机后数据库无法启动

          本文链接:https://www.haomeiwen.com/subject/eonzvqtx.html