How To Install Socat On Redhat Linux
At that place are several ways to perform remote-to-remote data re-create - socat, netcat, rsync, scp, sftp. ClusterControl was using netcat for remote copy purposes, however we have flipped that decision to employ socat. This web log post describes the reasons behind it.
A Brief History
ClusterControl introduced back up for streaming backup back since v1.2.ix using netcat, replacing the older fill-in-and-copy method using secure copy (scp). Streaming backup is a much amend option considering it doesn't consume disk space on the backup node and streaming happens on-the-wing, consuming only the disk space of the remote destination where the backup files are to be stored. Secure copy, on the other hand, requires setting upwards proper SSH keys and encryption adds operation overhead to the transfer procedure. This is unnecessary if you already have an isolated network for the database servers (encryption is as well possible with socat or ncat).
Netcat is a better way of streaming files over the network due to its lightweight procedure, simpler implementation and speed if compared to rsync, scp or sftp. By default, ClusterControl uses port 9999 for this purpose, which is configurable via ClusterControl -> Backup page if the Storage Location dropdown is "Store on Controller":
Introduction to netcat/socat
Netcat (also known equally nc) is a estimator networking utility for reading from and writing to network connections using TCP or UDP. It is quite elementary to build a very basic client/server model using nc. On ane console, start nc listening on a specific port for a connection. For case:
$ nc -fifty 1234
Netcat is now listening on port 1234 for a connection. On a 2d panel (or a second auto), connect to the machine and port existence listened on:
$ nc 127.0.0.1 1234
There should at present be a connectedness between the ports. Anything typed in the second console will be concatenated to the first, and vice-versa. After the connection has been gear up upwardly, nc does not really care which side is being used as a server and which side is being used as a customer. The connection may be terminated using an EOF ('^D').
There are currently three near popular versions of netcat for RHEL based operating system:
- netcat (too known as nc) - The original project. Default in CentOS/RHEL 6.
- nmap-ncat (also known equally ncat) - A amend version of netcat adult and maintained by the nmap project. It has support for multiple protocols, simultaneous connections and SSL. Default in CentOS/RHEL vii.
- socat - Also a improve version of netcat like to nmap-ncat. Available in EPEL for CentOS/RHEL.
In that location are likewise a rewritten version of GNU'south and OpenBSD's version which support boosted features. For example, OpenBSD's netcat supports TLS.
Netcat Effect on CentOS/RHEL
To create a backup on a database node and store it remotely using netcat, ClusterControl triggers the backup control on the target database node and streams the output by initiating two endpoints on source and destination hosts:
$ nc -dl 9999 # on destination (the storage node) $ {backup command} | nc 192.168.100.10 9999 # on source (the fill-in node)
Notwithstanding, the program "nc" in CentOS/RHEL 7 is an alias of nmap-ncat, which is a different version of the original netcat:
$ ls -fifty /usr/bin/nc lrwxrwxrwx one root root four Feb thirteen 2022 /usr/bin/nc -> ncat
On CentOS/Blood-red Chapeau half-dozen, "nc" is the original netcat projection. Both are practically like, however the control line options are not compatible between each other. Consider the following command to start the listening host for standard netcat:
$ nc -dl 9999
If the netcat version is the nmap-ncat version, which is the default installed on CentOS/RHEL 7, you lot would meet the following error instead:
Ncat: Invalid -d delay "l" (must be greater than 0). QUITTING.
The -d in nmap-ncat is a delay flag option, which in netcat means detach from stdin. Depending on the options used, this could potentially break the communication between nodes if they are running on dissimilar CentOS/RHEL version. Ane solution is to detect the installed netcat version, whether information technology'due south nmap-ncat or netcat and execute the correct listening control. However, ClusterControl prefers to use socat instead, as described in the side by side department.
Workaround
ClusterControl automatically favors socat if it is installed. Despite non being role of the standard Os package repository, you tin have it installed via EPEL repository or manual installation from Socat official page. Socat is also a dependency packet for Percona XtraDB Cluster which yous can verify by using the following command:
$ yum deplist Percona-XtraDB-Cluster-server-57 ... dependency: socat ...
Starting from ClusterControl v1.iv.2, all database deployments performed by ClusterControl will take socat installed. ClusterControl volition start socat to listen on the destination backup host with the post-obit command:
$ socat -u tcp-listen:9999,reuseaddr stdout > {destination path on receiver host}
While on the source host (the host where the fill-in is performed), the following fill-in control is executed (depending on the backup options configured via ClusterControl UI):
$ ulimit -n 256000 && LC_ALL=C /usr/bin/innobackupex --defaults-file=/etc/my.cnf --galera-info --parallel one --stream=xbstream --no-timestamp . | gzip -half-dozen - | socat - TCP4:192.168.1.100:9999
Past using socat, ClusterControl doesn't demand to verify what type of netcat version is installed or demand to fire different commands for each version. It besides allows us to employ more than advanced options similar reuseaddr. This improves the usability of the streaming process beyond multiple operating system versions.
Nosotros hope that will be of help to anyone out in that location trying to automate their backup streaming procedure.
Happy clustering!
PS.: To get started with ClusterControl, click here!
Source: https://severalnines.com/database-blog/using-socat-centosrhel-streaming-backups
Posted by: moorehonew1961.blogspot.com
0 Response to "How To Install Socat On Redhat Linux"
Post a Comment