开发者社区> 问答> 正文

求一个mysql 8GB内存的my.cnf配置~数据库报错

RT,配置my.cnf各种出错,导致我的mysql无法正常启动,十分抑郁。。。多谢各位 image.png

展开
收起
python小菜菜 2020-05-27 15:56:47 887 0
1 条回答
写回答
取消 提交回答
  • 哪个版本?官方给的应该是4G的配置吧

    ######5.0的。。版本太低了不好找- -这个不通用么?######

    在官方给的版本基础上改吧,可以参考phpmyadmin里的状态提示。

    如果报错,那就根据错误消息修正错误,google,或者帖出来让大家帮忙。

    不给细节,恐怕没人能帮你决问题

    ######

    我的12G内存服务器上的配置,web与数据库都在该机器上;负荷不太高。可以参考

    [mysqld]

    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0

    #add by feng 120418  --------------------------
    skip-locking
    key_buffer_size = 128M
    table_cache = 1024
    read_buffer_size = 2M
    read_rnd_buffer_size = 2M
    sort_buffer_size = 2M
    myisam_sort_buffer_size = 256M
    thread_cache_size = 8
    query_cache_size= 256M
    query_cache_limit= 5M
    tmp_table_size=1024M
    max_heap_table_size=1024M
    max_allowed_packet = 16M
    table_open_cache = 3072
    innodb_buffer_pool_size = 512M
    innodb_log_file_size = 256M
    innodb_additional_mem_pool_size=128M
    max_connections=2000
    join_buffer_size = 8M
    #tmpdir=/dev/shm
    #add by feng 120418  end ---------------------

    log-slow-queries=/var/run/mysqld/mysqld-slow.log
    slow_launch_time=1

    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid

    ######

    引用来自“fengyqf”的答案

    我的12G内存服务器上的配置,web与数据库都在该机器上;负荷不太高。可以参考

    [mysqld]

    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0

    #add by feng 120418  --------------------------
    skip-locking
    key_buffer_size = 128M
    table_cache = 1024
    read_buffer_size = 2M
    read_rnd_buffer_size = 2M
    sort_buffer_size = 2M
    myisam_sort_buffer_size = 256M
    thread_cache_size = 8
    query_cache_size= 256M
    query_cache_limit= 5M
    tmp_table_size=1024M
    max_heap_table_size=1024M
    max_allowed_packet = 16M
    table_open_cache = 3072
    innodb_buffer_pool_size = 512M
    innodb_log_file_size = 256M
    innodb_additional_mem_pool_size=128M
    max_connections=2000
    join_buffer_size = 8M
    #tmpdir=/dev/shm
    #add by feng 120418  end ---------------------

    log-slow-queries=/var/run/mysqld/mysqld-slow.log
    slow_launch_time=1

    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid

    [client]
    #password    = your_password
    port        = 3306
    socket        = /data/mysql/tmp/mysql.sock
    [mysqld]
    port        = 3306
    socket        = /data/mysql/tmp/mysql.sock
    skip-locking
    key_buffer = 256M
    max_connections=1500
    max_allowed_packet = 1M
    table_cache = 256
    sort_buffer_size = 1M
    read_buffer_size = 1M
    read_rnd_buffer_size = 4M
    myisam_sort_buffer_size = 64M
    thread_cache_size = 8
    query_cache_size= 16M
    thread_concurrency = 8


    log-bin=mysql-bin


    server-id    = 1



    [mysqldump]
    quick
    max_allowed_packet = 16M

    [mysql]
    no-auto-rehash

    [isamchk]
    key_buffer = 128M
    sort_buffer_size = 128M
    read_buffer = 2M
    write_buffer = 2M

    [myisamchk]
    key_buffer = 128M
    sort_buffer_size = 128M
    read_buffer = 2M
    write_buffer = 2M

    [mysqlhotcopy]
    interactive-timeout


    这个是我的配置,请问应该如何修改?您的那个有好几个配置我都看不懂,也不敢瞎弄
    ######楼主,启动报错的消息有没有?你是不是自己编译的MySQL,或者是什么一键安装包编译的?强烈不建议使用它们!会编译,就自己使用官方源码编,不会,就直接用yum,apt-get等装。 另外,MySQL的配置最好要看具体运行情况有针对的优化。######

    引用来自“fengyqf”的答案

    楼主,启动报错的消息有没有?你是不是自己编译的MySQL,或者是什么一键安装包编译的?强烈不建议使用它们!会编译,就自己使用官方源码编,不会,就直接用yum,apt-get等装。 另外,MySQL的配置最好要看具体运行情况有针对的优化。

    log日志:

    Number of processes running now: 0
    131024 11:10:09  mysqld restarted
    ?/data/mysql/libexec/mysqld: File '/var/run/mysqld/mysqld-slow.log' not found (Errcode: 2)
    131024 11:10:09 [ERROR] Could not use /var/run/mysqld/mysqld-slow.log for logging (error 2). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.
    131024 11:10:09  InnoDB: Database was not shut down normally!
    InnoDB: Starting crash recovery.
    InnoDB: Reading tablespace information from the .ibd files...
    InnoDB: Restoring possible half-written data pages from the doublewrite
    InnoDB: buffer...
    131024 11:10:09  InnoDB: Starting log scan based on checkpoint at
    InnoDB: log sequence number 0 36808.
    InnoDB: Doing recovery: scanned up to log sequence number 0 43655
    131024 11:10:09  InnoDB: Starting an apply batch of log records to the database...
    InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99


    另外附上的安装编译:

    ./configure --prefix=/data/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-big-tables --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-ndb-debug --with-unix-socket-path=/data/mysql/tmp/mysql.sock

    添加MySQL配置文件及访问权限

    # cd /data/mysql

    # bin/mysql_install_db --user=mysql

    # chown -R root:mysql . //设置权限,注意后面有一个 "."

    # chown -R mysql /var/lib/mysql //设置 mysql 目录权限,可省略

    # chgrp -R mysql . //注意后面有一个 "."

    # cp share/mysql/my-large.cnf /etc/my.cnf

    这个文档我已经用了很久很久了,以前用的centos5.5一直没有问题,这次服务器不能安装5.5,我才换的6.3,而且之前用虚拟机虚拟过一个32位的6.3安装也没问题,现在这个服务器是64位的,8G内存,不知道为什么就是死活不行。。。

    ######检查下innodb数据库文件,可能损坏了,重建下试试。 不同版本之间配置选项有所不同,要注意下######

    引用来自“fengyqf”的答案

    检查下innodb数据库文件,可能损坏了,重建下试试。 不同版本之间配置选项有所不同,要注意下
    我已经重新装过一次了,还是一样的问题,我觉得应该可以排除某文件损坏的问题。。
    ######

    检查一个这个Innodb数据库文件,删除重建,不是重装。

    如果不行,那就难说了。建议使用rpm包吧。

    ######

    引用来自“fengyqf”的答案

    检查一个这个Innodb数据库文件,删除重建,不是重装。

    如果不行,那就难说了。建议使用rpm包吧。

    好吧。。那有教程吗- -麻烦给我发一个呗。。谢谢了
    2020-05-29 17:54:07
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
DTCC 2022大会集锦《云原生一站式数据库技术与实践》 立即下载
内存取证与IaaS云平台恶意行 为的安全监控 立即下载
云服务器ECS内存增强型实例re6全新发布 立即下载

相关镜像