Set up MySQL server using a Mac Mini Server with Lion and a Promise Pegasus R6

Recently, I set up a Mac Mini server (with Mac OS X Lion) and a Promise Pegasus R6 Thunderbolt disk array as a mysql server for a client of mine. I had to learn few things in the process and I thought I would share the details for those who may need them in the future.

Setting up the server was fairly simple. It’s a Mac, few questions answered and the server is set up.

However, when I started with the Pegasus, I hit few snags.

During the server set up I had chosen as host name ‘db1.example.com’ (of course ‘example’ should be replaced with the actual domain to be used). It seems that this tripped the Promise software. Whenever I launched the software to change the RAID type, it simply crashed with an error. Looking at the error log, I found that it’s trying to launch a web server and it’s failing to resolve the domain name.

The solution was simple. Add the machine to its own hosts file. A quick command in the terminal solved the issue:

echo “127.0.0.1 db1.example.com” >> /etc/hosts

Please note the double ‘>>’, not a single one.

After that, I was able to launch the Promise utility without issues.

I selected the pre-setup disk array (RAID Level 5) and deleted it. I created a new RAID level 5 array with 4 drives + 1 parity + spare drive. This gives the client maximum safety using one array while maintaining blazing speed. At 8 TB of usable space on the array, it was more than enough for a while.

Note that it’s best if you use a drive name that is one word and all lower case letters. Just to make the examples simpler, let’s call our array bigarray.

With that done, it was time to install MySQL and set it up to use the RAID as the location for the data directory.

I downloaded MySQL binaries in a .dmg file from its site and simply used the package to install MySQL and the pref pane and the startup item.

To change the data directory that MySQL from the default to the Thunderbolt Array, you need to change few things.

1: Launch MySQL server by clicking the ‘start mysql’ button in the pref pane in the system preferences.

2: Set MySQL root password.
In the terminal type:

/usr/local/mysql/bin/mysqladmin -u root password “rootpassword”
(‘rootpassword’ to be replaced with a real password)

3: Stop MySQL using the pref pane.

4: Create the folder on the array. It’s best if you don’t use any capitals in its name. For example “mysqldata”.

5: copy the ‘mysql’ folder from the default data directory to the new folder.
In the terminal type:

sudo cp /usr/local/mysql/data/mysql /Volumes/bigarray/mysqldata/

6: copy the ‘performance_schema’ folder from the default data directory to the new folder also.
In the terminal type:

sudo cp /usr/local/mysql/data/performance_schema /Volumes/bigarray/mysqldata/

7: Change the ownership of this new data folder to mysql.
In the terminal type:

sudo chown -R _mysql:_mysql /Volumes/bigarray/mysqldata

Now we need to change MySQL’s configuration to point to the new location:

In the terminal:

sudo cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf

Now we need to change the file. Use your terminal text editor of choice to open my.cnf and below the line ‘thread_concurrency = 8’ type:

datadir = /Volumes/bigarray/mysqldata

Save the file.

Now you can start the MySQL server with the pref pane and it should work with the new directory. Those Thunderbolt arrays are crazy fast.