It appears in Mark Twain's 1885 novel, "The Adventures of Huckleberry Finn." It's set around the 1850s, and Mark Twain makes a point saying he's rendered all the dialog accurately, so we can assume it was used in the 1850s.
'He stirred up in a kind of a startlish way; but when he see it was only me he took a good gap and stretch, and then he says:
"Hello, what's up? Don't cry, bub. What's the trouble?"'