There are two main reasons for this error to happen
1. It could be that the spadmin group does not have write permissions to either data subdirectory under the vardir.
To resolve this, do chmod 775 on the data subdirectory before re-running ora_setup.
2. If it still fails, the issue could be a missing entry for the hostname in /etc/hosts file. To confirm this, launch sp_cop as spadmin user even though the ora_setup failed. This is supposed to bring up sp_cop without any associated processes like Capture, Read, Export or Post. If the launching of sp_cop fails with the following error:
./sp_cop -u21001 &
BTS-CFG-DB:cfgbtsdb1:oracle > gethostbyname(cfgbts) failed Parameter database initialization failed - exiting
If this is the case the problem has to do with missing entry for the host in /etc/hosts file. After adding the entry, you should be able to run ora_setup and then launch sp_cop.