I believe it should work by getting a Mini DisplayPort cable going from the 2009 to the 27" (into its Thunderbolt jack, which supports Mini DisplayPort cables).
I just did something like what you did recently. Well, I have a 27" Late 2009 iMac running High Sierra and a 21.5" Late 2012 iMac running Mojave.
There are only a few specific models of older Macs that will support that's called Target Display Mode, which is what I've ustilized here: I got a Mini DisplayPort cable online (3' is all I needed for just over $7 shipped and it came in white!), plugged one end into one of the 2012's two Thunderbolt jacks and the other end into the 2009's lone Mini DisplayPort jack. The second I did that, the display from the 21.5" immediately extended to the 27". Audio came with it, too. In most cases, the keyboard command for target display mode is CMD + F2.
From there, I went into System Preferences > Display > Arrangement tab> then click-and-drag arrange your monitors as you want to use them. Tip: See the little thin white bar along the top of one of them? That's your PRIMARY monitor (often your source monitor). Click and drag just THAT little white bar and move it over to the other monitor if you want all of your default notifications and etc to show up there.
Read up on this. Great guide: https://support.apple.com/en-us/HT204592