11/09/2016

[ MySQL ] How to grab database and table size.




1. Grab all database size.

SELECT table_schema, SUM(data_length + index_length)/1024/1024 AS total_mb, SUM(data_length)/1024/1024 AS data_mb, SUM(index_length)/1024/1024 AS index_mb, COUNT(*) AS tables, CURDATE() AS today FROM information_schema.tables GROUP BY table_schema ORDER BY 2 DESC;


2. Grab all table size.

SELECT table_schema, table_name, (data_length + index_length)/1024/1024 AS total_mb, (data_length)/1024/1024 AS data_mb, (index_length)/1024/1024 AS index_mb, CURDATE() AS today FROM information_schema.tables ORDER BY 3 DESC;

9/20/2016

ERROR: Cannot add watch /Dir (28:No space left on device)

Today I got the lsyncd problem and found the following error in /var/log/lsyncd.
 ===
Wed Sep 21 03:48:24 2016: ERROR: Cannot add watch /Dir_name/file_name (28:No space left on device)
 ===
I googled the error message and found the solution. The max_user_watches reached its limit. I need to increase the value of max_user_watches. 

At first, checked the current value.
 [root@host ~]# cat /proc/sys/fs/inotify/max_user_watches
 32768


To increase the max_user_watches, I edited the /etc/sysctl.cnf.
 [root@host ~]# vi /etc/sysctl.confadded the folowing line.
 fs.inotify.max_user_watches = 500000

To take a effect, I did the following command.
[root@host ~]# sysctl -p


That's it!

Temporary solution
  echo 65536 >/proc/sys/fs/inotify/max_user_watches

 [root@host ~]# cat /proc/sys/fs/inotify/max_user_watches
 65536


Finally I got around the error. :) 

5/06/2016

How to configure your s3 bucket public.


To set the all files in bucket public, add the bucket policy to your s3 bucket.
1. Go to https://awspolicygen.s3.amazonaws.com/policygen.html
2.  Set the following parameters.
          Select Type of Policy with "S3 bucket policy".
          Effect: Allow
          Principal:   *
          AWS Service: S3
          Actions:  GetObject
          Amazon Resource Name (ARN):    arn:aws:s3:::bucket-name/*

 3. Then, click 'Add Statement'
 4.  Click the 'Generate Policy' button. You'll get the following information like below.

{
  "Id": "Policy1462558474573",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1462581569846",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::bucket-name/*",
      "Principal": "*"
    }
  ]
}
5. Add above information in your s3 bucket policy.
That's it!