A magnitude 4.9 earthquake centered on the western side of Cook Inlet shook Southcentral Alaska communities early Saturday.