MySQL MEMORY Tables

I’ve been doing a bit of learning about MySQL lately at working. I have a horrible memory and writing things down after I learn something has always helped me to remember it.

A memory table can be created in MySQL using the ENGINE table option:

CREATE TABLE t (i INT) ENGINE = MEMORY;

TYPE = HEAP is an older way of specifying the same thing and is still supported for backwards compatibility. Memory tables use hash indexes by default so they’re very fast, and useful for creating temporary tables. When the server shuts down, the tables lose all of their values since they’re stored in memory, but the table definitions aren’t lost since they’re stored in .frm files on disk. These tables will exist when the server restarts but will be empty.

  • These tables can have up to 64 indexes per table, with 16 columns per index and a maximum key length of 3072 bytes.
  • They cannot contain BLOB or TEXT columns.
  • The maximum size of a MEMORY table is dependent on the max_heap_table_size system variable, which is by default 16MB. In order to create MEMORY tables of different sizes this variable’s value must be changed. It’s best to change the session value of this variable instead of the global value, unless you want the value to be changed for all clients.
  • Memory is not reclaimed when individual rows are deleted from MEMORY tables. It’s only reclaimed when the entire table is deleted.
Comments

Microsoft Exchangenge iOS Settings

My company doesn’t officially support adding a Microsoft Exchange email/calendar account to your iOS device unless you install a certain application and certificate. I didn’t want to do this since it enables them to do a lot more than just enable email on my phone.

We have Microsoft Exchange webmail accessible from anywhere so I eventually figured out the correct settings to use from the webmail URL to add a Microsoft Exchange account to my iOS devices that pushes my work email, address book, and calendar.

Once I log in, our webmail URL looks something like this: https://subdomain.domain.com/owa

The settings I used to add the Microsoft Exchange account to my iOS devices were: Server: subdomain.domain.com Domain: domain Username: same username as logging in to webmail (no domain required) Password: same password Use SSL: On

Once I used those settings and clicked Done checkmarks appeared beside each form field and then the account was added. It took maybe 5-10 minutes before I could access my email and calendar (I got a couple error messages during that time). I think it was while emails were being downloaded.

Comments

RP-PPPoE & Pppd - LCP: Timeout Sending Config-Requests

Recently I was installing RP-PPPoE 3.11 on CentOS 5.2 (Linux version 2.6). This will enable us to authenticate users connecting to our network through one of our computers (which I’ll call ‘server’).

Whenever I tried to connect to the server from a client, I would see the following in /var/log/messages on the server:

pppd[22137]: pppd 2.4.4 started by root, uid 0
pppd[22137]: Using interface ppp0
pppd[22137]: Connect: ppp0 <--> /dev/pts/1
pppd[22137]: LCP: timeout sending Config-Requests 
pppd[22137]: Connection terminated.
pppd[22137]: Modem hangup
pppoe[22140]: Timeout waiting for PADO packets
pppd[22137]: Exit.

After doing a ton of digging, I finally read a tip to try disabling the syslog daemon. This tip didn’t include why you would need to do this or what it had to do with RP-PPPoE, but I was running out of options so I gave it a try.

sudo /etc/init.d/syslog stop

I had authentiation and most other options disabled on RP-PPPoE as I was just trying to get the server and client connected, and lo-and-behold, the client connected right away! This was really weird, since what does syslog have to do with RP-PPPoE and why would it stop the connection from working?

I did a bunch of searching, and found the following two posts:

pppd and rp-pppoe LCP timeout issues

Bug 222295 – ppp-2.4.3-6.2.1 conflict with syslog on pppoe-server.

If you look through them, you’ll see it has to do with pppd version 2.4.4, which is the version running (as can be seen in the /var/log/messages log above). You can also test which version of pppd you’re using with pppd --version.

The specific issue has to do with the placement of a closelog() function call in main.c. Here’s the patch that’s included in the second post:

--- ppp-2.4.4/pppd/main.c.orig 2006-06-04 07:52:50.000000000 +0400
+++ ppp-2.4.4/pppd/main.c 2007-11-09 14:47:20.000000000 +0300
@@ -1567,6 +1567,8 @@
if (errfd == 0 || errfd == 1)
errfd = dup(errfd);

+ closelog();
+
/* dup the in, out, err fds to 0, 1, 2 */
if (infd != 0)
dup2(infd, 0);
@@ -1575,7 +1577,6 @@
if (errfd != 2)
dup2(errfd, 2);

