Showing posts with label tip. Show all posts
Showing posts with label tip. Show all posts

Wednesday, March 17, 2021

Change version of maven module and sub-module

 After a release or during a simple hot fix, you might want to modify the version of your maven-based service 


This is the trick: 


mvn versions:set -DgenerateBackupPoms=false -DnewVersion=1.42.0.1-SNAPSHOT

Thursday, November 21, 2019

Elastic Search - recovery of shards

In order to understand the status of the Elastic Cluster shard recovery (how many shards and in what percentage of data are still to be consumed by the elastic node):



watch -n 1 -d "curl -sS localhost:9200/_cat/recovery | grep -v done | sort"


curl -sS localhost:2013/_cat/recovery | grep -v done | sort
chat_events_2018_10        0  1080986 replica index    svpr-els219 svpr-els222 n/a n/a 99  99.0%  9245443931 99.4%  99  9245443931  0       100.0% 0
chat_events_2018_10        12 880628  replica index    svpr-els219 svpr-els225 n/a n/a 118 80.5%  9507834833 50.9%  118 9507834833  0       100.0% 0
chat_events_2018_10        4  1080998 replica index    svpr-els217 svpr-els222 n/a n/a 120 98.3%  9212348531 84.1%  120 9212348531  0       0.0%   549128
chat_events_2018_10        6  48448   gateway translog avpr-els217 avpr-els217 n/a n/a 0   100.0% 0          100.0% 120 9111543410  314413  -1.0%  -1
chat_events_2018_10        7  37318   gateway translog svpr-els239 svpr-els239 n/a n/a 0   100.0% 0          100.0% 119 9355121451  215907  -1.0%  -1
chat_events_2018_11        15 246460  replica index    svpr-els221 svpr-els230 n/a n/a 94  92.6%  7473306012 59.9%  94  7473306012  0       0.0%   207497
chat_events_2018_12        17 561707  replica index    svpr-els217 svpr-els225 n/a n/a 78  83.3%  5985100320 0.1%   78  5985100320  0       100.0% 0
chat_events_2019_01        10 403900  replica index    svpr-els222 svpr-els230 n/a n/a 162 68.5%  5824180424 0.3%   162 5824180424  0       0.0%   166305
chat_events_2019_02        1  377381  replica index    svpr-els222 svpr-els228 n/a n/a 154 72.1%  5509742229 0.2%   154 5509742229  0       0.0%   122191
chat_events_2019_02        16 561676  replica index    svpr-els220 svpr-els245 n/a n/a 150 95.3%  4684545993 80.1%  150 4684545993  0       0.0%   122191
chat_events_2019_03        3  936237  replica index    svpr-els217 svpr-els242 n/a n/a 158 75.9%  5212773307 7.8%   158 5212773307  0       0.0%   1527414

Sunday, October 6, 2019

lpnova - create OpenStack VM

Clone (clone server similar to avor-wto134 - 2 instances)
lpnova --clone avor-wto134 -H avor-wto -Q 2 -D virginia -U fawzea

in case of failure (because of F5 for ex , assuming avor-wto109 and 122 was created but failed in the middle) 

lpnova --clone avor-wto134 -H avor-wto109 -H avor-wto122   -D virginia -U fawzea --load 

Tuesday, September 24, 2019

Puppet sandbox


In order to check your puppet script in a sandox, go to any linux server and create the following directory structure:



Create dir


/tmp/mypuppet/


Under this directory 


./modules./modules/test./modules/test/templates./modules/test/templates/test.erb./modules/test/manifests./modules/test/manifests/init.pp



Here's your manifest: 
./test.pp

puppet apply --modulepath /tmp/mypuppet/modules test.pp

In my example , this was the manifest:

test.pp :
node qtvr-wto134 {class { 'test::config': }
} 

the modules modules/test/manifests/init.pp :


class test::config ($routingRulesList = ['zzffline1', 'zzffline2', 'zzffline3'],) {
file { "/home/michael_puppet_sandbox/mypuppet/locations.include":ensure => present,content => template("test/test.erb"),}
}

 and the template modules/test/templates/test.erb :
<% @routingRulesList.each do |routingRule| -%><%=routingRule%><% end %>


and then click on

 puppet apply --modulepath /tmp/mypuppet/modules .  test.pp 


