North Carolina was the state in which Mayberry was located, and thus served as the primary state of interest for The Andy Griffith Show, Mayberry R.F.D. and, briefly, Gomer Pyle U.S.M.C., before Gomer's unit shipped out to California.
Various points of state and local law were explored on The Andy Griffith Show during the course of Andy Taylor's job as sheriff. Likewise a number of state and county locations were named, thoiugh—like Mayberry itself—many were fictional.
However, Raleigh was frequently mentioned as not just the capital of the state, but as a vacation destination for Barney Fife. Eventually, Fife moved to Raleigh permanently, taking up a low-level position in state law enforcement. Andy also made a few trips to Raleigh over the years—occasionally, as in "Goodbye, Sheriff Taylor", to explore his own vocational future. In the seventh season episode, "A Visit to Barney Fife", Raleigh was actually depicted when Andy goes to visit Barney there.
Other real world cities in the state, like Asheville, Greensboro and Charlotte were very occasionally mentioned, but fictionalized versions of real towns like Mount Pilot and Siler City sometimes made it on screen. For instance, the sseason 5 episode, "Andy and Helen Have Their Day", shows Andy up in front of a magistrate in Siler City's jurisdiction for a fishing license violation.