1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How can i make MySQL to save its items into certain folder / partition?

Discussion in 'Site & Server Administration' started by postcd, Jul 28, 2016.

  1. #1
    Hello,

    i think that MySQL is creating some temporary tables on the HDD and some in RAM. I would like to use ramdisk /dev/shm to hold temporary disk tables. How can i tell MySQL to save temporary data there? And is it safe if there is a power outage, it is temporary tale so it should not be big problem if its lost? Is there any tutorial on how to achieve this?

    Thx
     
    postcd, Jul 28, 2016 IP
  2. Andrey Stroganov

    Andrey Stroganov Peon

    Messages:
    7
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    3
    #2
    If you mean temporary tables, you can make ramdisk something like:
    mkdir -p /var/mysqltmp
    chown mysql:mysql /var/mysqltmp
    mount -t tmpfs -o size=2g tmpfs /var/mysqltmp
    don't forget to add it to fstab
    tmpfs /var/mysqltmp tmpfs nodev,nosuid,noexec,nodiratime,size=2g 0 0

    and add it to mysql:
    nano /etc/my.cnf
    tmpdir = /var/mysqltmp

    service mysql restart
     
    Andrey Stroganov, Jul 29, 2016 IP
    postcd likes this.
  3. postcd

    postcd Well-Known Member

    Messages:
    1,037
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    190
    #3
    Thx i think it works. The folder is empty when i check it, but its modiffication times changing and it is locked by mysql process. (lsof /tmp/mysqltmp)
    I set 6GB size and location in /tmp, not sure what should be proper size and what happen if size is too small for MySQL.
    PS: iotop -ao command shows mysql processes generating IO, hopefully this is related to that ram based partition not to real HDD.
     
    postcd, Jul 29, 2016 IP