Replace an old IP with new one in all files of all sub-directories recursively

Here is a quick Linux tip for those who want to replace their old IP with new one for all files in a given directory and all its sub-directories recursively:

find [path-to-directory] -type f -print0 | xargs -0 sed -i 's[old-IP-escape-dot]/[new-IP]/g'

Quick example:

find /etc/nginx/ -type f -print0 | xargs -0 sed -i 's/192\.168\.10\.124/10.10.10.224/g'

As you can see the directory is “/etc/nginx” and replace it with the directory where are your (configuration) files are. We are replacing old IP=192.168.10.124 with the new one 10.10.10.224, so after the execution of the above line you’ll get modified files with IP 10.10.10.224.
You must escape the dot “.” in the IP!

Mount and boot ISO file from windows share in Supermicro IPMI Virtual media (CD-ROM)

This tutorial shows you how to load any ISO file in the virtual CD/DVD-ROM of a Supermicro server and boot from it if it is bootable. You could install operating systems from a ISO file or just share a data. Here we use an installation DVD disk of CentOS 7 to boot. This tutorial expect there is a windows (samba) share on the local network if you need to do it you can check here – Configure and mount samba share in Supermicro IPMI Virtual media (CD-ROM)
Loading an ISO disk in the (virtual) CD/DVD-ROM device attached to your server could be of a great help to the system administrators, you could use diagnostic disks, update disks (BIOS and firmware of devices), install multiple operating systems including MS Windows, share data and many more! You could use ISO disk right from your computer or from a server next to the server you want to use the ISO to speed up access.

STEP 1) When you are logged in the Supermicro IPMI web interface click on Virtual Media menu and then CD-ROM Image.

main menu
CD-ROM Image

Keep on reading!

Configure and mount samba share in Supermicro IPMI Virtual media (CD-ROM)

Having many Supermicro servers we used multiple times Virtual Media to install, diagnose and rescue Supermicro server. It is really simple to open the Console Redirection – java web start and just mount the ISO file from Virtual Media -> ISO File, but this way if your server is not local to your network and it is located in a colocation as it should be the connection is slow and in many cases bogus! Because it uses UDP it happened many times to remount or just to lose the connection and the media to disappear in the middle of the booting/loading process from the installation media, for example. And probably you have noticed there is additional option in the web interface of mounting ISO file from a windows share. Of course, in linux world it might be samba share as in our case and the share could be easily configured on a server in your colocation.
And we noticed was several times we have no problems using it, but some time the share could not be even saved and respectively could not be mounted. No error reported, just the edit boxes resets to blank and apparently everything was the same as the previous box, which it worked as a charm!
Here are the steps to enable one of your CentOS 7 servers to share a resource and to use it in your Supermicro IPMI KVM. The server is selinux enabled and the policy is Enforcing.

STEP 1) Install samba server in CentOS 7

[root@srv0 ~]# yum -y install samba samba-client samba-common policycoreutils-python
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                                                                                           |  30 kB  00:00:00     
 * base: mirrors.neterra.net
 * epel: mirrors.neterra.net
 * extras: mirrors.neterra.net
 * updates: mirrors.neterra.net
base                                                                                                                                           | 3.6 kB  00:00:00     
epel                                                                                                                                           | 3.2 kB  00:00:00     
extras                                                                                                                                         | 3.4 kB  00:00:00     
updates                                                                                                                                        | 3.4 kB  00:00:00     
(1/7): base/7/x86_64/group_gz                                                                                                                  | 166 kB  00:00:00     
(2/7): epel/x86_64/group_gz                                                                                                                    |  88 kB  00:00:00     
(3/7): base/7/x86_64/primary_db                                                                                                                | 5.9 MB  00:00:00     
(4/7): extras/7/x86_64/primary_db                                                                                                              | 147 kB  00:00:00     
(5/7): updates/7/x86_64/primary_db                                                                                                             | 2.0 MB  00:00:00     
(6/7): epel/x86_64/updateinfo                                                                                                                  | 932 kB  00:00:00     
(7/7): epel/x86_64/primary                                                                                                                     | 3.5 MB  00:00:00     
epel                                                                                                                                                      12584/12584
Package samba-client-4.7.1-6.el7.x86_64 already installed and latest version
Package samba-common-4.7.1-6.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:4.7.1-6.el7 will be installed
--> Processing Dependency: samba-libs = 4.7.1-6.el7 for package: samba-4.7.1-6.el7.x86_64
--> Processing Dependency: samba-common-tools = 4.7.1-6.el7 for package: samba-4.7.1-6.el7.x86_64
--> Processing Dependency: libxattr-tdb-samba4.so(SAMBA_4.7.1)(64bit) for package: samba-4.7.1-6.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: samba-4.7.1-6.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: samba-4.7.1-6.el7.x86_64
--> Processing Dependency: libxattr-tdb-samba4.so()(64bit) for package: samba-4.7.1-6.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: samba-4.7.1-6.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package samba-common-tools.x86_64 0:4.7.1-6.el7 will be installed
---> Package samba-libs.x86_64 0:4.7.1-6.el7 will be installed
--> Processing Dependency: libpytalloc-util.so.2(PYTALLOC_UTIL_2.1.9)(64bit) for package: samba-libs-4.7.1-6.el7.x86_64
--> Processing Dependency: libpytalloc-util.so.2(PYTALLOC_UTIL_2.1.6)(64bit) for package: samba-libs-4.7.1-6.el7.x86_64
--> Processing Dependency: libpytalloc-util.so.2(PYTALLOC_UTIL_2.0.6)(64bit) for package: samba-libs-4.7.1-6.el7.x86_64
--> Processing Dependency: libpytalloc-util.so.2()(64bit) for package: samba-libs-4.7.1-6.el7.x86_64
--> Running transaction check
---> Package pytalloc.x86_64 0:2.1.10-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================================
 Package                                        Arch                               Version                                     Repository                        Size
======================================================================================================================================================================
Installing:
 samba                                          x86_64                             4.7.1-6.el7                                 base                             661 k
Installing for dependencies:
 libaio                                         x86_64                             0.3.109-13.el7                              base                              24 k
 pytalloc                                       x86_64                             2.1.10-1.el7                                base                              17 k
 samba-common-tools                             x86_64                             4.7.1-6.el7                                 base                             463 k
 samba-libs                                     x86_64                             4.7.1-6.el7                                 base                             275 k

Transaction Summary
======================================================================================================================================================================
Install  1 Package (+4 Dependent packages)

