Recent advances have shown a great potential of anchor based mobile data gathering in wireless sensor networks. In such a scheme, during each periodic data gathering tour, the mobile collector stays at each anchor point for a period of sojourn time and collects data from nearby sensors via multi-hop communications. We provide an optimization based distributed algorithm for such data gathering in this paper. We adopt network utility, which is a properly defined function, to characterize the data gathering performance, and formalize the problem as a network utility maximization problem under the constraint of guaranteed network lifetime. To efficiently solve the problem, we decompose it into two sets of subproblems and solve them in a distributed manner, which facilitates the scalable implementations. Finally, we provide numerical results to demonstrate the convergence of the proposed distributed algorithm.