Skip to main content

MySQL is running out of memory in DigitalOcean

Hey, after update from MySQL 5.5 to 5.6, my life is getting worse. There are many 'Database connection error' when I try to open my website. And I even can not access to phpMyAdmin. What's happening.
OK, I turn on the SSH, connect to my server and BOOM, mysql is having 'Out of Memory' error, and everything crash.
That time, I need to restart mySQL:
$> sudo service mysql start

Next, I need to find out how much memory is being used, because Digital Ocean does not support this feature.
$> sudo apt-get install htop
$> htop
Now there is my memory usage:

Wow, mysqld service is consuming 48.9% memory, what!!!

There are 2 things I can do: Upgrade RAM (means upgrade Dropplet) or continue to check for another solution, my VPS is 1GB RAM.

Next, I check the log of mysql at /var/log/mysql: 
There are alot of errors:



There are some problems that we can find out:
+ InnoDB can not allocate memory 
+ InnoDB memory heap is disabled

Let's check the swap by this command:
$> free -m 


Swap = 0 means there is no swap setup. 

---> I need to setup the swap File by following steps:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

There might be some errors when you try command in above pages, like:
sysctl: cannot stat /proc/sys/50: No such file or directory

What you need to do is to:
+  move to the /proc/sys/vm folder: $> cd /proc/sys/vm
Then type again

Now my system start using swap file and no out of memory error. However I always recommend you to upgrade RAM if possible because using swap file will degrade your performance.


Comments

Popular posts from this blog

Setup splunk for virtual machine using Vagrant and Ansible

Splunk is a great tool for collecting and indexing data in any kind(log files, changes, tickets, scripts…) from any sources (sensors, networks, databases, smartphones,..( Then creating index for data which then support us to analyse data or search data in the way we like it. We want to try installing Splunk on Virtual environment in order to test, try, study… And with Vagrant&Ansible we can easily save our virtual machine configuration for next time use(in case my virtual machine was broken). There is already Splunkbox by Phips on githubs for simply installing:  https://github.com/phips/splunkbox 1.Download and install Virtual Box (You need a Virtual machine provider for Vagrant(Virtualbox is prefered)) https://www.virtualbox.org/wiki/Downloads 2. Download and install Vagrant   http://www.vagrantup.com/downloads 3. Download and install Ansible   http://docs.ansible.com/intro_installation.html   For MAC:  https://devopsu.com/guides/ansible-mac-osx.html

Launch android application within Unity app.

In Unity android application(called application A), you want to launch other android app(application B). I had tried to follow some entries and try :  List<ApplicationInfo> packages =  getPackageManager() .getInstalledApplications(PackageManager. GET_META_DATA ); for  (ApplicationInfo packageInfo : packages) { if (packageNameToOpen.equals(packageInfo. packageName )){ try { Intent intent =  new  Intent(); intent.putExtra(key, value); intent.setComponent( new  ComponentName(packageName,activityName)); UnityPlayer. currentActivity .startActivity(intent); } catch (Exception e){ } Android manages its items in "tasks" and "activity stack". If you normally call new activity as above, the activity of other app would be put in to same task of the current applications, which means you are not openning new application. You can see an example of opening mail client, the mail client allow you to call mail activity and it is put in to your curren

Install Ruby on Rails on MAC

Hello, I am quite familliar with Apache's friend products like XAMPP, LAMPP... And this is the first time I try Ruby on Rails(RoR). I'm quite stuck on installing it. As a normal PHP guy, I first try install Rails, following this tutorial: http://installrails.com/ And the next thing I want to learn about is how RoR works with MySQL, PhpMyadmin. So I tried to make it connect to XAMPP's MySQL but it did not work at all. I found out that, using mySQL in XAMPP package is not a common method, what I should do is to install MySQL as a single service onto my MAC. So I did following: 1. Install MYSQL with HomeBrew Did you install HomeBrew, if not, please follow:  https://coolestguidesontheplanet.com/installing-homebrew-on-os-x-el-capitan-10-11-package-manager-for-unix-apps/ Next, type this command to install MySQL to your machine: $ brew install mysql This will install mysql to your computer, if the installation is success, you could try start using mySQL with this c