Skip to main content

Posts

Showing posts from February, 2016

LUKS Disk encryption for CentOS 6.6/RHEL 6

Linux Unified Key Setup-on-disk-format (or LUKS) allows you to encrypt partitions on your Linux computer. This is particularly important when it comes to mobile computers and removable media. LUKS allows multiple user keys to decrypt a master key, which is used for the bulk encryption of the partition. What LUKS does ? from redhat site . LUKS encrypts entire block devices and is therefore well-suited for protecting the contents of mobile devices such as removable storage media or laptop disk drives. The underlying contents of the encrypted block device are arbitrary. This makes it useful for encrypting swap devices. This can also be useful with certain databases that use specially formatted block devices for data storage. LUKS uses the existing device mapper kernel subsystem. LUKS provides passphrase strengthening which protects against dictionary attacks. LUKS devices contain multiple key slots, allowing users to add backup keys or passphrases. What LUKS does not do: fro...

Mysql Database Moving Data Directory to New Location.

How to move an existing data directory in mysql to a new location. We were running out of space and had to move the existing data directory to a new drive. Below are the steps to move the data directory to new location. Stop mysql using the following command: sudo service mysqld stop Copy the existing data directory (default located in /var/lib/mysql ) using the following command: sudo mkdir /db sudo cp -R -p /var/lib/mysql /db Update the mysql configuration file with new path /db/mysql the following command: sudo vim /etc/my.cnf Here is how the configuration looks like. [ahmed@localhost mysql]$ cat /etc/my.cnf [mysqld] datadir=/db/mysql socket=/db/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [ahmed@localhost mysql]$ Look for the entry for datadir, and change the path (which should be /var/lib/mysql ) to ...

Mysql Database Disk Usage.

We were running out of disk space on one of the databases server, we need to get information on what the current table/database usage was. Below are few commands for mysql server tables usages. To get details of table. show table status from zabbix; You can use this query to show the size of a table (although you need to substitute the variables first): SELECT table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES WHERE table_schema = "$DB_NAME" AND table_name = "$TABLE_NAME"; Here is the output: mysql> SELECT -> table_name AS `Table`, -> round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` -> FROM information_schema.TABLES -> WHERE table_schema = "zabbix" -> AND table_name = "history"; +---------+------------+ | Table | Size in MB | +---------+------------+ | history | 0.03 |...