Total download size: 1.4 M
Installed size: 3.8 M
Downloading packages:
(1/5): libaio-0.3.109-13.el7.x86_64.rpm                                                                                                        |  24 kB  00:00:00     
(2/5): pytalloc-2.1.10-1.el7.x86_64.rpm                                                                                                        |  17 kB  00:00:00     
(3/5): samba-4.7.1-6.el7.x86_64.rpm                                                                                                            | 661 kB  00:00:00     
(4/5): samba-common-tools-4.7.1-6.el7.x86_64.rpm                                                                                               | 463 kB  00:00:00     
(5/5): samba-libs-4.7.1-6.el7.x86_64.rpm                                                                                                       | 275 kB  00:00:00     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                 4.5 MB/s | 1.4 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pytalloc-2.1.10-1.el7.x86_64                                                                                                                       1/5 
  Installing : samba-libs-4.7.1-6.el7.x86_64                                                                                                                      2/5 
  Installing : samba-common-tools-4.7.1-6.el7.x86_64                                                                                                              3/5 
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                                       4/5 
  Installing : samba-4.7.1-6.el7.x86_64                                                                                                                           5/5 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                                       1/5 
  Verifying  : samba-libs-4.7.1-6.el7.x86_64                                                                                                                      2/5 
  Verifying  : samba-common-tools-4.7.1-6.el7.x86_64                                                                                                              3/5 
  Verifying  : samba-4.7.1-6.el7.x86_64                                                                                                                           4/5 
  Verifying  : pytalloc-2.1.10-1.el7.x86_64                                                                                                                       5/5 

Installed:
  samba.x86_64 0:4.7.1-6.el7                                                                                                                                          

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7        pytalloc.x86_64 0:2.1.10-1.el7        samba-common-tools.x86_64 0:4.7.1-6.el7        samba-libs.x86_64 0:4.7.1-6.el7       

Complete!
[root@srv0 ~]#

STEP 2) Configure samba server CentOS 7 for the purpose of using it in IPMI Virtual share.

We are going to use a share without login credentials, because our KVM IP are always local ones and accessed via a vpn network and in addition only the network of the IPMI IPs could access the share (the samba server has a firewall configured).
Set the configuration file of the samba server – one directory storing the files shared with no login credentials (no username/password means anonymous login).
The configuration file is:

/etc/samba/smb.conf

[global]
workgroup = WINSHARE
server string = Samba Server %v
netbios name = centossrv
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
[share]
path = /mnt/storage1/samba
browsable =yes
writable = no
guest ok = yes
read only = yes

As you can see we use “/mnt/storage1/samba” for our directory where the ISO files will be located. Change this path if you want to put your ISO files somewhere else.
Set the right permissions for the directory and selinux (if you server is not selinux enabled, you could skip the selinux part) and run the samba daemon:

[root@srv0 ~]# mkdir /mnt/storage1/samba
[root@srv0 ~]# chown -R nobody:nobody /mnt/storage1/samba/
[root@srv0 ~]# semanage fcontext -a -t samba_share_t '/mnt/storage1/samba(/.*)?'
[root@srv0 ~]# restorecon -Rv /mnt/storage1/samba/
restorecon reset /mnt/storage1/samba context unconfined_u:object_r:unlabeled_t:s0->unconfined_u:object_r:samba_share_t:s0
[root@srv0 ~]# cd /mnt/storage1/samba/
[root@srv0 samba]# wget http://mirror.leaseweb.com/centos/7.5.1804/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso
--2018-06-01 14:15:42--  http://mirror.leaseweb.com/centos/7.5.1804/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso
Resolving mirror.leaseweb.com (mirror.leaseweb.com)... 37.58.58.140, 2a00:c98:2030:a034::21
Connecting to mirror.leaseweb.com (mirror.leaseweb.com)|37.58.58.140|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 950009856 (906M) [application/octet-stream]
Saving to: ‘CentOS-7-x86_64-Minimal-1804.iso’

100%[============================================================================================================================>] 950,009,856 40.1MB/s   in 33s    

2018-06-01 14:16:15 (27.3 MB/s) - ‘CentOS-7-x86_64-Minimal-1804.iso’ saved [950009856/950009856]

[root@srv0 samba]# chown nobody:nobody CentOS-7-x86_64-Minimal-1804.iso
[root@srv0 samba]# systemctl start smb
[root@srv0 samba]# systemctl status smb
● smb.service - Samba SMB Daemon
   Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-06-01 14:17:57 UTC; 20s ago
 Main PID: 31961 (smbd)
   Status: "smbd: ready to serve connections..."
    Tasks: 4
   Memory: 19.0M
   CGroup: /system.slice/smb.service
           ├─31961 /usr/sbin/smbd --foreground --no-process-group
           ├─31964 /usr/sbin/smbd --foreground --no-process-group
           ├─31965 /usr/sbin/smbd --foreground --no-process-group
           └─31966 /usr/sbin/smbd --foreground --no-process-group

Jun 01 14:17:56 srv0@local systemd[1]: Starting Samba SMB Daemon...
Jun 01 14:17:57 srv0@local smbd[31961]: [2018/06/01 14:17:57.761913,  0] ../lib/util/become_daemon.c:124(daemon_ready)
Jun 01 14:17:57 srv0@local smbd[31961]:   STATUS=daemon 'smbd' finished starting up and ready to serve connections
Jun 01 14:17:57 srv0@local systemd[1]: Started Samba SMB Daemon.

Configure the firewall to allow only connections from the IPMI KVM IP networks (or a single IP if you need to expose it in the Internet). You can work with build in zone “trusted”, but here we prefer more generic approach, which could be used not only for local IP networks but for real IPs:

[root@srv0 samba]# firewall-cmd --new-zone=smbshare --permanent
success
[root@srv0 samba]# firewall-cmd --zone=smbshare --add-source=192.168.7.0/24 --permanent
success
[root@srv0 samba]# firewall-cmd --zone=smbshare --add-service=samba --permanent
success
[root@srv0 samba]# firewall-cmd --zone=smbshare --add-service=samba-client --permanent
success
[root@srv00 samba]# firewall-cmd --reload
success
[root@srv00 samba]# firewall-cmd --zone=smbshare --list-all
smbshare (active)
  target: default
  icmp-block-inversion: no
  interfaces: 
  sources: 192.168.7.0/24
  services: samba samba-client
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

[root@srv00 samba]#

STEP 3) Mount a disk in IPMI Virutal Media and boot from it

