免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2131 | 回复: 6
打印 上一主题 下一主题

关于Mysql配置参数的设置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-24 10:04 |只看该作者 |倒序浏览
系统信息如下:

intel dual CPU  1.6G
内存:  1G
操作系统:  fedora 8 ---kernel 2.6.20

我的my.cnf 文件内容如下:
=======================================================================================================================

# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/var) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password        = your_password
port                = 3306
#socket                = /var/lib/mysql/mysql.sock
socket                = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port                = 3306
socket                = /tmp/mysql.sock
skip-locking
#key_buffer = 384M
key_buffer = 512M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
#query_cache_size = 32M
query_cache_size = 128M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id        = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Point the following paths to different dedicated disks
#tmpdir                = /tmp/               
#log-update         = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 384M
#bdb_max_lock = 100000

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/var/
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = /usr/local/var/
#innodb_log_arch_dir = /usr/local/var/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

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

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

[mysqlhotcopy]
interactive-timeout
====================================================================

我想1ms写一次数据库,操作10个表,每个表50列,测试发现数据来不及写入书库,会出现数据丢失,

请大家看看俺的my.cnf文件,指导下还有哪些参数可以优化。  



[ 本帖最后由 rsmgnu 于 2008-7-24 10:32 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-07-24 10:08 |只看该作者
You total memory is too small that it can not afford your configuration.

论坛徽章:
1
白银圣斗士
日期:2015-11-23 08:33:04
3 [报告]
发表于 2008-07-24 10:10 |只看该作者
这个不咱样。

要看status 出来的数据。

论坛徽章:
0
4 [报告]
发表于 2008-07-24 10:37 |只看该作者
原帖由 yueliangdao0608 于 2008-7-24 10:08 发表
You total memory is too small that it can not afford your configuration.



奥,我加块内存再测试一下,多谢  :)

论坛徽章:
0
5 [报告]
发表于 2008-07-24 10:48 |只看该作者
原帖由 枫影谁用了 于 2008-7-24 10:10 发表
这个不咱样。

要看status 出来的数据。


俺的status 如下,请帮忙看看。

=============================================