The command puppet apply --modulepath /tmp/mypuppet/modules . test.pp  will create the following output file :



puppet apply --modulepath /tmp/mypuppet/modules . test.pp
zzffline1zzffline2zzffline3

Thursday, March 8, 2018

for loop example - for remote ssh

instead of mcollective:

for server in qtvr-els03  qtvr-els04  qtvr-els05  qtor-els601  qtor-els602  qtor-els603  qtvr-els005  qtvr-els0029 ; do ssh root@$server "hostname; /etc/init.d/elasticsearch status "; done


Or also
for server in `zoom --HF lpcluster=z2_elasticsearch_agent_manager_01 -f hostname`; do ssh $server 'echo $HOSTNAME'; done;



in another word:

for server in server1 server2 server3 ; do ssh root@$server "hostname; echo do something"; done


Very useful!

Thursday, July 20, 2017

Socat - a Simple Tcp Proxy

In order to setup a simple TCP proxy, I've used the following :

yum install socat

socat TCP4-LISTEN:2003,fork TCP4:app.graphite.lpdomain.com:2003


This listen to port 2003 and send everything to the remote server app.graphite.lpdomain.com , to remote port 2003

I've done that in order to be able to send metric value to a remote graphite server that was not accessible from my server.
In order to send value to graphite , I've used the following :


echo Centralized.service.sandbox.test3   1234  `date +%s --date='30 minutes ago'` | nc -v my-proxy-server 2003


BTW, I was also suggested to use nc command, but it appears that this proxy tool is more primitive and doesn't support multiple connection apparently :

mkfifo backpipe
nc -k -l 2003    <backpipe | nc app.graphite.lpdomain.com 2003  1>backpipe 

Tuesday, July 14, 2015

how to fix the RPM stuck problem

how to fix the RPM stuck problem 
when running rpm -qa |grep something , then it gets stuck forever ...

It's problably due to the a huge number of RPM process ...

I was suggested to do the following: 
  • ps -ef|grep rpm |awk '{print $2}' | xargs kill -9
  • cd /var/lib/rpm/
  • ls
  • rm -f  __*


Other related links: 
http://unix.stackexchange.com/questions/166966/rpm-command-stuck-freeze-when-installing-rpm-file



rpm may be waiting for a lock to be freed.
First, run ps -ef | grep rpm to see if you have any RPM commands running. If you do, kill them using kill -9.
Next, delete any leftover locks rm -rf /var/lib/rpm/__db.0*

Tuesday, June 23, 2015

NFS and Shared Folder creation between servers


Install NFS on all your servers

yum install nfs-utils -y
service rpcbind start
service nfs start
service autofs restart

NFS server side

Then, in your "NFS server", create the shared folder (aka the folder to be shared)

mkdir /home/mich/SHARED_FOLDER
chmod a+w /home/mich/SHARED_FOLDER



Define the mount folder:

vi /etc/exports /home/mich/SHARED_FOLDER 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)
where the  192.168.1.0/24 is the IP range of the servers authorized to access this mounted folders

In order to make the export change effective, type:
exportfs -a

then, do not forget to start nfs
/etc/init.d/nfs start

or even to start it automatically in startup:
for ex:

cat /etc/rc.d/rc.local 

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
depmod -a
modprobe acpiphp
if [ -f /etc/rc.firstboot ]
then
        /etc/rc.firstboot | tee /var/log/firstboot.log
        cp /etc/rc.firstboot /usr/local/etc/
        rm /etc/rc.firstboot
        reboot
fi
touch /var/lock/subsys/local
/etc/init.d/nfs start

NFS CLIENT side


Then, on each client side, that want to use this mount :


mkdir /nfs/shared
mount -t nfs 192.168.20.11:/home/mich/SHARED_FOLDER/ /nfs/shared/


where 192.168.20.11 is the IP of the NFS server that you've configured in the previous paragraph

or do it automatically after startup:
vi /etc/fstab

add something like:
192.168.20.11:/home/mich/SHARED_FOLDER/ /nfs/shared/  nfs rsize=8192,wsize=8192,timeo=14,intr

if you want to test it without reboot your machine, do simply
mount -a

All those instructions were freely and quite fully inspired from this link:


Thursday, June 18, 2015

