How to configure a Delayed Replica Set Member?
Let's assume that our member is third in the array of replica members:
The
The
And finally
The use case for this is to have a replication that is used for analytical purposes or used for backup and so on.
#mongodb #mongo #replica #replication #primary #delayed_replica_set #slaveDelay
Let's assume that our member is third in the array of replica members:
cfg = rs.conf()
cfg.members[2].priority = 0
cfg.members[2].hidden = true
cfg.members[2].slaveDelay = 3600
rs.reconfig(cfg)
The
priority
is set to 0 (preventing to be elected as primary).The
hidden
to true in order to hide the node from clients querying the database.And finally
slaveDelay
to number of seconds that we want it to get behind of Primary Node
.The use case for this is to have a replication that is used for analytical purposes or used for backup and so on.
#mongodb #mongo #replica #replication #primary #delayed_replica_set #slaveDelay
Tech C**P
How to configure a Delayed Replica Set Member? Let's assume that our member is third in the array of replica members: cfg = rs.conf() cfg.members[2].priority = 0 cfg.members[2].hidden = true cfg.members[2].slaveDelay = 3600 rs.reconfig(cfg) The priority…
IMPORTANT:
The length of the secondary members[n].slaveDelay must fit within the window of the oplog. If the oplog is shorter than the members[n].slaveDelay window, the delayed member cannot successfully replicate operations.
How to add self-signed certificates to replica set nodes?
https://medium.com/@rossbulat/deploy-a-3-node-mongodb-3-6-replica-set-with-x-509-authentication-self-signed-certificates-d539fda94db4
#mongo #mongodb #ssl #self_signed #openssl
https://medium.com/@rossbulat/deploy-a-3-node-mongodb-3-6-replica-set-with-x-509-authentication-self-signed-certificates-d539fda94db4
#mongo #mongodb #ssl #self_signed #openssl
Medium
Deploy a 3-Node MongoDB 4.0 Replica Set with X.509 Authentication + Self Signed Certificates
This article will guide you through the process of setting up a MongoDB cluster that will utilise X.509 authentication with self signed…
In order to see how much time your mongoDB slave is behind the primary node:
#mongodb #mongo #slave #printSlaveReplicationInfo #replica #replication
rs0:SECONDARY> db.printSlaveReplicationInfo()
source: mongo.mongo.com:27017
syncedTo: Mon Nov 12 2018 06:33:40 GMT+0000 (UTC)
-4 secs (0 hrs) behind the primary
#mongodb #mongo #slave #printSlaveReplicationInfo #replica #replication
How to check
We assume here that you have a replica set in place. First download the python script for our nagios plugin:
Now the
Create a new file
Create a new file in
This service gets enabled where it finds
#sysadmin #icinga2 #mongodb #replication #replication_lag #nagios_plugin
MongoDB
replication lag in Icinga2
and get notified when it is over 15 seconds?We assume here that you have a replica set in place. First download the python script for our nagios plugin:
cd /usr/lib/nagios/plugins
git clone git://github.com/mzupan/nagios-plugin-mongodb.git
Now the
Icinga2
part. You first need to create a command for replication lag check:cd /etc/icinga2/conf.d/commands
Create a new file
replication_lag.conf
:object CheckCommand "check_replication_lag" {
import "plugin-check-command"
command = [ PluginDir + "/nagios-plugin-mongodb/check_mongodb.py", "-A", "replication_lag" ]
arguments = {
"-H" = "$mongo_host$"
"-P" = "$mongo_port$"
}
}
Create a new file in
services
folder called replication_lag.conf
:apply Service for (display_name => config in host.vars.replication) {
import "generic-service"
check_command = "check_replication_lag"
vars += config
assign where host.vars.replication
}
This service gets enabled where it finds
replication
in host config. Now in secondary mongoDB hosts configuration add the below part:vars.replication["Secondary DB"] = {
mongo_host = "slave.example.com"
mongo_port = 27017
}
#sysadmin #icinga2 #mongodb #replication #replication_lag #nagios_plugin
Tech C**P
How to check MongoDB replication lag in Icinga2 and get notified when it is over 15 seconds? We assume here that you have a replica set in place. First download the python script for our nagios plugin: cd /usr/lib/nagios/plugins git clone git://gith…
GitHub
GitHub - mzupan/nagios-plugin-mongodb: A Nagios plugin to check the status of MongoDB
A Nagios plugin to check the status of MongoDB. Contribute to mzupan/nagios-plugin-mongodb development by creating an account on GitHub.
Why Axigen Mail Server log gives the error of
It is suggest to leave this behaviour as is, but in case there is an exception that you want to send mail to that mail server you need to ignore TLS for the target. In order to do so login to
1- Navigate to Security & Filtering -> Acceptance & Routing -> Advanced Settings
2- Click the
3- Write a suggestive name for the rule like
4- In the
- Recipient -> Domain -> add the condition -> select 'Is' from the combo box -> write Name_of_the_domain (example.com) in the combo box.
- Delivery -> Relaying mail -> click add the condition
5- Select at the top of the
6- in the
Now click
#mailserver #axigen #TLS #STARTTLS
Unable to perform STARTTLS
and how to solve it?Axigen
by default initiate a TLS connection with the target mail server. When the target mail server does not accept TLS, Axigen will mark the mail message as Relay error
with the error of Unable to perform STARTTLS
.It is suggest to leave this behaviour as is, but in case there is an exception that you want to send mail to that mail server you need to ignore TLS for the target. In order to do so login to
Axigen
webadmin interface and:1- Navigate to Security & Filtering -> Acceptance & Routing -> Advanced Settings
2- Click the
Add Acceptance / Routing Rule
button3- Write a suggestive name for the rule like
disable_tls_example_com
4- In the
Conditions
section add the following two conditions:- Recipient -> Domain -> add the condition -> select 'Is' from the combo box -> write Name_of_the_domain (example.com) in the combo box.
- Delivery -> Relaying mail -> click add the condition
5- Select at the top of the
Conditions
section For incoming messages that match
-> ALL of the conditions below
(instead of the default `ANY of the conditions below`)6- in the
Actions
section select Settings -> Allow StartTLS -> add the action. DO NOT tick the check-box next to Allow StartTLS
.Now click
SAVE CONFIGURATION
button. Your're done and you should see something like below in your axigen log file:Set recipient <[email protected]> state to SENT
#mailserver #axigen #TLS #STARTTLS
How to add comma to end of multiple lines in
1- First go to
2- Now select your mutiple lines by going down using
3- Go to end of line by pressing
4- Now press
5- type comma
6- press ESC (wait one second or so)
Voila! We're done.
#vim #tricks #VB #visual_block
VIM
? Yeah, that's tricky boy :))))1- First go to
Visual Block
mode by pressing ^v (CTRL+V)2- Now select your mutiple lines by going down using
down arrow
button.3- Go to end of line by pressing
end
command in your keyboard in linux and windows or if you're using MAC
by pressing fn+right arrow
.4- Now press
shift+A
(It worked in MAC in linux we needn't that)5- type comma
6- press ESC (wait one second or so)
Voila! We're done.
#vim #tricks #VB #visual_block
Cannot
If you haven't tried to force
Now in case using
Now user
It outputs the pid of the processes using this volume. The extra character at the end of pid will give some extra info. ( c in 2510c)
c - the process is using the file as its current working directory
m - the file is mapped with mmap
o - the process is using it as an open file
r - the file is the root directory of the process
t - the process is accessing the file as a text file
y - this file is the controlling terminal for the process
Kill these processes:
Now umount it:
#umount #NFS #fuser #psmisc
umount
a busy driver.If you haven't tried to force
umount
by -f
try it:umount -f /mnt/your-mounted-drive
Now in case using
-f
it still gives error. Try this:apt-get install psmisc
Now user
fuser
command like below:fuser -c /mnt/your-mounted-drive
/mnt/your-mounted-drive/: 2510c 11086
It outputs the pid of the processes using this volume. The extra character at the end of pid will give some extra info. ( c in 2510c)
c - the process is using the file as its current working directory
m - the file is mapped with mmap
o - the process is using it as an open file
r - the file is the root directory of the process
t - the process is accessing the file as a text file
y - this file is the controlling terminal for the process
Kill these processes:
kill -9 2510 11086
Now umount it:
umount /mnt/your-mounted-drive
#umount #NFS #fuser #psmisc
Tech C**P
Cannot umount a busy driver. If you haven't tried to force umount by -f try it: umount -f /mnt/your-mounted-drive Now in case using -f it still gives error. Try this: apt-get install psmisc Now user fuser command like below: fuser -c /mnt/your…
You can use the below command to do it all:
Where:
- parameter
- while
-
#linux #fuser #umount
fuser -ickv /mnt/your-mounted-drive
Where:
- parameter
k
kills the offending process,- while
v
shows in advance the process and its user-
i
asks you for confirmation.NOTE:
if some process resists, then try again with fuser -ickv -9
#linux #fuser #umount
Log rotatation in
some compressed files some files which ends with
The location of log rotation configs is in
Explanation of some parameters:
- weekly: weekly says that you want to
- rotate 4: it says that how many rotated files should be kept, here I keep 4 rotated files (one month).
- compress: well you tell me what this parameter does.
- delaycompress: some programs do not close file handlers immediately, here we tell log rotate to delay the compression.
- missingok: don't return error if the log file is missing
OK, the list goes on. Take a look at the manual yourself and see its options.
#linux #logrotate #rotate
Linux
is so handy as its name implies, it rotates log files. If you have a look at the /var/log
path you can seesome compressed files some files which ends with
.1
/var/log/my-app.log {
weekly
rotate 4
compress
delaycompress
missingok
notifempty
create 644 root root
}
The location of log rotation configs is in
/etc/logrotate.d/
. I have created a file in it with the config above.Explanation of some parameters:
- weekly: weekly says that you want to
Linux
to rotate your log files weekly, you can also set daily, monthly, yearly.- rotate 4: it says that how many rotated files should be kept, here I keep 4 rotated files (one month).
- compress: well you tell me what this parameter does.
- delaycompress: some programs do not close file handlers immediately, here we tell log rotate to delay the compression.
- missingok: don't return error if the log file is missing
OK, the list goes on. Take a look at the manual yourself and see its options.
#linux #logrotate #rotate
How to package Edge extension?
https://docs.microsoft.com/en-us/microsoft-edge/extensions/guides/packaging/using-manifoldjs-to-package-extensions
#microsoft #edge #extension #addon
https://docs.microsoft.com/en-us/microsoft-edge/extensions/guides/packaging/using-manifoldjs-to-package-extensions
#microsoft #edge #extension #addon
Docs
Using ManifoldJS to package extensions - Microsoft Edge Development
See how to package your Microsoft Edge extension in a snap with ManifoldJS, the Node.js open source tool.
How to create Safari Extension?
https://code.tutsplus.com/tutorials/how-to-create-a-safari-extension-from-scratch--net-15050
#apple #safari #extension #addon
https://code.tutsplus.com/tutorials/how-to-create-a-safari-extension-from-scratch--net-15050
#apple #safari #extension #addon
Code Envato Tuts+
How to Create a Safari Extension from Scratch
Safari 5, the latest version of Apple's web browser, introduces extensions. Safari extensions are small add-ons that you can use to expand Safari's capabilities, built using simple HTML, CSS and...
Don't crack! I'd like to talk a little bit of Angular here rather than backend and those jargons :)
As you might know,
In Angular to bind properties to your component variables use [] like below:
On the contrary in order to bind an event to an element you would use () as below:
In two-way binding you do as below in reality:
This is why
#angular #bind #event_binding #two_way_binding #banana_in_a_box
As you might know,
Angular
bind elements to component variables in order to update values. There is concept for data binding which is called Banana in a box
and its form is like [()]
(a banana in a box). This is a two-way binding mechanism. But why it is like that. Why a banana in a box? :)In Angular to bind properties to your component variables use [] like below:
<img [src]="my_source_image" />
On the contrary in order to bind an event to an element you would use () as below:
<button (click)="doSomething()">
In two-way binding you do as below in reality:
<input [ngModel]="ctrl.name" (ngModelChange)="ctrl.name=$event">
NOTE:
you bind name to ngModel
and on model change you set event value on form control name: ctrl.name=$event
.This is why
Angular uses `[()]
. It binds both properties and events in one go like a magic.#angular #bind #event_binding #two_way_binding #banana_in_a_box
How to create a an application for your platform? Let's say an
I suppose you have
Now you can generate a native app from your website using the command below:
There are many parameters you can give to
#nativefier #nodejs #npm #electron #mac #windows #exe
EXE
file for windows and .app
for MAC or a binary for linux.I suppose you have
nodejs
and npm
already installed. You need to install nativefier
node module using the command below first:npm install -g nativefier
Now you can generate a native app from your website using the command below:
nativefier "https://www.google.com/" --name="Google"
There are many parameters you can give to
nativefier
in order to set custom settings on it. Check nativefier --help
for that.#nativefier #nodejs #npm #electron #mac #windows #exe
I have a script that checks a source folder for new files in case there are files in the source folder, it will move those files to destination.
The problem I encountered recently was that files are huge and it may be in the middle of the copying into source by another process so my script tries to move an incomplete file to a destination. Let's say the file is 4GB in size and just only 1GB of the file has been copied. I have to wait until file is 4GB and other handler using that file, then I should safely move the file.
You can use
#linux #sysadmin #lsof #grep
The problem I encountered recently was that files are huge and it may be in the middle of the copying into source by another process so my script tries to move an incomplete file to a destination. Let's say the file is 4GB in size and just only 1GB of the file has been copied. I have to wait until file is 4GB and other handler using that file, then I should safely move the file.
You can use
lsof
command in order to check which processes are using the source file:if [[ `lsof -- /var/my-folder/my-big-file.tar.gz` ]]
then
echo "File is being used by a process."
exit 1
fi
NOTE:
you can give file directly to lsof
using --
or you can use grep command as follow:lsof | grep /var/my-folder/my-big-file.tar.gz
NOTE2:
if you are in a loop use break
instead of exit
.NOTE3:
if you get command not found
, install it using apt-get install lsof
#linux #sysadmin #lsof #grep
How to zero-pad a number in
In order to zero-pad a number you need to use do like below:
Here I have used
As simple as that.
#bash #printf #zeropad #zero-pad #zeropadding
bash
?printf
is here to help :)In order to zero-pad a number you need to use do like below:
your_number_var=1
output=$(printf "%02d" $your_number_var)
echo $output # 01
Here I have used
%02d
. the number 2 refers to numbers of padding and d
refers to digit
. So to zero-pad to 5 you can use %05d
.As simple as that.
#bash #printf #zeropad #zero-pad #zeropadding