I told you that would happen...

Installing MySQL 5.6 from rpm

Oracle has broken various aspects of installation of MySQL 5.6 via RPM.
See, among others, http://bugs.mysql.com/bug.php?id=72724

If you want to install with a non-default data directory (/db_data/mysql in this example), here are some steps you need to take:

1. set up your /etc/my.cnf with datadir setting, etc
2. install the RPM (yum install MySQL-server)
3. rm /usr/my.cnf (WTF???)
4. mv /var/lib/mysql/* /db_data/mysql/ (installer generally obeys datadir, but 'mysql_install_db' does not)
5. start mysql (service mysql start)
6. clear root password or set it to something else:
TEMPPW=$(foo=`cat /root/.mysql_secret`; echo ${foo##* });
mysql --connect-expired-password -p$TEMPPW -e "SET PASSWORD = '';"

continue as normal.

mysql grant subqueries

MySQL doesn't allow subqueries inside GRANT statements (only inside SELECT, INSERT, UPDATE, DELETE, SET, or DO). Here's a workaround using bash, when you want to grant based on a wildcard pattern in the schema name:

mysql -e "grant select on $(mysql -N -e "select distinct table_schema from information_schema.tables where table_schema like 'foo%';").* to user@host;"

Flowchart of InnoDB writes (logs, buffers)

I whipped this up originally to aid in explaining how Xtrabackup works, but I find useful for explaining replication as well. Feel free to complain at me if you find any inaccuracies or omissions :)

(edit: sorry I can't immediately figure out how to make the Drupal theme wider, and I'm too lazy to resize the image. Click on it for a full view.)

activate serial console on CentOS 6 (or RedHat EL 6)

How to activate the serial console in CentOS 6. Useful for logging into a virtual guest via 'virsh console'.

/etc/init/ttyS0.conf:

# ttyS0 - agetty

stop on runlevel [016]
start on runlevel [345]

instance ttyS0
respawn
pre-start exec /sbin/securetty ttyS0
exec /sbin/agetty /dev/ttyS0 115200 vt100-nav

then run
start ttyS0

MySQL: count tables by Schema and Storage Engine

select table_schema, engine, count(*) from information_schema.tables where table_schema not in ('mysql', 'information_schema', 'test') group by table_schema, engine;

+--------------+--------+----------+
| table_schema | engine | count(*) |
+--------------+--------+----------+
| gallery2     | InnoDB |       56 | 
| gallery2     | MyISAM |        2 | 
| foo          | NULL   |        1 | 
| foo          | InnoDB |        3 | 
| foo          | MyISAM |        1 | 
+--------------+--------+----------+

Installing CentOS 6 or RedHat EL 6 on a partition larger than 2.2T

CentOS/Redhat 6 support installing and booting using GPT partitions, which can be larger than 2 TB. Your BIOS must also support UEFI booting. For a new install on an unpartitioned drive, wait for Anaconda (the graphical installer) to start, then press ctrl+alt+F2 to get a shell prompt. Create a new partition table on the blank drive:

parted /dev/sda
> mklabel gpt
> quit

Press ctrl+alt+F6 to return to the installer, Anaconda should recognize the drive at its full size and let you partition as normal. Make sure you don't choose the option to wipe the entire drive, or you'll get an old DOS partition table. That's it!

rsync over ssh via an intermediate proxy host

rsync -av -e 'ssh -o "ProxyCommand ssh user@proxyhost exec nc %h %p 2>/dev/null"' /var/lib/mysql/* user@host:/var/lib/mysql/

MySQL hot backup, streamed via SSH

innobackupex --stream=tar ./ | ssh user@host "(cd /var/lib/mysql && tar -xif -)"

installing Glassfish on CentOS

Assuming Java is already installed and JAVA_HOME is set

cd /opt
wget http://download.java.net/glassfish/3.1/release/glassfish-3.1.zip
unzip -q glassfish-3.1.zip
groupadd glassfish
useradd -s /bin/bash -g glassfish glassfish
chown -R glassfish:glassfish /opt/glassfish3/

/etc/init.d/glassfish:

#! /bin/bash
#
# glassfish Start/Stop the glassfish application server
#
# chkconfig: 345 80 20
# description: GlassFish is an open source application server project \
#              led by Sun Microsystems for the Java EE platform
#

BASH trick: exit codes for piped commands via $PIPESTATUS

Tagged:

Here's an example pipe:

$ true | false | true | false

$? will return 1 because that is the exit code of the last command in the pipe (false)

If you need to access the exit code of previous commands in the pipe, use the BASH built-in array $PIPESTATUS. For example, to get the exit code of the first command ("true" in this example), use

${PIPESTATUS[0]}

And so on.

$ true | false | true | false
$ echo ${PIPESTATUS[*]}
0 1 0 1

To save $PIPESTATUS in another variable:

$ true | false | true | false
$ foo=( ${PIPESTATUS[*]} )
$ echo ${foo[*]}
0 1 0 1
Syndicate content