Cannot delete file in Windows - it says Already

Ever tried to delete / move / rename a file , but Windows refuses, saying the file is already used by another program ...


In order to find this f$@@%! other file that prevent you to handle this file, you can use ProcessExplorer




Press on Find / Find Handle or DLL
write the name of your file



Credits goes to
http://superuser.com/questions/399659/how-can-i-identify-what-application-is-using-a-given-file


Sunday, June 15, 2014

Working Environment 2014

Here's a list of the tools that I want to see on any dev computer (windows 7 enterprise) I'm working with.



Ditto - clipboard manager  http://ditto-cp.sourceforge.net/
ArsClip - clipboard manager  better than Ditto (which has a high-cpu bug) http://www.joejoesoft.com/vcms/97/
Cygwin
Console - for emulating both cygwin and DOS - http://sourceforge.net/projects/console/
Xemacs  - editor
WinMerge  - file comparison
JDK  - java of course
Maven (modify the setting to your needs)
IDE (Idea / Eclipse )
WinRar  - unzip / uncompress tool
mRemoteNG - for ssh  http://www.mremoteng.org/
Unlocker - for finding process that "handles" a file
Launchy  - windows app launcher (like Executor / SlickRun ) - http://www.launchy.net/download.php#windows  - or maybe the winner is executor . unclear
KeePass - password manager http://keepass.info/
GoogleDrive
Google Music 
Tortoise (SVN ) 
SlikSVN - for SVN binary as well - http://www.sliksvn.com/en/download
Process Explorer  
Apache Directory Studio
to be continued ...

Monday, June 2, 2014

vi macro - tip

I always wanted to know that: macro on vi ...




Instructions: To enter a macro, type:
q<letter><commands>q
To execute the macro <number> times (once by default), type:
<number>@<letter>


Example: So, the complete process looks like:
qdstart recording to register d
...your complex series of commands
qstop recording

Then, for re-executing the macro :

@dexecute your macro
@@execute your macro again

Monday, November 19, 2012

How to synchronize clock between time

In order to synchronize the clock time between servers, you must have one reference server. In our example tlvntp1.tlv.lpnet.com
Then, all your server should refer to it . That's the way to do it:

1) In your file /etc/ntp.conf, you should have the following line:

server tlvntp1.tlv.lpnet.com
My System Administrator did the following shortcut:
echo server tlvntp1.tlv.lpnet.com > /etc/ntp.conf

But be careful with it, since it may delete other synchronization option the file already has.


2) To be synchronized with our IT ntpserver (the one with the good clock time)
service ntpd restart

3) Then ntpq -p
to display what the offset with the synchronized server  (the tlvntp1) 
The offset should reduce after few minutes ....

This apparently means what is the offset between your current server and the referenced ntp server ( here, for ex, rstm02 and rstm18 etc ...)
michaelz@roor-wto128:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+rstm02.lpdomain 64.236.96.53     2 u  162 1024  377    0.320    4.600   0.049
+rstm18.lpdomain 204.9.54.119     2 u  150 1024  377    0.337    5.579   0.063
*rstm09.lpdomain 64.236.96.53     2 u  173 1024  377    0.358    1.196   0.035
 rstm07.lpdomain 172.16.22.71     2 u  551 1024  377    0.777  -42.128   3.369
 rstm06.lpdomain 172.16.22.71     2 u  884 1024  377    2.675  -94.770  96.884


Same, but without host name resolving (-n option)
michaelz@roor-wto128:~$ ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+10.16.23.11     64.236.96.53     2 u  168 1024  377    0.320    4.600   0.049
+10.16.22.18     204.9.54.119     2 u  156 1024  377    0.337    5.579   0.063
*10.16.23.21     64.236.96.53     2 u  179 1024  377    0.358    1.196   0.035
 10.16.22.61     172.16.22.71     2 u  557 1024  377    0.777  -42.128   3.369
 10.16.22.71     172.16.22.71     2 u  890 1024  377    2.675  -94.770  96.884


4) Synchronize time between two servers
In order to synchronize the time between two different servers (no need to have an ntp server in between):

ntpdate -u the-second-host-server





To synchronize your Windows with an external NTP server, do the following:
net time \\tlvdc1 /set /y    
where, tlvdc1 is the host  name of yoru NTP server