Assume that SwitchA and SwitchB set up a stack, and you want SwitchA to be the master switch. If stack cables have been connected, complete stack configuration on SwitchA first and restart SwitchA. After SwitchA restarts, complete stack configuration on SwitchB and restart SwitchB. After SwitchB restarts, it joins the stack and becomes the standby switch. SwitchA functions as the master switch in the stack.
If you complete stack configuration on the two switches before connecting stack cables, the two single-chassis stacks merge into one stack after they are connected. Set a higher stack priority for SwitchA and a lower stack priority for SwitchB, so that SwitchA becomes the master switch after the stacks merge.