firewall-cmd, xargs and formatting

firewall-cmd –direct –get-all-rules | xargs -n1 echo ipv4 nat PREROUTING 1 ! –src 172.30.25.0/24 –dst 10.0.25.1 -p tcp –dport 3050 -j DNAT –to 172.30.25.168:3050 -m comment –comment LVS -> server If you finished with such unformatted text, you can use the parameter -i [root@db3 ~]# firewall-cmd –direct –get-all-rules | grep “168\|.25.1\s”| head -n 2 | […]

Read more...

Data alignment in block devices

CentOS 7 [root@]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) Problem: mkfs.xfs warning: device is not properly aligned [root@]# parted -a optimal /dev/mapper/mpathb mkpart primary 0% 100% [root@]# parted /dev/mapper/mpathb align-check opt 1 1 aligned parted /dev/mapper/mpathb p Model: Linux device-mapper (multipath) (dm) Disk /dev/mapper/mpathb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: […]

Read more...

Spark and CSV and SQL

SQL data_frame = spark.read.csv(“/db/nowe/APLUS_LOG_MINMAX_1183241001_LoggerData.csv”, header=True).select(“ID”, “UTC”).limit(200) data_frame.createOrReplaceTempView(“my_table”) # What happened? # data_frame.printSchema() spark.sql(“desc my_table”).show() # Wow # data_frame.first() spark.sql(“select * from my_table limit 1”).show() # data_frame.withColumnRenamed spark.sql(“select ID as SOME_ID from my_table limit 1”).show() # Casting… data_frame.select(data_frame.ID.cast(“float”)).show(2) spark.sql(“select CAST(ID as FLOAT) as SOME_ID from my_table limit 1”).show() # Now, cast ID to float, then get […]

Read more...

Spark and CSV for python language

Now, we have 2017 year, second quarter. It seems that in one year the a/m instruction are not to be adequate. Simple instructions: # Open file and use first columns as header data_frame = spark.read.csv(“/path/to/file.csv”, header=True) # You received basic Spark type – DataFrame. # See what structure how looks the structure data_frame.printSchema() root |– […]

Read more...

Docker & mysql – import data from host

docker exec -i your-docker-name /bin/bash -c ” mysql -D your-datat-base-name ” < '/path/to/your/data.sql'

Read more...

How to log errors of all scripts executed via cron to one file?

To achieve such feature I prepared mix which is to be used in both script and cron The example: crontab -l CRON_ERR=/var/log/overseer.log * * * * * YourScript.sh 2>>$CRON_ERR || echo “[`date`] YourScript.sh” >>$CRON_ERR 2>&1 As I have already mentioned you have to modify your script either #!/bin/bash set -E GLOBAL_ERR=0 trap “GLOBAL_ERR=127” ERR [… […]

Read more...

OS X routing changed by Cisco AnyConnect

If you connect via VPN Cisco client, the routing table is changed. You can see the actual routes with following command: netstat -nr | grep “192.168” # this is my result: 192.168.0/16 10.0.255.208 UGSc 1 0 utun1 192.168.191 link#17 UCS 2 0 utun1 192.168.191.255 link#17 UHWIi 2 2 utun1 192.168.203 link#17 UCS 2 0 utun1 […]

Read more...

What resides in Linux cache? That is the question. How it is related to the docker containers?

Here you will find bunch of the answers; problem solved. https://hoytech.com/vmtouch/ https://github.com/tobert/pcstat # pcstat installation yum install golang.x86_64 go get golang.org/x/sys/unix go get github.com/tobert/pcstat/pcstat # vmtouch installtion git clone https://github.com/hoytech/vmtouch.git cd vmtouch make make install ln -s /usr/local/bin/vmtouch /sbin/ See how the cache looks like (buff/cache position): free -g == Discovery which parts of dockers’ […]

Read more...

Tuned

Simple and short info for databases/nosql. # get list tuned-adm list – latency-performance – oracle # check which is active tuned-adm active Current active profile: balanced # set tuned-adm profile latency-performance Check whether the service is enabled: [root@db8 sd-docker-creator]# systemctl list-unit-files | grep tuned tuned.service enabled Check how it works: # change governor echo powersave […]

Read more...

Reset multipath bindings

To do it, remove adequate lines in the /etc/multipath/bindings Thus, you can reset mpatha, mpathb, etc.

Read more...