The Catalan giants were always in control and, despite offering the hosts a few too many chances, cruised to victory with goals from the Brazilian and the 18-year-old forward
Dani Alves got the Catalans off to a cracking start as he rifled an effort into the roof of the net after just five minutes but Tolgay Arslan drew the hosts level midway through the first half.
Barca regained the lead before half time with a goal from Gerard Deulofeu and they saw out the win by retaining possession through the second period.
Argentine superstar Lionel Messi was ruled out of the game beforehand having suffered muscular bruising to his right calf in training, reportedly saving the hosts €400,000 in appearance fees for the match that was set to celebrate their 125th anniversary.
Barcelona were positive from the off with Alexis proving to be a popular outlet on the right. In the fifth minute Dennis Aogo failed to clear a corner and the Chilean picked up the ball at the back post. He then rolled it back to Alves who steamed in and belted an unstoppable shot past Rene Adler.
However, the visitors soon became complacent and allowed the Bundesliga side a route back into the game. Son Heung-Min saw an effort saved by Jose Pinto in the 21st minute but Hamburg restored parity moments later.
Arslan won the ball back in the Barcelona half before breaking forward and sliding it across the box to Marcus Berg. His stabbed attempt rattled the bar but the rebound fell kindly for Tolgay, who squeezed the ball into the back of the net.
Alexis continued to be a thorn in HSV's side and was thwarted soon after by another terrific save from Rene Adler but the former Germany international was eventually beaten seven minutes before the break.
After parrying Afellay's powerful shot away from goal, getting across to save Deulofeu's follow-up proved too big of an ask for Adler as the 18-year-old's shot crept over the line.
Vilanova made nine substitutions at half time with Marc Muniesa and Rafinha coming on while Thorsten Fink replaced seven of his players.
The wholesale changes stifled the game somewhat but Artjoms Rudnevs looked lively in the early stages of the second half and should really have hit the target from Muhamed Besic's cross in the 59th minute.
Muniesa had been taken off the field after picking up an injury moments before and with him unable to continue, Marc Bartra returned to the field after being substituted at half time so that the Catalan club did not have to continue with 10 men.
Hamburg could get nowhere near the ball and in the 73rd minute they almost fell two goals behind. A long ball up to the top from the Blaugrana was not dealt with by Adler but Cristian Lobato failed to tuck the ball away, lofting his volley well over the bar of an open goal.
Barcelona will face Raja Club Athletic in their next friendly fixture on Saturday June 28.