- closelog();
if (log_to_fd > 2)
close(log_to_fd);
if (the_channel->close)

As you can see, the patch just relocates the function call a few lines up. What I decided to do was download the latest version of pppd, ensure the patch was already applied, and install it overtop of pppd 2.4.4 already on the system. I downloaded the latest version (2.4.5) from here, inspected main.c to make sure the patch was already applied (which it was), and followed the installation instructions to install it.

Once I had 2.4.5 installed, I confirmed with pppd --version, ran the server and tried connecting with a client. I ended up needing to rebuild 2.4.5 after changing the install path in the configure script because it wasn’t installing to the same directory as 2.4.4 and RP-PPPoE was still using 2.4.4. 2.4.4 was located in /usr/sbin, while the configure script configured 2.4.5 to install to /usr/local/sbin by default. After changing the configure script to install to /usr/sbin, RP-PPPoE used the correct version and the client connected without issue! The logs in /var/log/messages now look like this:

pppd[4075]: pppd 2.4.5 started by root, uid 0
pppd[4075]: Using interface ppp0
pppd[4075]: Connect: ppp0 <--> /dev/pts/1
pppd[4075]: local  IP address 10.0.0.1
pppd[4075]: remote IP address 10.67.15.1

After I got rid of that bug, I started turning features back on (such as authentication), and everything worked.

The two main tutorials I read to actually set up RP-PPPoE were:

Setting-up Basic PPPoE Server in Linux (x86_64 Platform)

PPPoE Server – How To Do It Yourself

Comments

VirtualBox Shared Folders

Last night I was trying to get shared folders working using VirtualBox. I have the host as Ubuntu 12.04 and a guest using Ubuntu 11.04. For the life of me I couldn’t get them to work. I followed the instructions on installing the Linux Guest Additions from VirtualBox’s site and set up shared folders the same way many tutorials/blogs suggested, but every time I went to mount the shared folder I would get this error:

/sbin/mount.vboxsf: mounting failed with the error: No such Device

I finally found a post explaining that the issue was the installation of modules while installing the Guest Additions. VirtualBox’s website instructs to install just dkms before running the Guest Additions script, but this was incorrect. One indication that this is the issue is to run ls mod | grep vbox. You shouldn’t see vboxsf.

In order to build the modules necessary for shared folders, the following three packages need to be installed before running the Guest Additions installation script:

sudo apt-get install dkms build-essential linux-headers-generic      

After that, I re-ran the Guest Additions script by connecting the VBoxGuestAdditions.iso as a storage device (using phpvirtualbox), mounting the device at /dev/scd0, and running the script:

sudo mount /dev/scd0 /media/cdrom
cd /media/cdrom
./VBoxLinuxAdditions.run

Once that had completed, I restarted and ran ls mod | grep vbox. You should see see vboxsf.

One that’s done, you should be able to mount your shared folders, like so:

mount -t vboxsf -o uid=1000,gid=1000 d /media/sf_d

I put one of those commands for each of my shared folders in /etc/rc.local. Make sure you create the sf_d folder in /media before trying to mount it there, and change uid and gid to the user you want the mount to be mounted under.

Comments

Steve Jobs

One year ago today, Steve Jobs resigned as CEO of Apple.

One of my favourite keynotes to watch is the original introduction of the iPhone. Right around the 29 minute mark gives me chills. You can download it on iTunes and I think you should, even if you don’t want to watch it right away. It’s an iconic event and it would be a shame to not have it if it’s ever taken off of iTunes.

Download it here.

His keynotes were special. I’ll miss them.

Comments

Interview Questions

You should know the answer to all of these questions before going into an interview. They aren’t difficult questions, but knowing the answers beforehand will certainly reduce stress while you’re in the interview trying to come up with an answer.

  1. Why do you want to work for us?
  2. How do you think you could contribute to our company?
  3. What kind of work do you like best?
  4. Do you work well with others?
  5. What are your hobbies?
  6. What would you like to do when you graduate?
  7. Are you good at taking direction?
  8. Are you good at giving direction?
  9. Are you good at multitasking, or do you prefer to focus on one thing?
  10. Do you like to be busy?
  11. What would you like to learn if you worked for us?
  12. What do you do in your spare time?
  13. What would you do if you disagreed with your boss?
  14. What would you do if you had a conflict with a co-worker?
  15. Are you comfortable talking about your ideas?
  16. Are you comfortable talking in front of a group?
Comments