Is it mandatory to have a passport validity for 5 years to get a?
No, but it is in your interests to have as much validity in your passport as possible. Any visa and permit issued to you will only be valid as long as your passport. If these all expire mid-term, you will have to renew your passport at your Embassy, then apply for an extension of your permit. The visa, which allows you to travel to Canada, can only be renewed abroad. This is not a problem if you do not leave Canada for the duration of your studies, but can really mess up a visit home.