简体   繁体   English

从ubuntu机器上移动mysql成功,但是内存消耗来自旧目录

[英]moving mysql from ubuntu machine was successful, but the memory consumption is from old directory

I installed apache,mysql, phpmyadmin in my ubuntu machine. 我在ubuntu机器上安装了apache,mysql,phpmyadmin。 I have a large database to store in mysql, so moved mysql from root to /mnt0 directory. 我有一个很大的数据库要存储在mysql中,因此将mysql从根目录移到/ mnt0目录。 But looks like mnt0's memory is not consumed at all rather root directory's memory is consumed. 但是看起来根本没有消耗mnt0的内存,而是消耗了根目录的内存。 which means maybe moving mysql was not successful. 这意味着可能无法成功移动mysql。 Below is the memory usage of my machine (when I started root directory, it had 6.3G of memory available. After using the database for a while, the available memory in root is 5.1G & mnt0 looks the same, I mean no memory usage) 下面是我的机器的内存使用情况(当我启动根目录时,它具有6.3G的可用内存。使用数据库一段时间后,根目录中的可用内存为5.1G&mnt0看起来相同,我的意思是没有内存使用率)

Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      7.8G  2.4G  5.1G  32% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            3.7G  8.0K  3.7G   1% /dev
tmpfs           752M  212K  752M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            3.7G     0  3.7G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/xvdb       414G  485M  392G   1% /mnt0

This is where I moved mysql to buntu@ip-xx-xxx-xxx-xxx:/mnt0$ ls -l drwx------ 2 root root 16384 Feb 6 00:17 lost+found drwx------ 8 mysql mysql 4096 Feb 21 19:37 mysql 这是我将mysql移至buntu @ ip-xx-xxx-xxx-xxx:/ mnt0 $ ls -l drwx ------ 2根root 16384 Feb 6 00:17 lost + found drwx ----- -8个mysql mysql 4096 2月21日19:37 mysql

I have changed this file /etc/apparmor.d/usr.sbin.mysql for new datadir. 我已经将此文件/etc/apparmor.d/usr.sbin.mysql更改为新的datadir。 /mnt0$ cat /etc/apparmor.d/usr.sbin.mysqld / mnt0 $ cat /etc/apparmor.d/usr.sbin.mysqld

# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>

