Dry run inside project folder: terraform plan
Автор: Marribi
Show contents of the package:root# tar -tzf archiv.tar.gz
Extract files here:root# tar -xzf archiv.tar.gz
Extract only some file by mask:root# tar -xzf archiv.tar.gz "*.log"
Extract to a directory:root# tar -xzf archiv.tar.gz -C dir
Show contents of the bzip2 package:tar -tjf archiv.tar.bz2
Extract files here:root# tar -xjf archiv.tar.gz
To make 1 machine cache apt packages for hole net install apt-cacher (or apt-cacher-ng, squid-deb-proxy, apt-proxy, approx)
You do NOT need httpd (apache) for standard configuration (port 3142).
Logs file location: /var/log/apt-cacher
root# apt-get install apt-cacher
# File /etc/default/apt-cacher
vi /etc/default/apt-cacher
AUTOSTART=1
# File /etc/apt-cacher/apt-cacher.conf
vi /etc/apt-cacher/apt-cacher.conf
...
daemon_addr=192.168.0.1
allowed_hosts=192.168.0.0/24
...
root# service apt-cacher start
#Import already downloaded apt packages to apt-chacher
root# cd /usr/share/apt-cacher
root# ./apt-cacher-import.pl /var/cache/apt/archives
Client-side configuration.
Check if
http://apt-cacher:3142
http://apt-cacher:3142/report
are reachable. (with curl or browser)
And change apt conf file:
# File /apt/apt.conf.d/01proxy
vi /apt/apt.conf.d/01proxy
Acquire::http::Proxy "http://apt-cacher:3142/"
Log ping to host with timestamp.
@echo off
set /p host=HOST ADDRESS:
set logfile=Log_%host%.log
echo Target Host = %host% >%logfile%
for /f "tokens=*" %%A in ('ping %host% -n 1 ') do (echo %%A>>%logfile% && GOTO Ping)
:Ping
for /f "tokens=* skip=2" %%A in ('ping %host% -n 1 ') do (
echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A>>%logfile%
echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A
timeout 1 >NUL
GOTO Ping)
Ping some host with date every minute:
screen -dmS ping_from_edge1_to_edge2_eth0 bash -c 'while true; do date +"%Y-%m-%d %T" ; ping -c 60 IP_ADDRESS; done >> /home/user/ping_edge1_to_edge2_eth0.log'
fio (IOPS test)
Original topic can be accessed by https://www.ibm.com/cloud/blog/using-fio-to-tell-whether-your-storage-is-fast-enough-for-etcd
Test IOPS in Linux system.
tar -xzf fio.tgz
yum localinstall *.rpm
cd /data0/etcd
mkdir test-data;fio —rw=write —ioengine=sync —fdatasync=1 —directory=test-data —size=22m —bs=2300 —name=mytest
#!/bin/bash
now=$(date "+%Y%d%m-%H%M");
while true;
do
fio --rw=write --ioengine=sync --fdatasync=1 --directory=/data0/etcd/test-data --size=22m --bs=2300 --name=${now}_mytest >> /data0/etcd/results.log;
sleep 600;
done
To install Centos 7 EPEL repository execute:#yum install -y epel-release
or install it from rpm:#wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#yum install -y epel-release-latest-7.noarch.rpm
list repos:yum repolist
Search package in the repository:yum search package_name
Get information about the package:yum info package_name
Install package:yum install package_name
List all available packages in a specific repository called repo_name (will also disable all other repositories):yum --disablerepo="*" --enablerepo="repo_name" list available
Find a specific package in a specific repository:yum --disablerepo="*" --enablerepo="repo_name" list available | grep 'package_name'
List output of packages in a specific repository:yum --disablerepo="*" --enablerepo="repo_name" list available | less
Find files in current catalog with text «sometext»:find -type f -exec grep -q sometext {} \; -print
Find all files in all subdirectories and execute script/command:find . -type d -print0 | xargs -0 -L1 sh -c 'cd "$0" && pwd && ./script.sh unpack'
Find all files in the current folder that are less than 1 kilobyte and delete them:find . -type 'f' -size -1k -delete
Simple download:
wget http://website.com/file.txt
Download with reconnecting:
wget -c http://website.com/file.txt
Download with 20 retries for errors and reconnections:
wget -t 20 —retry-connrefused http://website.com/file.txt
Download the whole website up to 4 layers in-depth (-l 4):
wget -r -l 4 -p -E -k http://website.com
-r — recursively
-l 4 — 4 layers in depth
-p — download css and images
-E — download php and asp scripts
-k — converts links in files to point to local copies
Download website:
wget -p -k -E -H http://website.com/index.html
-H — checks external links to be accessible.
execute the program with different priority:
nice -n [19 to -20] program
-n 0 — standard priority
-n 19 — lowest priority
-n -20 — highest priority
change already running program priority:
renice -n [19 to -20] -p PID
renice -n [19 to -20] -u user
change IO priority:
ionice -c [1 to 3] -n [19 to -20] command or program
ionice -c 2 -n 7 cat /var/logs/some.log
or with process:
ionice -c2 -n7 -p PROCESS(PID)
-c means class of IO priority:
-c 1: Real-time. The highest IO priority can interrupt the operating system’s normal behavior.
-c 2: Best effort. The default class of priority, nice and renice will do the work with the second class of IO priority.
-c 3: Idle. The process will get IO only when no other process is using the drives.
more info: man-page ionice(1)
Start command in a detached screen with logging to file, example captures pod logs in the background:screen -dmS screen_name bash -c 'kubectl logs -f pod_name | tee /home/user/log.txt';
Close all detached screens:
screen -ls | grep ‘(Detached)’ | awk ‘sys {screen -S $1 -X quit}’