mysql> show status;
+-----------------------------------+-----------+
| Variable_name                     | Value     |
+-----------------------------------+-----------+
| Aborted_clients                   | 0         |
| Aborted_connects                  | 0         |
| Binlog_cache_disk_use             | 0         |
| Binlog_cache_use                  | 0         |
| Bytes_received                    | 322       |
| Bytes_sent                        | 2867      |
| Com_admin_commands                | 0         |
| Com_alter_db                      | 0         |
| Com_alter_table                   | 0         |
| Com_analyze                       | 0         |
| Com_backup_table                  | 0         |
| Com_begin                         | 0         |
| Com_call_procedure                | 0         |
| Com_change_db                     | 2         |
| Com_change_master                 | 0         |
| Com_check                         | 0         |
| Com_checksum                      | 0         |
| Com_commit                        | 0         |
| Com_create_db                     | 1         |
| Com_create_function               | 0         |
| Com_create_index                  | 0         |
| Com_create_table                  | 0         |
| Com_create_user                   | 0         |
| Com_dealloc_sql                   | 0         |
| Com_delete                        | 0         |
| Com_delete_multi                  | 0         |
| Com_do                            | 0         |
| Com_drop_db                       | 0         |
| Com_drop_function                 | 0         |
| Com_drop_index                    | 0         |
| Com_drop_table                    | 0         |
| Com_drop_user                     | 0         |
| Com_execute_sql                   | 0         |
| Com_flush                         | 0         |
| Com_grant                         | 0         |
| Com_ha_close                      | 0         |
| Com_ha_open                       | 0         |
| Com_ha_read                       | 0         |
| Com_help                          | 0         |
| Com_insert                        | 0         |
| Com_insert_select                 | 0         |
| Com_kill                          | 0         |
| Com_load                          | 0         |
| Com_load_master_data              | 0         |
| Com_load_master_table             | 0         |
| Com_lock_tables                   | 0         |
| Com_optimize                      | 0         |
| Com_preload_keys                  | 0         |
| Com_prepare_sql                   | 0         |
| Com_purge                         | 0         |
| Com_purge_before_date             | 0         |
| Com_rename_table                  | 0         |
| Com_repair                        | 0         |
| Com_replace                       | 0         |
| Com_replace_select                | 0         |
| Com_reset                         | 0         |
| Com_restore_table                 | 0         |
| Com_revoke                        | 0         |
| Com_revoke_all                    | 0         |
| Com_rollback                      | 0         |
| Com_savepoint                     | 0         |
| Com_select                        | 3         |
| Com_set_option                    | 0         |
| Com_show_binlog_events            | 0         |
| Com_show_binlogs                  | 0         |
| Com_show_charsets                 | 0         |
| Com_show_collations               | 0         |
| Com_show_column_types             | 0         |
| Com_show_create_db                | 0         |
| Com_show_create_table             | 0         |
| Com_show_databases                | 2         |
| Com_show_errors                   | 0         |
| Com_show_fields                   | 1         |
| Com_show_grants                   | 0         |
| Com_show_innodb_status            | 0         |
| Com_show_keys                     | 0         |
| Com_show_logs                     | 0         |
| Com_show_master_status            | 0         |
| Com_show_ndb_status               | 0         |
| Com_show_new_master               | 0         |
| Com_show_open_tables              | 0         |
| Com_show_privileges               | 0         |
| Com_show_processlist              | 0         |
| Com_show_slave_hosts              | 0         |
| Com_show_slave_status             | 0         |
| Com_show_status                   | 1         |
| Com_show_storage_engines          | 0         |
| Com_show_tables                   | 2         |
| Com_show_triggers                 | 0         |
| Com_show_variables                | 0         |
| Com_show_warnings                 | 0         |
| Com_slave_start                   | 0         |
| Com_slave_stop                    | 0         |
| Com_stmt_close                    | 0         |
| Com_stmt_execute                  | 0         |
| Com_stmt_fetch                    | 0         |
| Com_stmt_prepare                  | 0         |
| Com_stmt_reset                    | 0         |
| Com_stmt_send_long_data           | 0         |
| Com_truncate                      | 0         |
| Com_unlock_tables                 | 0         |
| Com_update                        | 0         |
| Com_update_multi                  | 0         |
| Com_xa_commit                     | 0         |
| Com_xa_end                        | 0         |
| Com_xa_prepare                    | 0         |
| Com_xa_recover                    | 0         |
| Com_xa_rollback                   | 0         |
| Com_xa_start                      | 0         |
| Compression                       | OFF       |
| Connections                       | 2         |
| Created_tmp_disk_tables           | 1         |
| Created_tmp_files                 | 5         |
| Created_tmp_tables                | 6         |
| Delayed_errors                    | 0         |
| Delayed_insert_threads            | 0         |
| Delayed_writes                    | 0         |
| Flush_commands                    | 1         |
| Handler_commit                    | 0         |
| Handler_delete                    | 0         |
| Handler_discover                  | 0         |
| Handler_prepare                   | 0         |
| Handler_read_first                | 0         |
| Handler_read_key                  | 0         |
| Handler_read_next                 | 0         |
| Handler_read_prev                 | 0         |
| Handler_read_rnd                  | 0         |
| Handler_read_rnd_next             | 68        |
| Handler_rollback                  | 0         |
| Handler_savepoint                 | 0         |
| Handler_savepoint_rollback        | 0         |
| Handler_update                    | 0         |
| Handler_write                     | 195       |
| Innodb_buffer_pool_pages_data     | 19        |
| Innodb_buffer_pool_pages_dirty    | 0         |
| Innodb_buffer_pool_pages_flushed  | 0         |
| Innodb_buffer_pool_pages_free     | 493       |
| Innodb_buffer_pool_pages_latched  | 0         |
| Innodb_buffer_pool_pages_misc     | 0         |
| Innodb_buffer_pool_pages_total    | 512       |
| Innodb_buffer_pool_read_ahead_rnd | 1         |
| Innodb_buffer_pool_read_ahead_seq | 0         |
| Innodb_buffer_pool_read_requests  | 77        |
| Innodb_buffer_pool_reads          | 12        |
| Innodb_buffer_pool_wait_free      | 0         |
| Innodb_buffer_pool_write_requests | 0         |
| Innodb_data_fsyncs                | 3         |
| Innodb_data_pending_fsyncs        | 0         |
| Innodb_data_pending_reads         | 0         |
| Innodb_data_pending_writes        | 0         |
| Innodb_data_read                  | 2494464   |
| Innodb_data_reads                 | 25        |
| Innodb_data_writes                | 3         |
| Innodb_data_written               | 1536      |
| Innodb_dblwr_pages_written        | 0         |
| Innodb_dblwr_writes               | 0         |
| Innodb_log_waits                  | 0         |
| Innodb_log_write_requests         | 0         |
| Innodb_log_writes                 | 1         |
| Innodb_os_log_fsyncs              | 3         |
| Innodb_os_log_pending_fsyncs      | 0         |
| Innodb_os_log_pending_writes      | 0         |
| Innodb_os_log_written             | 512       |
| Innodb_page_size                  | 16384     |
| Innodb_pages_created              | 0         |
| Innodb_pages_read                 | 19        |
| Innodb_pages_written              | 0         |
| Innodb_row_lock_current_waits     | 0         |
| Innodb_row_lock_time              | 0         |
| Innodb_row_lock_time_avg          | 0         |
| Innodb_row_lock_time_max          | 0         |
| Innodb_row_lock_waits             | 0         |
| Innodb_rows_deleted               | 0         |
| Innodb_rows_inserted              | 0         |
| Innodb_rows_read                  | 0         |
| Innodb_rows_updated               | 0         |
| Key_blocks_not_flushed            | 0         |
| Key_blocks_unused                 | 463920    |
| Key_blocks_used                   | 0         |
| Key_read_requests                 | 0         |
| Key_reads                         | 0         |
| Key_write_requests                | 0         |
| Key_writes                        | 0         |
| Last_query_cost                   | 10.499000 |
| Max_used_connections              | 1         |
| Not_flushed_delayed_rows          | 0         |
| Open_files                        | 14        |
| Open_streams                      | 0         |
| Open_tables                       | 6         |
| Opened_tables                     | 0         |
| Prepared_stmt_count               | 0         |
| Qcache_free_blocks                | 1         |
| Qcache_free_memory                | 134208792 |
| Qcache_hits                       | 0         |
| Qcache_inserts                    | 0         |
| Qcache_lowmem_prunes              | 0         |
| Qcache_not_cached                 | 9         |
| Qcache_queries_in_cache           | 0         |
| Qcache_total_blocks               | 1         |
| Questions                         | 15        |
| Rpl_status                        | NULL      |
| Select_full_join                  | 0         |
| Select_full_range_join            | 0         |
| Select_range                      | 0         |
| Select_range_check                | 0         |
| Select_scan                       | 6         |
| Slave_open_temp_tables            | 0         |
| Slave_retried_transactions        | 0         |
| Slave_running                     | OFF       |
| Slow_launch_threads               | 0         |
| Slow_queries                      | 0         |
| Sort_merge_passes                 | 0         |
| Sort_range                        | 0         |
| Sort_rows                         | 0         |
| Sort_scan                         | 0         |
| Table_locks_immediate             | 12        |
| Table_locks_waited                | 0         |
| Tc_log_max_pages_used             | 0         |
| Tc_log_page_size                  | 0         |
| Tc_log_page_waits                 | 0         |
| Threads_cached                    | 0         |
| Threads_connected                 | 1         |
| Threads_created                   | 1         |
| Threads_running                   | 1         |
| Uptime                            | 1950      |
| Uptime_since_flush_status         | 1950      |
+-----------------------------------+-----------+
226 rows in set (0.01 sec)

====================================================


谢谢拉  

论坛徽章:
0
6 [报告]
发表于 2008-07-24 18:18 |只看该作者
顶起来撒~~~~~~~~~

论坛徽章:
8
综合交流区版块每周发帖之星
日期:2015-12-02 15:03:53数据库技术版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-09-14 06:20:00金牛座
日期:2014-10-10 11:23:34CU十二周年纪念徽章
日期:2013-10-24 15:41:34酉鸡
日期:2013-10-19 10:17:1315-16赛季CBA联赛之北京
日期:2017-03-06 15:12:44
7 [报告]
发表于 2008-07-24 18:43 |只看该作者
把相关的cache/buffer调大点


不用的引擎skip
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP