If it's not a problem, it's probably not a problem. It looks a little weird, though.
I normally deal with MySQL instances on low-RAM systems, but sure enough, I see the same thing on my PC:
Code:
rtucker@witte:~$ free -m
total used free shared buffers cached
Mem: 11662 11335 327 0 837 3918
-/+ buffers/cache: 6578 5084
Swap: 12287 997 11290
rtucker@witte:~$ uname -a
Linux witte 2.6.32-35-generic #78-Ubuntu SMP Tue Oct 11 16:11:24 UTC 2011 x86_64 GNU/Linux
rtucker@witte:~$ ps auxwww | grep mysql
mysql 1735 0.0 0.7 1246196 87212 ? Ssl Oct23 47:11 /usr/sbin/mysqld
rtucker 24878 0.0 0.0 7628 920 pts/13 S+ 17:09 0:00 grep mysql
rtucker@witte:~$ sudo -i service mysql restart
mysql start/running, process 24995
(waits for it to stabilize)
rtucker@witte:~$ ps auxwww | grep mysql
mysql 24995 11.8 1.8 1112192 224984 ? Ssl 17:09 0:03 /usr/sbin/mysqld
rtucker 26029 0.0 0.0 7624 908 pts/13 S+ 17:10 0:00 grep mysql
rtucker@witte:~$ free -m
total used free shared buffers cached
Mem: 11662 11332 330 0 838 3967
-/+ buffers/cache: 6526 5136
Swap: 12287 763 11524
I'd recommend running
mysqltuner.pl and posting the output... you might not want to change anything (it will ALWAYS find something wrong with your config!), but the output is great for summarizing your settings at-a-glance:
Code:
rtucker@witte:~$ mysqltuner.pl
>> MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.1.41-3ubuntu12.10-log
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 43M (Tables: 158)
[--] Data in InnoDB tables: 764M (Tables: 748)
[!!] Total fragmented tables: 26
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 2m 10s (580 q [4.462 qps], 201 conn, TX: 57K, RX: 37K)
[--] Reads / Writes: 100% / 0%
[--] Total buffers: 869.0M global + 2.7M per thread (151 max threads)
[OK] Maximum possible memory usage: 1.2G (10% of installed RAM)
[OK] Slow queries: 0% (3/580)
[OK] Highest usage of available connections: 1% (2/151)
[!!] Key buffer size / total MyISAM indexes: 16.0M/23.5M
[!!] Query cache efficiency: 0.0% (0 cached / 383 selects)
[OK] Query cache prunes per day: 0
[OK] Temporary tables created on disk: 23% (48 on disk / 201 total)
[OK] Thread cache hit rate: 99% (2 created / 201 connections)
[!!] Table cache hit rate: 1% (96 open / 4K opened)
[OK] Open file limit used: 19% (195/1K)
[OK] Table locks acquired immediately: 100% (200 immediate / 200 locks)
[OK] InnoDB data size / buffer pool: 764.2M/800.0M
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours - recommendations may be inaccurate
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
key_buffer_size (> 23.5M)
query_cache_limit (> 4M, or use smaller result sets)
table_cache (> 96)
(I probably should have run this
before restarting mysqld, eh?)
The two big things to look at:
1) Maximum possible memory usage: this better be well below 2019 MB. I bet it's about 828 MB for you, though, if the pattern holds
2) InnoDB data size / buffer pool: this ratio should be below 1, but the denominator must be less than the amount of RAM you have. MySQL eventually reserves the right to use this much memory. The ratio should also be pretty close to 1, depending on how much your data is expected to grow. The InnoDB buffer pool size is a setting you control.
3) Data in MyISAM tables: should be very close to 0 MB. This is how much data you should plan to lose if someone sneezes near your database. (Sorry, couldn't resist.) But the InnoDB buffer pool only applies to InnoDB, and MyISAM memory management is a much more complex affair.
What I think is happening is that MySQL (and other things) have
requested all of that RAM, but the kernel is betting they won't actually need it right away. This is somewhat analogous to how banks operate: a particular percentage of assets must be liquid (per the reserve requirement), and if this falls short at any time, various Things happen Very Quickly to solve the problem before all hell breaks loose. Up to a point, your kernel can "loan out" more memory than it has available. This can involve swapping stuff out.
Another cause of swap usage is disk caching. It seems counter-intuitive, but if your kernel thinks swapping stuff out will yield better overall performance, it'll swap stuff out. I don't think this is the immediate cause for you (I'd expect to see more *****s on your Mem line in htop), but it is an example of the kernel's mindset. And yes, the kernel does predict how likely a given chunk of memory or disk is to be read when making these sorts of decisions.
tl;dr: It's probably normal. The kernel will do weird stuff for performance.
_________________
Code:
/* TODO: need to add signature to posts */