No, you do not need to replace all cylinders if only the number 2 cylinder is misfiring. A misfire in one cylinder is usually caused by a problem with that cylinder's spark plug, ignition coil, or fuel injector. Replacing the affected component will usually resolve the misfire.
If you are experiencing a misfire in multiple cylinders, it is possible that there is a more serious problem with the engine, such as a vacuum leak or a faulty ignition module. In this case, it would be best to take your vehicle to a mechanic for diagnosis and repair.