Posts Tagged ‘ system

TCP state diagram

Ansible. nmcli module. Failed to import the required Python library

In new version of Ubuntu/Centos need to use new name of imported module. When using old i had this error:

Failed to import the required Python library (NetworkManager glib API) on node's Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}

when running playbook:

  - nmcli:
      conn_name: my-eth1
      ifname: eth1
      type: ethernet
      ip6: '2001:db8::cafe'
      gw6: '2001:db8::1'
      state: present


or this error when try to use NMClient from python script:

Traceback (most recent call last):
File "", line 6, in
gi.require_version('NMClient', '1.2')
File "/usr/lib/python3/dist-packages/gi/", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace NMClient not available

If we look in source code of module nmcli in line 567 ( /usr/local/lib/python3.6/dist-packages/ansible/modules/net_tools/ ):

    import gi
    gi.require_version('NMClient', '1.0')
    gi.require_version('NetworkManager', '1.0')

    from gi.repository import NetworkManager, NMClient

In new version we need to import new name NM , like this:

    import gi
    gi.require_version('NM', '1.0')

    from gi.repository import NM

And playbook work’s as expected

Flume: java.lang.NoClassDefFoundError: org/apache/hadoop/io/SequenceFile$CompressionType


2017-08-09 12:29:09,754 (conf-file-poller-0) [ERROR - org.apache.flume.node.PollingPropertiesFileConfigurationProvider$] Failed to start agent because dependencies were not found in classpath. Error follows.
java.lang.NoClassDefFoundError: org/apache/hadoop/io/SequenceFile$CompressionType
	at org.apache.flume.sink.hdfs.HDFSEventSink.configure(
	at org.apache.flume.conf.Configurables.configure(
	at org.apache.flume.node.AbstractConfigurationProvider.loadSinks(
	at org.apache.flume.node.AbstractConfigurationProvider.getConfiguration(
	at org.apache.flume.node.PollingPropertiesFileConfigurationProvider$
	at java.util.concurrent.Executors$
	at java.util.concurrent.FutureTask.runAndReset(
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(
	at java.util.concurrent.ScheduledThreadPoolExecutor$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.ClassNotFoundException:$CompressionType
	at java.lang.ClassLoader.loadClass(
	at sun.misc.Launcher$AppClassLoader.loadClass(
	at java.lang.ClassLoader.loadClass(
	... 12 more


export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/
export JAVA_OPTS="$JAVA_OPTS -Dorg.apache.flume.log.rawdata=true -Dorg.apache.flume.log.printconfig=true "


Забавна программа якщо треба перенести якийсь текст на телефон, а під рукою нема ніяких штатних месенджерів

echo "text_string" | qrencode -t UTF8 -o - 
████ ▄▄▄▄▄ █▀▄█▀▄█ ▄▄▄▄▄ ████
████ █   █ █▀▄█▀██ █   █ ████
████ █▄▄▄█ █▀▀ ▄ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█ ▀ █▄▄▄▄▄▄▄████
████ ▄▄▄ ▀▄▄  ██ ▄█▄▀ ▀▄▀████
█████▀▄▄▄█▄█▀█▀▄█▀▄▀█  ▄█████
████▄▄▄▄█▄▄▄ ▀▄▄▀█ █▀▄█ ▀████
████ ▄▄▄▄▄ █▄ ▄█▄ ██▀▀ ▄█████
████ █   █ █ ▄ █▀▀ ▄▀ ▀▄▄████
████ █▄▄▄█ █ ▄▀▀▄▀▄█▀▀ ██████

SSH client stuck on connect

This is probably an issue with D-Bus and systemd. If the dbus service is restarted for some reason, you will also need to restart systemd-logind
restart systemd-logind service:

systemctl restart systemd-logind

I had this same issue on CentOS 7, because the messagebus was restarted (which is how the D-Bus service is called on CentOS).

Linux bridge: MAC addresses and dynamic ports

Scenario: KVM virtualization host running several bridged guests. The host has a bridge interface br0 that starts out containing only eth0, and other interfaces are dynamically added and removed from the bridge as guests are started and stopped.
The problem is, the host seems to randomly suffer some loss of connectivity (from a few to 30-40 seconds) when some guest is started or stopped. Initially one might think of something related to STP, but it turns out that it is disabled (and even then, ports appearing or disappearing should not affect existing ports).

What happens here is that, when a new guest is started, a tap interface is created and enslaved to the bridge (the tap interface is usually connected to the guest’s own ethernet interface). This interface has a name like vnet5, for example. Minor but important detail, this tap interface has a more or less random MAC address. (Note that we’re talking of the host-side tap interface, not the guest-side virtual interface, whose MAC address is configurable in the guest’s configuration file or on the command line). It is theoretically possible to set the MAC address of this host-side tap interface, but it’s quite involved and basically nobody does that (and also virt-manager has no provision to do that).

Now, by default bridge interfaces in Linux use, for their MAC address, the lowest MAC address among the enslaved interfaces. So if the newly created interface has a lower MAC, the bridge changes its MAC address and uses that of the new interface. When the guest is stopped, the tap interface is removed from the bridge and destroyed, at which point the bridge’s MAC address has to change again. Depending on when and how often guests are started/stopped, the host’s bridge interface may be changing its MAC address quite often.

Of course, this may (and does) cause connectivity problems for traffic to/from the host (fortunately, traffic to/from the guests is not affected), because neighboring computers and network devices suddenly have to update their ARP caches with the new MAC address before they can talk to the host. Depending on the traffic patterns, this may take anything from a few seconds to several tens of seconds.
Read more

Mysql: wrong slave_master_info after upgrade to 5.7

After upgrade mysql-server from 5.6 to 5.7.10 something strange going on with multimaster replication.
When you add more then one channel replication tool not see second channel and server hangs on first channel.
This happens because mysql_upgrade tool have a bug. This bug create columns in table slave_master_info in wrong order.
Read more

Apache Helix presentation

Video on youtube


Add CA certifice from Let’s Encrypt to Java 8

For add cert to Java 8 you need use keytool

cd /tmp/ && \
curl -O && \
sudo $JAVA_HOME/bin/keytool -noprompt -importcert -alias letsencryptauthorityx1 -keystore $JAVA_HOME/jre/lib/security/cacerts -file  letsencryptauthorityx1.der  -storepass changeit && \
curl -O && \
sudo $JAVA_HOME/bin/keytool -noprompt -importcert -alias lets-encrypt-x3-cross-signed -keystore $JAVA_HOME/jre/lib/security/cacerts -file lets-encrypt-x3-cross-signed.der -storepass changeit

Read more

Syncthing: Debian run script

Rename syncthing.txt to syncthing
Put to /etc/init.d/
Change USER and DAEMON vars

 chmod 755 /etc/init.d/syncthing

To run Syncthing :

sudo service syncthing start

For autostart

sudo update-rc.d syncthing defaults

avconv: simple video converter in Linux

If you want convert video from big size to smartphone size use this Libav tool

apt-get install libav-tools

or Gentoo

USE="mp3 speex threads v4l jpeg2k aac amr cpudetection faac opus vdpau x264 webp  x265 xvid " CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 sse4_1"  emerge -av libav

and command for convert

avconv -i original_video.mkv -b:v 600k -s 576x432 -strict experimental small_size.mp4