You could check our additional tutorial for it here –

STEP 3.1) Fill “Share host” and “Path image” only, because we configured our samba share without a password

main menu
Image on Windows Share

STEP 3.2) Upon a successful configuration saving you’ll get a confirmation dialog.

If no confirmation is shown you would not be able to mount the share, check out our Troubleshooting below!

main menu
Save configuration of Image on Windows Share

STEP 3.3) After saving the configuration click on “Mount” to load your ISO file in the virtual CD-ROM.

main menu
Mount Image on Windows Share

STEP 3.4) This dialog is always shown no matter there is such share or not: “Please check the device status to confirm whether the image is mounted/unmounted.”

main menu
Check device status

STEP 3.5) If the Supermicro IPMI accessed successfully the share resource it would mount it (load the ISO file as s CD in the virtual CD-ROM).

If not the three Device 1,2,3 will show the same: “No disk emulation set.”, which means the samba share is not accessible, check the permissions for the file and the firewall first (and the logs files, too).

main menu
There is an iso file mounted

* Troubleshooting

– if you click on button “Save” and just nothing happen – no dialog for successful saving and no dialog at all, probably there is a Javascript error, try to open the web interface from a different browser with clean history or click ctrl+F5 when loading the Virtual Media page! More in Cannot save and mount a Supermicro IPMI Virtual media mount – javascript error?

Cannot save and mount a Supermicro IPMI Virtual media mount – javascript error?

If you have multiple Supermicro servers with many different versions of IPMI KVM software installed it could happen your browser to cache some of the JavaScript and other static content to reuse them, but it could very unpleasant when you have different version of IPMI software on different servers and you might notice strange behavior of the web interface! Especially if you use ssh tunneling to access your multiple Supermicro IPMI KVMs from local IP on your computerTunneling the IPMI/KVM ports over ssh (supermicro ipmi ports)

One of the big problems we have when we wanted to mount a Virtual Media

from a windows share (samba share in our case) in IPMI KVM web interface -> Virtual Media -> CD-ROM image -> Save and when the Save is clicked just nothing happen (sometimes it triggers a reload of the iframe) – no error nothing and no confirmation for successful save! At first it seems the web interface accepted the “Share Host” and “Path to Image”:

main menu
Fill “Share Host” and “Path to Image”

but when you click “Mount” it does not mount the media:
main menu
no disk emulation set

and when you reload the CD-ROM image page you get again blank edit boxes or (the old values):
main menu
Old values

Probably a refresh will get the values blank:
main menu
Blank edit boxes

And if you check your browser console you’ll see there is a JavaScript error:

Uncaught ReferenceError: FocusOnErrorSpecificCharSet3 is not defined

The error might be different, this was in our case. the problem was

the browser cached “https://192.168.0.170/js/utils.js”

from one of the previous servers and there the version of the IPMI KVM software was different and apparently the

/js/utils.js

was throwing an error and not working (this function did not exist in some older Supermicro IPMI KVM versions, the file is there but it is slightly different). The solution is so simple!

Just refresh the page with CTRL+F5 or delete the history or use another browser.

Such a simple problem, but could lead to big problems if you try to use the mount virtual media. In fact look for problems in the JavaScript if you cannot save the configuration in the “Share Host” and “Path to Image”, because when saving the IPMI do not check if there is a live “Share Host” with a windows/samba share and an image there, the software just check for special in “Shared” characters like:

var SpeficCharFilter = /[,; &'"<>\\=$|^?*~`()\[\]\{\}#%]/;

And for the password:

var SpeficCharFilter = /[,; &'"<>\\=$|^?~`()\[\]\{\}#%]/;

But in both cases you’ll get an alert with an error.

So to summer it up if you put IP and a path to the windows share of Virtual Media and click “Save” and nothing happen – no confirmation for successful saving you got a JavaScript error and probably your browser cached one of the JavaScript files, the solution is simple just refresh with CTRL+F5 or load from different browser!
We often use ssh tunneling for IPMI KVM accessTunneling the IPMI/KVM ports over ssh (supermicro ipmi ports) and different version of the static files of the supermicro IPMI web interface are cached locally, which as you can see could have really bad consequences!

Working Save button

click Save button

main menu
Fill “Share Host” and “Path to Image”

Confirmation when everything is OK

main menu
The confirmation of image on windows share has been successfully set.

sysbench – FATAL: Too large position discovered in request

Here is a quick fix, which could take you a long time solving it even with Internet, because not so much information on the topic!
Let’s you want to run sysbench to check the IO of an SSD or NVME or your old hard drive? You run something like:

sysbench --test=fileio --file-total-size=4G --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
sysbench --test=fileio --file-total-size=4G --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
sysbench --test=fileio --file-total-size=4G --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd cleanup

Total of 4G files split in 128000 files and each file should be 32K seems OK at first, but you got:

FATAL: Too large position discovered in request

And the solution is simple enough:

file-total-size = file-num * file-block-size

And put the file-total-size in the units you used for file-block-size to be sure there are no rounding!
To put in simple words:

the size of file data should evenly divide by the number of files

So the above will transform to:

ssysbench --test=fileio --file-total-size=4096000K --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
ssysbench --test=fileio --file-total-size=4096000K --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
ssysbench --test=fileio --file-total-size=4096000K --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd cleanup

Here are the computes:

–file-total-size=4096000K = –file-num=128000 * –file-block-size=32K

Simple equation could save you a lot of time!

* Good run – no errors!

srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096000K \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

128000 files, 32Kb each, 4000Mb total
Creating files for the test...
srv@local:/disks/1/test# echo 3 > /proc/sys/vm/drop_caches
srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096000K \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 100

Extra file open flags: 16384
128000 files, 32Kb each
3.9062Gb total file size
Block size 32Kb
Number of random requests for random IO: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Threads started!
Time limit exceeded, exiting...
(last message repeated 99 times)
Done.

Operations performed:  4605591 Read, 0 Write, 0 Other = 4605591 Total
Read 140.55Gb  Written 0b  Total transferred 140.55Gb  (479.74Mb/sec)
15351.63 Requests/sec executed

Test execution summary:
    total time:                          300.0067s
    total number of events:              4605591
    total time taken by event execution: 29893.5378
    per-request statistics:
         min:                                  0.07ms
         avg:                                  6.49ms
         max:                                 40.43ms
         approx.  95 percentile:               7.06ms

Threads fairness:
    events (avg/stddev):           46055.9100/51.84
    execution time (avg/stddev):   298.9354/0.00


sysbench 0.4.12:  multi-threaded system evaluation benchmark

srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096000K \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
Removing test files...

* Bad run – with the error: FATAL: Too large position discovered in request

srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096M \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

128000 files, 32Kb each, 4096M total
Creating files for the test...
srv@local:/disks/1/test# echo 3 > /proc/sys/vm/drop_caches
srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096M \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 100

Extra file open flags: 16384
128000 files, 32.768Kb each
3.9999Gb total file size
Block size 32Kb
Number of random requests for random IO: 200000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Threads started!
FATAL: Too large position discovered in request!
(last message repeated 30 times)
FATAL: Failed to read file! file: 80714 pos: 2 errno = 22 ()
FATAL: Too large position discovered in request!
(last message repeated 67 times)
Done.

Operations performed:  1 Read, 0 Write, 0 Other = 1 Total
Read 32Kb  Written 0b  Total transferred 32Kb  (114.71Kb/sec)
    3.58 Requests/sec executed

Test execution summary:
    total time:                          0.2790s
    total number of events:              1
    total time taken by event execution: 0.0038
    per-request statistics:
         min:                                  3.79ms
         avg:                                  3.79ms
         max:                                  3.79ms
         approx.  95 percentile:         10000000.00ms

Threads fairness:
    events (avg/stddev):           0.0100/0.10
    execution time (avg/stddev):   0.0000/0.00
srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096M \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd cleanup
Removing test files...

Receive multicast packets on CentOS 7 (and other linux distros)

There are so many web pages and blogs post for multicast traffic under linux and how to enable it, but in most of them something always is missing and if you follow them probably you’ll end up with not working setup and you’ll have to search the Internet again – some do need tuning of the linux kernel variables not to drop packets, some need tuning the firewall to allow protocols.
Here we present a real working example of a server under CentOS 7, our server has two network ports:

  1. eno1 – local unicast traffic with local IP
  2. eno2 – multicast traffic

We have multicast TV streams, which we can use through our second network interface and we want to use ffmpeg to encode the video. We have “Multicast Group:port” for every stream, which is like “IP:PORT” and in our case the port is always the same 5000. Here are the steps you need to do if you want to receive these streams.

STEP 1) Set networking and make the configuration permanent.

In CentOS 7 the network of eno2, set a local IP, in fact it does not matter the exact IP, we used 10.10.10.0/24 local network.

/etc/sysconfig/network-scripts/ifcfg-eno2

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno2
UUID=2481b907-5e6e-45f9-ab96-7091e4e7d6d1
ONBOOT=yes
HWADDR=0c:c4:7a:44:87:a5
IPADDR0=10.10.10.152
PREFIX0=24
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
NM_CONTROLLED=no

The important lines are highlighted. Configure the network adapter on boot and set 10.10.10.152.
Second and very important add a static route for the multicast traffic for the network interface, which is supposed to have the multicast streams (in our case “eno2”). Use file:

/etc/sysconfig/network-scripts/route-eno2

224.0.0.0/4 dev eno2

STEP 2) Kernel variables tuning

