When I was heavily pregnant with our third baby my husband and I used to take our double mattress from our bed and sleep downstairs every night for 3 weeks. We did this as our second child who is only 16 months older than our youngest wasn't the best sleeper and was still sleeping in our bed and we knew this couldn't carry on once the baby was born as he would be in our room.
So one of us would put our eldest to bed in his own room in his cot bed (he was almost 4) and the other one of us would put our middle child in his cot in our room. It took a good few nights if not more of going in to him and soothing him, lying him back in his cot and us sleeping downstairs on the mattress so as not to disturb him when we went to bed but it worked, after the 3 weeks of doing that we moved him in his cot to his brothers room and he got used to being in his cot instead of in bed with us.
It's just what you do as a parent. My now almost 7 yo and 4 yo have bunk beds in their room and our almost 3 year old sleeps in a toddler bed in our room (two bed house) but sooner rather than later the little one will be moved in the bedroom with his brothers in his own single bed.
Maybe I'm lucky but none of mine climbed out of their cots and none of them get up out of their beds in the night (that's not to say they don't
duck about from time to time, or wake up crying etc because they do) but they stay in their beds unless we get them out. They take after me I guess, I love my bed