When running gpinitsystem, you can get the following error:
20200323:13:54:21:gpcreateseg.sh:cppplgpms3b01a:gpadmin-[FATAL]:-Failed to insert port=6001 in /data02/primary/gpseg7/postgresql.conf on cppplgpss3b004 Script Exiting! 20200323:13:54:21:gpcreateseg.sh:cppplgpms3b01a:gpadmin-[FATAL]:-Failed to insert port=6000 in /data01/primary/gpseg6/postgresql.conf on cppplgpss3b004 Script Exiting!
This causes gpinitsystem to hang and causes you to terminate the process which causes it to fail.
When looking at the debug log and tracing the code, we can see that it fails at this step:
$TRUSTED_SHELL $SED_HOST sed -i'.bak1' -f /dev/stdin "$FILENAME" <<< "$SED_COMMAND" > /dev/null 2>&1 if [ $RETVAL -ne 0 ]; then ERROR_EXIT "[FATAL]:-Failed to insert $SUB_TXT in $FILENAME on $SED_HOST"
When trying to run the actual statement on the command line, it fails with a permission error on /dev/null.
ssh sdw1 sed -i'.bak1' -f /dev/stdin "/data01/primary/gpseg1/postgresql.conf" <<< s'/port.*/port=6000/g' > /dev/null 2 >&1 sed: couldn't open file /dev/stdin: Permission denied
Note: Running it on the master without the ssh portion is successful since it doesn't involve ssh.
Since it works on the master, this issue is strictly due to a setting in /etc/ssh/sshd_config:
UsePrivilegeSeparation no
Please check to see if this is set to no. If so, then it needs to be changed to "sandbox" or "yes", otherwise ssh would be unable to access shared memory due to privilege issue.
Red Hat also has the following warning:
If setting up an SSH server, do not turn off the Privilege Separation feature by using the UsePrivilegeSeparation no directive in the /etc/ssh/sshd_config file. Turning off Privilege Separation disables many security features and exposes the server to potential security vulnerabilities and targeted attacks. For more information about UsePrivilegeSeparation, see the sshd_config(5) manual page or the What is the significance of UsePrivilegeSeparation directive in /etc/ssh/sshd_config file and how to test it ? Red Hat knowledge base article.
After setting UsePrivilegeSeparation to the proper value, restart sshd service to apply the changes.
To re-run gpinitsystem, you can delete the master directory and all the segment directories.
For additional information, refer to the following Red Hat documentation: System Administrator’s Guide Red Hat Enterprise Linux 7 | Red Hat Customer Portal