[srv@local ~]# for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 0 > "$i";   done
[srv@local ~]# echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Turn off “Reverse Path Filtering” for all interfaces (rp_filter) and ping for the multicast address to work properly we need to disable icmp_echo_ignore_broadcasts. By default kernel drops these packets so you need this tuning or your application will not receive a single udp packet.
You could save the above two lines in

/etc/rc.local

and do not forget to set proper access rights:

[srv@local ~]# chmod 755 /etc/rc.local

Or you can use

/etc/sysctl.conf

Add the following lines in it:

net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.eno2.rp_filter=0
net.ipv4.icmp_echo_ignore_broadcasts=0

STEP 3) Allow UDP traffic (and/or IGMP) if you have firewall

Here the port is the “Multicast Group:port” of the IP your application will join (look the example below)

  1. firewalld – the default with CentOS 7:
    [srv@local ~]# firewall-cmd --new-zone=multicast --permanent
    [srv@local ~]# firewall-cmd --zone=multicast --add-interface=eno2 --permanent
    [srv@local ~]# firewall-cmd --zone=multicast --add-protocol=igmp --permanent
    [srv@local ~]# firewall-cmd --zone=multicast --add-protocol=icmp --permanent
    [srv@local ~]# firewall-cmd --zone=multicast --add-source=224.0.0.0/4 --permanent
    [srv@local ~]# firewall-cmd --zone=multicast --add-source=10.10.10.0/24 --permanent
    [srv@local ~]# firewall-cmd --zone=multicast --add-port=5000/udp --permanent
    [srv@local ~]# firewall-cmd --reload
    

    We make a new zone for the multicast streams and add our interface, the sources and the port we use. We added IGMP, because in some use cases it is needed (in our it could work without IGMP added)

  2. iptables – if you have disabled firewall and still you wanted to have a firewall:
    # allow multicast addresses
    [srv@local ~]# iptables -A INPUT -p udp -d 5000 -j ACCEPT
    [srv@local ~]# iptables -A INPUT -s 224.0.0.0/4 -j ACCEPT
    [srv@local ~]# iptables -A INPUT -p igmp -d 224.0.0.0/4 -j ACCEPT
    [srv@local ~]# iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT
    

    Probably it is a good idea to see if you have current rules (with “iptables -L -v -n” or even “iptables-save”) and to see if you should use “-A” (above) or “-I” to insert the rules above the DROP rule(s).

* Example with ffmpeg joining to a multicast group

[srv@local ~]# ffmpeg -i 'udp://239.100.10.5:5000'
ffmpeg version 2.8.6 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (Gentoo 5.3.0 p1.0, pie-0.6.5)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-march=native -O2 -msse3 -fomit-frame-pointer -pipe' --disable-static --enable-avfilter --enable-avresample --disable-stripping --enable-nonfree --enable-version3 --enable-nonfree --disable-indev=alsa --disable-indev=oss --disable-outdev=alsa --disable-outdev=oss --enable-version3 --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-doc --disable-gnutls --enable-gpl --enable-hardcoded-tables --enable-iconv --disable-lzma --enable-network --enable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl --disable-vaapi --disable-vdpau --enable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --enable-libcaca --disable-openal --disable-opengl --disable-libv4l2 --disable-libpulse --enable-libopencore-amrwb --enable-libopencore-amrnb --disable-libfdk-aac --enable-libopenjpeg --disable-libbluray --disable-libcelt --disable-libgme --enable-libgsm --disable-libmodplug --disable-libopus --disable-libquvi --disable-librtmp --disable-libssh --disable-libschroedinger --disable-libspeex --enable-libvorbis --enable-libvpx --disable-libzvbi --disable-libbs2b --disable-libflite --disable-frei0r --disable-libfribidi --enable-fontconfig --disable-ladspa --disable-libass --enable-libfreetype --disable-libsoxr --enable-pthreads --enable-libvo-aacenc --disable-libvo-amrwbenc --enable-libmp3lame --disable-libaacplus --enable-libfaac --disable-libsnappy --enable-libtheora --disable-libtwolame --disable-libwavpack --disable-libwebp --enable-libx264 --disable-libx265 --enable-libxvid --enable-x11grab --disable-amd3dnow --disable-amd3dnowext --disable-fma4 --disable-xop --cpu=host
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[mpeg2video @ 0xf2fa80] Invalid frame dimensions 0x0.
    Last message repeated 10 times
Input #0, mpegts, from 'udp://239.100.10.5:5000':
  Duration: N/A, start: 87846.990933, bitrate: 5659 kb/s
  Program 5 
    Metadata:
      service_name    : ?TVtest
      service_provider: ?ss
    Stream #0:0[0x33]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], 5467 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x34](bul): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
At least one output file must be specified

As you can see to join the multicast group and ffmpeg to start encoding you use “udp://239.100.10.5:5000” for input stream parameter. Here ffmpeg joins the group and receives packets successfully.

* Generic example to receive UDP multicast stream

You may use the following example in any linux distro like Ubuntu, CentOS 7, Gentoo, OpenSuse and many others to receive muticast streams

[srv@local ~]# #ifconfig or ip - use one of them
[srv@local ~]# #ifconfig
[srv@local ~]# ifconfig eno1 10.10.10.152/24 up
[srv@local ~]# route add -net 224.0.0.0 netmask 240.0.0.0 eno2
[srv@local ~]# #or ip
[srv@local ~]# ip addr add 10.10.10.152/24 dev eno2
[srv@local ~]# ip link set eno2 up
[srv@local ~]# #allow multicast packets to the server
[srv@local ~]# for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 0 > "$i";   done
[srv@local ~]# echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
[srv@local ~]# #if you have firewall use the following for the iptables OR firewalld after that - use only one of them!
[srv@local ~]# iptables -A INPUT -p udp -d 5000 -j ACCEPT
[srv@local ~]# iptables -A INPUT -s 224.0.0.0/4 -j ACCEPT
[srv@local ~]# iptables -A INPUT -p igmp -d 224.0.0.0/4 -j ACCEPT
[srv@local ~]# iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT
[srv@local ~]# #firewalld setup
[srv@local ~]# firewall-cmd --new-zone=multicast --permanent
[srv@local ~]# firewall-cmd --zone=multicast --add-interface=eno2 --permanent
[srv@local ~]# firewall-cmd --zone=multicast --add-protocol=igmp --permanent
[srv@local ~]# firewall-cmd --zone=multicast --add-protocol=icmp --permanent
[srv@local ~]# firewall-cmd --zone=multicast --add-source=224.0.0.0/4 --permanent
[srv@local ~]# firewall-cmd --zone=multicast --add-source=10.10.10.0/24 --permanent
[srv@local ~]# firewall-cmd --zone=multicast --add-port=5000/udp --permanent
[srv@local ~]# firewall-cmd --reload

Review of freshly installed Fedora 27 Cinnamon Desktop

After the tutorial of Install Fedora 27 Cinnamon Desktop this tutorial is mainly to see what to expect from a freshly installed Fedora 27 Cinnamon – the look and feel of the Cinnamon GUI – http://developer.linuxmint.com/projects/cinnamon-projects.html
The idea of this tutorial is just to see what to expect from Fedora 27 Cinnamonthe look and feel of the GUI, the default installed programs and their look and how to do some basic steps with them, it is included also screenshots of the Cinnamon settings programs. Here you’ll find more than 100 screenshots and not so many text we do not want to turn this review of many text and version information and 3 meaningless screenshot, which you cannot see anything for the user interface, which these days is the primary goal of a Desktop system. You can expect more of this kind reviews in the future…
Cinnamon derives from GNOME 3 and it follows the traditional desktop conventions. After the release of GNOME 3 and GNOME Shell (and abandoning GNOME 2) a fork of GNOME 3 was made and Cinnamon was born to follow traditional desktop not the “shell” interface of GNOME 3. At present Cinnamon is not a front-end on top of the GNOME any more despite it still uses GTK+. If you search for a GTK+ based GNOME 2 or xfce similar linux desktop GUI you might reach a good option with Cinnamon. Its look and feel is more like KDE than MATE, which follows more strictly GNOME 2 layout.
Cinnamon is developed by Linux Mint team, which is yet another Linux distro.You can check it here – https://linuxmint.com/ As you may see from the screenshots below the main idea is to have a taskbar situated bottom of the screen with a “start” button and all programs arranged in different categories – the traditional Desktop behavior. The desktop feels fast, but there are reports of using greater memory footprint.

SCREENSHOT 1)

main menu
Keep on reading!

Install Fedora 27 Cinnamon Desktop

This tutorial will show you the simple steps of installing a modern Linux Distribution like Fedora 27 Cinnamon for the user graphical interface. Cinnamon derives from GNOME 3 and it follows the traditional desktop conventions. After the release of GNOME 3 and GNOME Shell (and abandoning GNOME 2) a fork of GNOME 3 was made and Cinnamon was born to follow traditional desktop not the “shell” interface of GNOME 3. At present Cinnamon is not a front-end on top of the GNOME any more despite it still uses GTK+. If you search for a GTK+ based GNOME 2 or xfce similar linux desktop GUI you might reach a good option with Cinnamon. Its look and feel is more like KDE than MATE, which follows more strictly GNOME 2 layout.
First we present the basic steps for installing the Operating system in addition to your present operating systems (here we have two: Windows 10 and Ubuntu) and then you can see some screenshots of the installed system and the look and feel of it. We have another tutorials showing more screenshots of the installed and working Fedora 27 Cinnamon (Gnome and KDE plasma) – so you can decide which of them to try first – coming soon. All of the installation setups are very similar for all GUIs of Fedora 27 it loads a live edition of the version of Fedora 27 you install and then the setup is launched by the user, the setup almost identical in all editions, but we do not want to give you a tutorials with “spaghetti” and unstructured flow of steps to follow.

We used the following ISO for the installation process:

https://download.fedoraproject.org/pub/fedora/linux/releases/27/Spins/x86_64/iso/Fedora-Cinnamon-Live-x86_64-27-1.6.iso

It is a LIVE image so you can try it before installing. The easiest way is just to download the image and burn it to a DVD disk and then follow the installation below:

STEP 1) If you booted from the DVD you would get this first screen – select “Start Fedora-Cinnamon-Live 27” and hit Enter

main menu
Start Fedora-Cinnamon-Live 27

Keep on reading!

Update supermicro server’s firmware BIOS under linux with the SUM cli

The newer Supermicro motherboards have the ability to update the system BIOS from IPMI Web management or with a Supermicro tool called

“Supermicro Update Manager (SUM)”

This tool consists of a linux cli and it works on most of the X9/X10/X11 Supermicro systems. If you have one of these motherboards you probably could update your BIOS under linux console and throwing away your freedos cd prehistoric update process (probably coming soon). If you’ve used Supermicro with for ages you probably are aware of the problem with the updating the BIOS, their tool is an old DOS flash utility, which could be used under MS Windows and with linux servers we got a problem! But not any more! Recent motherboards with built-in IPMI modules have “BIOS Update” option in the web interface (under Maintenance menu), but you need a license (which by the way is not expensive).

main menu
BIOS Update

So if you happen to have such server you could give a try to SUM linux cli (yes they made a linux cli and even a freebsd one!). With the SUM cli you could do more than just update the BIOS (which is pretty important) here are the functions you can do Key Management, System Checks, BIOS Management, BMC Management, System Event Log, CMM Management, Storage Management, Applications (through the network) and for some of them you still need a license, but for BIOS update you do not need if you do it as Supermicro says

In-Band

which basically means from the server you want to update (or in general use it). KEEP IN MIND this method will reset your BIOS options to DEFAULTS!!! In fact you need a license to use preserve settings you can see the output of the SUM help for the command UpdateBios. So save your changes to recover them after the update!
And here we present a BIOS update with SUM on one of our Supermicro servers with motherboard X11SSV-M4F
So the BIOS version was 1.0 reported by lshw:

[srv@local ~]# lshw|head -n 25
srv@local
    description: System
    product: Super Server (To be filled by O.E.M.)
    vendor: Supermicro
    version: 0123456789
    serial: 0123456789
    width: 64 bits
    capabilities: smbios-3.0 dmi-3.0 smp vsyscall32
    configuration: boot=normal chassis=server family=To be filled by O.E.M. sku=To be filled by O.E.M. uuid=00000000-0000-0000-0000-111111111111
  *-core
       description: Motherboard
       product: X11SSV-M4F
       vendor: Supermicro
       physical id: 0
       version: 1.02
       serial: 112233000044
       slot: To be filled by O.E.M.
     *-firmware
          description: BIOS
          vendor: American Megatrends Inc.
          physical id: 0
          version: 1.0
          date: 10/18/2016
          size: 64KiB
          capacity: 15MiB

And here are the steps to do:

STEP 1) Download the SUM cli – Supermicro Update Manager and unpack it in your server

You could download freely the SUM version 2 from here: https://www.supermicro.com/solutions/SMS_SUM.cfm (this link explains what the tool is used for) at the bottom of the page there is a link to download the SUM – https://www.supermicro.com/SwDownload/UserInfo.aspx?sw=0&cat=SUM Here you should fill the form with your name, company and email address and then you will be redirected to the download page, which at present is like the screenshot below:

main menu
Supermicro Update Manager (SUM)

When downloaded the linux version you would have the following files in the archive file:

[srv@local ~]# cd
[srv@local ~]# tar xzvf sum_2.0.0_Linux_x86_64_20171108.tar.gz
sum_2.0.0_Linux_x86_64/
sum_2.0.0_Linux_x86_64/ReleaseNote.txt
sum_2.0.0_Linux_x86_64/sum
sum_2.0.0_Linux_x86_64/ExternalData/
sum_2.0.0_Linux_x86_64/ExternalData/VENID.txt
sum_2.0.0_Linux_x86_64/ExternalData/SMCIPID.txt
sum_2.0.0_Linux_x86_64/driver/
sum_2.0.0_Linux_x86_64/driver/RHL4_x86_64/
sum_2.0.0_Linux_x86_64/driver/RHL4_x86_64/sum_bios.ko
sum_2.0.0_Linux_x86_64/driver/RHL6_x86_64/
sum_2.0.0_Linux_x86_64/driver/RHL6_x86_64/sum_bios.ko
sum_2.0.0_Linux_x86_64/driver/RHL5_x86_64/
sum_2.0.0_Linux_x86_64/driver/RHL5_x86_64/sum_bios.ko
sum_2.0.0_Linux_x86_64/driver/RHL7_x86_64/
sum_2.0.0_Linux_x86_64/driver/RHL7_x86_64/sum_bios.ko
sum_2.0.0_Linux_x86_64/SUM_UserGuide.pdf

The “sum” file binary is the tool you need.

STEP 2) Download the new motherboard BIOS firmware

, which for our board (X11SSV-M4F – https://www.supermicro.com/products/motherboard/Xeon/C236_C232/X11SSV-M4F.cfm) it was version 1.1 with filename “X11SVMF8_308.zip”, unpack the file under X11SVMF8_308

[srv@local ~]# cd
[srv@local ~]# unzip X11SVMF8_308.zip
Archive:  X11SVMF8_308.zip
   creating: X11SVMF8.308/
  inflating: X11SVMF8.308/AFUDOSU.SMC  
  inflating: X11SVMF8.308/CHOICE.SMC  
  inflating: X11SVMF8.308/FDT.smc    
  inflating: X11SVMF8.308/FLASH.BAT  
  inflating: X11SVMF8.308/Readme for UP X11 AMI  BIOS.txt  
  inflating: X11SVMF8.308/X11SVMF8.308

The file “X11SVMF8.308” is the BIOS firmware of the motherboard. As you can see the prehistoric DOS executable flash utility is still distributed and is supported method of updating.

STEP 3) Update the BIOS

[srv@local ~]# cd /root/sum_2.0.0_Linux_x86_64
[srv@local ~]# ./sum -c UpdateBios --file ../X11SVMF8.308/X11SVMF8.308 
Supermicro Update Manager (for UEFI BIOS) 2.0.0 (2017/11/08) (x86_64)
Copyright©2017 Super Micro Computer, Inc. All rights reserved
Reading BIOS flash ..................... (100%)
Checking BIOS ID ...
Checking ME Firmware ...
Comparing FDT for ROM file and flash.... (100%)

***************************<<<<<CRITICAL WARNING>>>>>***************************

ExitCode                = 254
Description             = Manual steps are required
Program Error Code      = 119.18
Error message:
    FDT is different. Please use system reboot(do not shutdown 
    or poweroff system) command to force ME enter manufacturing mode 
    and run UpdateBIOS command again to update BIOS and ME region.

********************************************************************************
[srv@local ~]# reboot

As you can see we got critical warning! You may not have the critical, but if you do you need to run the command second time to really flash the new BIOS firmware. So here it is, AFTER rebooting your server login again and execute the command again:

[srv@local ~]# cd /root/sum_2.0.0_Linux_x86_64
[srv@local ~]# ./sum -c UpdateBios --file ../X11SVMF8.308/X11SVMF8.308 
Supermicro Update Manager (for UEFI BIOS) 2.0.0 (2017/11/08) (x86_64)
Copyright©2017 Super Micro Computer, Inc. All rights reserved
Reading BIOS flash ..................... (100%)
Checking BIOS ID ...
Programming BIOS and ME (including FDT)
Writing BIOS flash ..................... (100%)
Verifying BIOS flash ................... (100%)
Checking ME Firmware ...
Putting ME data to BIOS ................ (100%)
Writing ME region in BIOS flash ...
 - Update success for FDR
 - Updated Recovery Loader to OPRx
 - Updated FPT, MFSB, FTPR and MFS
 - ME Entire Image done
WARNING:Must power cycle or restart the system for the changes to take effect!
[srv@local ~]# reboot

And there you have it you updated the BIOS of your server successfully. KEEP IN MIND the BIOS settings are reset to Defaults! When you restart the server the second time (if you get the critical warning or the first time if you do not) you should load the optimized defaults and change your settings according your needs. Go to BIOS and load the optimized defaults and change the settings according your needs (or your backup).

[srv@local ~]# lshw|head -n 25
srv@local
    description: System
    product: Super Server (To be filled by O.E.M.)
    vendor: Supermicro
    version: 0123456789
    serial: 0123456789
    width: 64 bits
    capabilities: smbios-3.0 dmi-3.0 smp vsyscall32
    configuration: boot=normal chassis=server family=To be filled by O.E.M. sku=To be filled by O.E.M. uuid=00000000-0000-0000-0000-111111111111
  *-core
       description: Motherboard
       product: X11SSV-M4F
       vendor: Supermicro
       physical id: 0
       version: 1.02
       serial: 112233000044
       slot: To be filled by O.E.M.
     *-firmware
          description: BIOS
          vendor: American Megatrends Inc.
          physical id: 0
          version: 1.1
          date: 03/08/2018
          size: 64KiB
          capacity: 15MiB

* SUM cli – UpdateBios help output

[srv@local ~]# ./sum -h -c UpdateBios
Supermicro Update Manager (for UEFI BIOS) 2.0.0 (2017/11/08) (x86_64)
Copyright©2017 Super Micro Computer, Inc. All rights reserved
Description
    Updates BIOS with the given image file.
Required Arguments
    --file    <file name>
Optional Arguments
    --reboot
          Forces the managed system to reboot or power up after operation.
    --flash_smbios
          Overwrites the SMBIOS data
    --preserve_nv
          Preserves the NVRAM region
    --preserve_mer
          Preserves the ME firmware region
    --preserve_setting
          Preserves setting configurations
Usage Modes
    [OOB] [In-Band] [Multiple systems OOB] 
Node Product Key Required
     No for [In-Band]
    Yes for [OOB]
Examples
OOB
  # ./sum -i 192.168.34.56 -u ADMIN -p ADMIN -c UpdateBios --file BIOS.rom 
    --reboot
In-Band
  # ./sum -c UpdateBios --file BIOS.rom --reboot
Multiple systems OOB
  # ./sum -l IP_ADDR_RANGE.txt -u ADMIN -p ADMIN -c UpdateBios --file BIOS.rom 
    --reboot
Notice
    1. For [OOB] and [Multiple systems OOB] usage modes, before executing this 
    command, it is recommended to shutdown the managed system first.
    2. --preserve_setting option is only supported in Purley and the platforms 
    of later versions. Note that --preserve_setting option for in-band usage 
    requires "SFT-OOB-LIC" product key. The preserved setting configurations 
    will be listed in preserved_settings.log.

* SUM cli generic help output


[srv@local ~]# ./sum 
Supermicro Update Manager (for UEFI BIOS) 2.0.0 (2017/11/08) (x86_64)
Copyright©2017 Super Micro Computer, Inc. All rights reserved

NAME
  sum (Supermicro Update Manager)

SYNOPSIS
  sum [OPTIONs] [COMMAND] [COMMAND ARGUMENTS]

OPTIONS
  -h  Shows help information.
  -v  Displays the verbose output.
  -i  <BMC/CMM IP address or BMC/CMM host name>
  -l  <BMC/CMM system list file name. Refer to the user's guide for formatting>
  -u  <BMC/CMM user ID>
  -p  <BMC/CMM user password>
  -c  <command name> (case insensitive)

USAGE MODES
○  Single System Out-Of-Band (OOB) Management [operates on single BMC/CMM]: 
    Must use -i,-u, -p options
○  Single System In-Band Management [operates on local OS]: Do not use -i, -u 
    and -p options
○  Concurrent Systems OOB Management [operates on multiple system BMCs/CMMs]: 
    Replace -i option with -l option

COMMANDS
Function Group             Command Names

Key Management             ActivateProductKey, QueryProductKey, ClearProductKey
System Checks              CheckOOBSupport, CheckAssetInfo, 
                           CheckSystemUtilization, CheckSensorData
BIOS Management            GetBIOSInfo, UpdateBios, GetDefaultBiosCfg, 
                           GetCurrentBiosCfg, ChangeBiosCfg, 
                           LoadDefaultBiosCfg, GetDmiInfo, ChangeDmiInfo, 
                           EditDmiInfo, SetBiosAction
BMC Management             GetBmcInfo, UpdateBmc, GetBmcCfg, ChangeBmcCfg
System Event Log           GetEventLog, ClearEventLog
CMM Management             GetCmmInfo, UpdateCmm, GetCmmCfg, ChangeCmmCfg
Storage Management         GetRaidControllerInfo, UpdateRaidController, 
                           GetRaidCfg, ChangeRaidCfg, GetSataInfo, GetNvmeInfo