/usr/sbin/mysqld {
  #include <abstractions/base>
  #include <abstractions/nameservice>
  #include <abstractions/user-tmp>
  #include <abstractions/mysql>
  #include <abstractions/winbind>

  capability dac_override,
  capability sys_resource,
  capability setgid,
  capability setuid,

  network tcp,

  /etc/hosts.allow r,
  /etc/hosts.deny r,

  /etc/mysql/*.pem r,
  /etc/mysql/conf.d/ r,
  /etc/mysql/conf.d/* r,
  /etc/mysql/*.cnf r,
  /usr/lib/mysql/plugin/ r,
  /usr/lib/mysql/plugin/*.so* mr,
  /usr/sbin/mysqld mr,
  /usr/share/mysql/** r,
  /var/log/mysql.log rw,
  /var/log/mysql.err rw,

  /mnt0/mysql/ r,
  /mnt0/mysql/** rwk,

  /var/log/mysql/ r,
  /var/log/mysql/* rw,
  /var/run/mysqld/mysqld.pid rw,
  /var/run/mysqld/mysqld.sock w,
  /run/mysqld/mysqld.pid rw,
  /run/mysqld/mysqld.sock w,

  /sys/devices/system/cpu/ r,

  # Site-specific additions and overrides. See local/README for details.
  #include <local/usr.sbin.mysqld>
}

Edit: added du -kh of /mnt0 & ls -lha /mnt0/mysql 编辑:添加了/ mnt0和ls -lha / mnt0 / mysql的du -kh

root@ip-xx-xxx-xxx-xxx:/mnt0# du -kh
204K    ./mysql-crapy/mysql/phpmyadmin
4.0K    ./mysql-crapy/mysql/test
212K    ./mysql-crapy/mysql/performance_schema
1.1M    ./mysql-crapy/mysql/mysql
30M ./mysql-crapy/mysql
30M ./mysql-crapy
16K ./lost+found
40K ./api.Kavitha.com
32K ./mysql/DB
224K    ./mysql/phpmyadmin
4.0K    ./mysql/test
212K    ./mysql/performance_schema
1.1M    ./mysql/mysql
20K ./mysql/KavithaDataBase
110M    ./mysql
96K ./CoreUtils/cli/fb
952K    ./CoreUtils/cli
44K ./CoreUtils/addrstd
43M ./CoreUtils/db
12K ./CoreUtils/etc-conf
16K ./CoreUtils/feeds
16K ./CoreUtils/api/
68K ./CoreUtils/api
104M    ./CoreUtils/dict
16K ./CoreUtils/core/sendgrid/sendgrid-php/Test/Mock
28K ./CoreUtils/core/sendgrid/sendgrid-php/Test/SendGrid
56K ./CoreUtils/core/sendgrid/sendgrid-php/Test
20K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/CharacterReader
8.0K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/CharacterReaderFactory
20K ./CoreUtils/core/sendgrid/sendgrid-php/lib/
36K ./CoreUtils/core/sendgrid/sendgrid-php/lib/
12K ./CoreUtils/core/sendgrid/sendgrid-php/lib/
12K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Plugins/Reporters
8.0K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Plugins/Decorator
12K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Plugins/Loggers
12K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Plugins/Pop
112K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Plugins
20K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/StreamFilters
20K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/CharacterStream
16K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Transport/Esmtp/Auth
32K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Transport/Esmtp
124K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Transport
52K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Mime/Headers
12K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Mime/HeaderEncoder
16K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Mime/ContentEncoder
212K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Mime
68K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Events
24K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift/Encoder
844K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes/Swift
852K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/classes
20K ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift/dependency_maps
896K    ./CoreUtils/core/sendgrid/sendgrid-php/lib/swift
900K    ./CoreUtils/core/sendgrid/sendgrid-php/lib
40K ./CoreUtils/core/sendgrid/sendgrid-php/SendGrid
1008K   ./CoreUtils/core/sendgrid/sendgrid-php
1016K   ./CoreUtils/core/sendgrid
1.6M    ./CoreUtils/core
20K ./CoreUtils/
149M    ./CoreUtils
316M    .



/mnt0# ls -lha /mnt0/mysql

total 109M

drwx------ 8 mysql mysql 4.0K Feb 21 20:31 .
drwxrwxrwx 7 root  root  4.0K Feb 21 20:19 ..
drwx------ 2 mysql mysql 4.0K Feb 12 00:22 Db
-rw-r--r-- 1 root  root     0 Feb 11 19:38 debian-5.5.flag
-rw-rw---- 1 mysql mysql  98M Feb 24 18:12 ibdata1
-rw-rw---- 1 mysql mysql 5.0M Feb 24 18:12 ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M Feb 24 18:12 ib_logfile1
drwx------ 2 mysql root  4.0K Feb 11 19:39 mysql
-rw-rw---- 1 root  root     6 Feb 11 19:39 mysql_upgrade_info
drwx------ 2 mysql mysql 4.0K Feb 11 19:39 performance_schema
drwx------ 2 mysql mysql 4.0K Feb 11 19:45 phpmyadmin
drwx------ 2 mysql root  4.0K Feb 11 19:38 test
drwx------ 2 mysql mysql 4.0K Feb 12 20:39 KavithaDataBase

Are you expecting the database to be huge? 您是否期望数据库庞大? This looks correct and normal, if the database isn't that big the 1.2GB of phantom used space on your other partition could be explained by some non-MySQL process. 这看起来是正确和正常的,如果数据库不是那么大,那么其他分区上的1.2GB幻像已用空间可以通过一些非MySQL进程来解释。

This helpful bit of code I found should show your approximate database size: 发现的这段有用的代码应该显示您大约的数据库大小:

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema ;

I suggest running that from the SQL tab of phpMyAdmin and looking at the results. 我建议从phpMyAdmin的SQL选项卡运行该命令,然后查看结果。 If you add them all together it should be approximately 110MB. 如果将它们全部加在一起,则大约应为110MB。 That way you can approximately tell whether the data is actually in MySQL at this point. 这样一来,您就可以大致判断出该数据实际上是否在MySQL中。

You may be a victim of under-mounting. 您可能是安装不足的受害者。 This is a pretty easy thing to test: 这是一件很容易测试的事情:

# make a temp directory to mount
mkdir /tmp/testmount
# bind-mount the root partition to a new location
mount --bind / /tmp/testmount
# change into that directory. 
# Note: as this is a bind-mount, /mnt0 will NOT be mounted. It SHOULD be empty.
cd /tmp/testmount/mnt0
# see if there are any files where /mnt0 is
du -ah

If you get any files under /tmp/testmount/mnt0, then mysql is somehow starting to access files before /mnt0 is actually mounted. 如果您在/ tmp / testmount / mnt0下获得任何文件,则mysql会以某种方式实际安装/ mnt0 之前开始访问文件。 Files are created in the right spot, just not on the right filesystem. 文件是在正确的位置创建的,只是不在正确的文件系统上创建。 If this is the case, delay mysql start until after /mnt0 is mounted. 如果是这种情况,请延迟mysql启动,直到安装/ mnt0之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM