Change the Location of the unix_socket_directory Parameter

The unix_socket_directories system parameter is a configuration parameter specifying the file system directories for the PostgreSQL server to store its Unix domain sockets

YugabyteDB also uses this parameter.

The default value for unix_socket_directories is /tmp.

Example:

				
					[root@localhost ~]# alias y
alias y='ysqlsh -h yugabytedb.tech -U yugabyte'

[root@localhost ~]# y -c "SHOW unix_socket_directories;"
    unix_socket_directories
-------------------------------
 /tmp/.yb.yugabytedb.tech:5433
(1 row)
				
			

In PostgreSQL we can change the default value of unix_socket_directories by editing the postgresql.conf file then restarting PostgresSQL.

That doesn’t work with YugabyteDB.

But starting in YB 2.19.0, we can alter the default value of unix_socket_directories via the tmp_dir T-Server gFlag!

Example:

				
					[root@localhost ~]# y -c "SELECT substring(version() from 'YB-([^\s]+)') AS \"YugabyteDB Version\";"
 YugabyteDB Version
--------------------
 2.19.2.0-b0
(1 row)

[root@localhost ~]# y -c "SHOW unix_socket_directories;"
    unix_socket_directories
-------------------------------
 /tmp/.yb.yugabytedb.tech:5433
(1 row)

[root@localhost ~]# curl -s http://yugabytedb.tech:9000/varz?raw | grep "\-\-tmp_dir"
--tmp_dir=/tmp

[root@localhost ~]# yugabyted stop --base_dir=/root/yb-cluster/node1
Stopped yugabyted using config /root/yb-cluster/node1/conf/yugabyted.conf.

[root@localhost ~]# mkdir /root/jim/tmp2

[root@localhost ~]# yugabyted start --advertise_address=yugabytedb.tech --base_dir=/root/yb-cluster/node1 --tserver_flags="tmp_dir=/root/jim/tmp" > start.log

[root@localhost ~]# curl -s http://yugabytedb.tech:9000/varz?raw | grep "\-\-tmp_dir"
--tmp_dir=/root/jim/tmp

[root@localhost ~]# y -c "SHOW unix_socket_directories;"
        unix_socket_directories
----------------------------------------
 /root/jim/tmp/.yb.yugabytedb.tech:5433
(1 row)
				
			

In the above example, we changed the default value of unix_socket_directories from /tmp to /root/jim/tmpMake sure that the new directory exists and is writable by the YugabyteDB process before setting the gFlag.

Also, note the use of the curl command to display the current value of the tmp_dir T-Server gFlag. We covered that previously in the Quickly View GFlags Values From The Command Line tip.

Oh, one more thing. I used yugabyted for the example. It’s a great tool for quickly testing these sort of things!

Have Fun!

Saw these crazy climbers at Yosemite National Park!