Applications               TpmProvision, MountIsoImage, UnmountIsoImage

COMMAND USAGE
  See help message for each command
  Syntax:"  # ./sum -h -c <command name>"
  Notes: 1)Command support is platform dependent. Please refer to Appendix C in 
         the user's guide for platform dependency hints.
         2)If BMC/CMM user ID or password includes special characters, it has 
         to be quoted.

EXAMPLES
OOB
  # ./sum -i 192.168.34.56 -u ADMIN -p ADMIN -c ChangeBmcCfg --file BmcCfg.txt
  # ./sum -i 192.168.34.56 -u ADMIN -p "&123456" -c ChangeBmcCfg --file 
  BmcCfg.txt
Multiple systems OOB
  # ./sum -l IP_ADDR_RANGE.txt -u ADMIN -p ADMIN -c GetBIOSInfo --file BIOS.rom
  # ./sum -l IP_ADDR_RANGE.txt -u ADMIN -p "&123456" -c GetBIOSInfo --file 
  BIOS.rom
In-Band
  # ./sum -c UpdateBios --file BIOS.rom
Help Message
  # ./sum -h -c UpdateBios

mysql slave requested master to start replication from position greater than the file size

If you happen to reset your master mysql server without shutting down the mysql process (probably because of your super collocation cut the power!!!) you could have a slave server, which have the following error:

Last_IO_Errno: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from position > file size; the first event 'mysql-bin.005173' at 644642725, the last event read from './mysql-bin.005173' at 4, the last byte read from './mysql-bin.005173' at 4.'

The slave server wants to read a position in the master, which does not exist probably because it was not committed to the file.

It is fairly easy (and in most cases safe) to just correct the position and restart the replication! Take the Master_Log_File and Read_Master_Log_Pos on the slave with:

[root@mysql1 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50497
Server version: 5.6.38-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 10.10.10.10
                  Master_User: replusr
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.005173
          Read_Master_Log_Pos: 644642725
               Relay_Log_File: mysqld-relay-bin.000479
                Relay_Log_Pos: 644642888
        Relay_Master_Log_File: mysql-bin.005173
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 644642725
              Relay_Log_Space: 644643109
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from position > file size; the first event 'mysql-bin.005173' at 644642725, the last event read from './mysql-bin.005173' at 4, the last byte read from './mysql-bin.005173' at 4.'
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 2
                  Master_UUID: ce8a6c29-cf8e-11e5-9d39-000000000001
             Master_Info_File: /var/lib/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 180525 16:27:22
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
1 row in set (0.00 sec)

As you can see the highlighted variables are important, that is the file and the position you should check in your master mysql server. So go to your master datadir (or the binlog directory, which could be changed with “binlog-dir”) and check whether there is Master_Log_File: “mysql-bin.005173” with position Read_Master_Log_Pos: “644642725”

srv@local-master ~ # cd /var/lib/mysql/
srv@local-master mysql # ls -altr mysql-bin.005173
-rw-rw---- 1 mysql mysql 644639026 24 may 12,22 mysql-bin.005173
srv@local-master mysql # mysqlbinlog mysql-bin.005173|tail -n 15
# at 644638722
#180524 12:03:31 server id 2  end_log_pos 644638930 CRC32 0xfeabe1ab    Query   thread_id=88263388      exec_time=0     error_code=0
SET TIMESTAMP=1527152611/*!*/;
UPDATE `group_desc` SET `id` = '153357',`name` = 'Test Group Name',`tags` = '|Test Group |' WHERE  `id` = '153357'
/*!*/;
# at 644638930
#180524 12:03:31 server id 2  end_log_pos 644639026 CRC32 0x5ca1b693    Query   thread_id=88263388      exec_time=0     error_code=0
SET TIMESTAMP=1527152611/*!*/;
COMMIT
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
srv@local-master ~ # 

And yes, there is no position Read_Master_Log_Pos: “644642725” as the slave requested! The position number starts with

# at

for example

# at 644638930

As you can see from the bash commands above we got the last 15 lines of our binlog mysql file and the last position was 644638930. Here is what is going on: slave requested to continue from master’s position at 644642725, but master has last position 644638930:

644642725 > 644638930

To fix it just use the next binlog file and position 1 and your slave will continue normally. Let’s say there is a possibility your master missed to write the last commands to the master’s binlog because of the reset and in this situation your slave could be out of sync and in this case you should recover your slave from a full mysql dump and import in the slave. But in most cases it is fairly safe to continue.

[root@mysql1 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50506
Server version: 5.6.38-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> STOP SLAVE;
Query OK, 0 rows affected (0.12 sec)

mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.005174',MASTER_LOG_POS=1;
Query OK, 0 rows affected (0.47 sec)

mysql> START SLAVE;
Query OK, 0 rows affected (0.04 sec)

And if everything is OK your slave will continue with no errors (just with a big delay – behind your master):

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.10.10.10
                  Master_User: replusr
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.005175
          Read_Master_Log_Pos: 328685690
               Relay_Log_File: mysqld-relay-bin.000003
                Relay_Log_Pos: 36999
        Relay_Master_Log_File: mysql-bin.005175
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 36836
              Relay_Log_Space: 334719008
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 103216
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 2
                  Master_UUID: ce8a6c29-cf8e-11e5-9d39-000000000001
             Master_Info_File: /var/lib/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Repair by sorting
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
1 row in set (0.00 sec)

But if you get:

Duplicate entry

Last_SQL_Errno: 1062
Last_SQL_Error: Error 'Duplicate entry '422987' for key 'PRIMARY'' on query. Default database: 'mydb'. Query: 'INSERT INTO `spec_cookie` (`userid`, `userip`, `cookie`, `added`) VALUES ('96201', '2591115382', 'f3b81be45a484c652d38a2c70f8c44c30d4d04d1293918c9071e052ffd9c76f7', NOW())'

You might get into troubles if you continue, be careful!!! Examine the query, select the data in the slave and in the master, if they are equal you can skip it the error with:

[srv@local-slave ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50506
Server version: 5.6.38-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> STOP SLAVE;
Query OK, 0 rows affected (0.09 sec)

mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
Query OK, 0 rows affected (0.00 sec)

mysql> START SLAVE;
Query OK, 0 rows affected (0.12 sec)

mysql>

If they are not equal you can change them manually and continue again. More about Duplicate entry you can check here (similar mysql binlog problems): mysql slave reset and fixing relay log read failure