I can talk about
Maybe in the future I do so! :)
Icinga2
for about a book! From memory, CPU, disk usage monitoring to even creating custom plugins with python or other languages to monitor your specific use case (Let's you want to monitor your microservice modules).Maybe in the future I do so! :)
One of the greatest examples of
https://docs.mongodb.com/manual/tutorial/geospatial-tutorial/
#mongodb #mongo #geospatial #geoWithin #geoNear #geo #2dsphere #geoIntersects
Geospatial
queries is MongoDB's tutorial about finding the nearest restaurant. This example can be applied to online taxis like Snapp
, tap30
or some social networks. Read the below article if you are crazy as hell to learn new things like me :)https://docs.mongodb.com/manual/tutorial/geospatial-tutorial/
#mongodb #mongo #geospatial #geoWithin #geoNear #geo #2dsphere #geoIntersects
Mongodb
Find Restaurants with Geospatial Queries
در طول دوره کاری خود بارها با بحث تغییر نیازمندیهای بیزینس مواجه شده ام و در تمامی موارد به جرات می توانم بگویم که هر زمانی که تغییر نیازمندی باعث تغییر زیاد در ماژولها میشود و من از انجام تغییر از راه میانبر و به قولی کثیف پیش برده ام یکجا همون قضیه یقه من راه گرفته (bite in the ass) و هر بار که تغییر مورد نظر با اینکه زیاد هم بوده انجامش داده ام توانستم که به بهترین نحو مسئله را حل کنم و در آینده هم خودم از کارم راضی بودم.
نکته مهم قضیه این هست که همیشه مدیران عامل به سریعترین وجه ممکن خروجی را از شما میخواهند، در این گونه مواقع سریع تسلیم نشوید و کار کثیف و میانبر که بد هست را انجام ندهید. مدیر عامل فردی ست مثل شما با آنها صحبت کنید و بگویید به این دلایل زمان بیشتری میخواهید و باید به این صورت انجام شود وگرنه در آینده به مشکل میخوریم، در اکثر موارد موفق می شوید که زمان بیشتری بخرید و کار را بصورت درست انجام دهید. در کنار زمان، این مسئله به اخلاق برنامه نویسی نیز بازمیگردد و برخی افراد حوصله کار زیاد والبته درست را ندارند!!! عجیب است ولی خود من هم تا چند سال پیش در همین دسته جای میگرفتم.
نکته اینجاست که اخلاقتون رو خوب کنید :)
و نکته بعد این هست که با مدیران خود صحبت کنید و آنها را در قبال کاری که میکنید توجیح کنید.
#دلنوشته
نکته مهم قضیه این هست که همیشه مدیران عامل به سریعترین وجه ممکن خروجی را از شما میخواهند، در این گونه مواقع سریع تسلیم نشوید و کار کثیف و میانبر که بد هست را انجام ندهید. مدیر عامل فردی ست مثل شما با آنها صحبت کنید و بگویید به این دلایل زمان بیشتری میخواهید و باید به این صورت انجام شود وگرنه در آینده به مشکل میخوریم، در اکثر موارد موفق می شوید که زمان بیشتری بخرید و کار را بصورت درست انجام دهید. در کنار زمان، این مسئله به اخلاق برنامه نویسی نیز بازمیگردد و برخی افراد حوصله کار زیاد والبته درست را ندارند!!! عجیب است ولی خود من هم تا چند سال پیش در همین دسته جای میگرفتم.
نکته اینجاست که اخلاقتون رو خوب کنید :)
و نکته بعد این هست که با مدیران خود صحبت کنید و آنها را در قبال کاری که میکنید توجیح کنید.
#دلنوشته
https://medium.com/@psamim/performance-tips-to-have-in-mind-while-writing-react-components-1f387adce7a5
#react #reactjs
#react #reactjs
Medium
Performance tips to have in mind while writing React components
As I was fine-tuning the React components I am working on, I tested and played with different ways I could re-write the code. I am…
https://askubuntu.com/questions/919054/how-do-i-run-a-single-command-at-startup-using-systemd
#linux #systemd #systemctl #service
#linux #systemd #systemctl #service
Ask Ubuntu
How do I run a single command at startup using systemd?
I'd like to startup an Apache Spark cluster after boot using the following command:
sudo ./path/to/spark/sbin/start-all.sh
Then run this command when the system prepares to reboot/shutdown:
sudo ...
sudo ./path/to/spark/sbin/start-all.sh
Then run this command when the system prepares to reboot/shutdown:
sudo ...
Upgrade mongoDB from
Here we persume you are on
1- import public key:
2- create apt sources file:
3- update repo
4- install the MongoDB packages
* it will ask for config overwrite, if you want to take backup take a backup from config and then overwrite it.
#mongodb #mongo #mongodb36 #database #upgrade #mongodb34
3.4
to 3.6
:Here we persume you are on
debian 8 jessie
.1- import public key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
2- create apt sources file:
echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.6 main" | sudo tee / etc/apt/sources.list.d/mongodb-org-3.6.list
3- update repo
sudo apt-get update
4- install the MongoDB packages
sudo apt-get install -y mongodb-org=3.6.2 mongodb-org-server=3.6.2 mongodb-org-shell=3. 6.2 mongodb-org-mongos=3.6.2 mongodb-org-tools=3.6.2
* it will ask for config overwrite, if you want to take backup take a backup from config and then overwrite it.
#mongodb #mongo #mongodb36 #database #upgrade #mongodb34
Check
Please make sure that you have permissions on getting grants list, otherwise
#mysql #grants #sql_grants #database
grants
of a specific user on MySQL
:SELECT sql_grants FROM common_schema.sql_show_grants WHERE user='app';
Please make sure that you have permissions on getting grants list, otherwise
permission denied
will be returned back.#mysql #grants #sql_grants #database
Did you know that the mongoDB shell is a full-featured JavaScript interpreter, capable of running arbitrary JavaScript programs? To illustrate this, let’s perform some basic math:
We can also leverage all of the standard JavaScript libraries:
We can even define and call JavaScript functions. In previous posts we explained how to kill slow queries, there we explained how to define a function in MongoDB and store that function inside of MongoDB.
#mongodb #mongo #shell #javascript #js
> x = 200
200
> x / 5;
40
We can also leverage all of the standard JavaScript libraries:
> Math.sin(Math.PI / 2);
1
> new Date("2010/1/1");
"Fri Jan 01 2010 00:00:00 GMT-0500 (EST)"
> "Hello, World!".replace("World", "MongoDB"); Hello, MongoDB!
We can even define and call JavaScript functions. In previous posts we explained how to kill slow queries, there we explained how to define a function in MongoDB and store that function inside of MongoDB.
#mongodb #mongo #shell #javascript #js
Tech C**P
Today we encountered slowness on MongoDB that caused all the infrastructure to get affected. The problem was that slowness on some specific mongo queries caused all the other queries to wait. YES we use index and YES we used explained on those queries and…
You can read more about mongoDB functions here...
OperationalError: (2013, 'Lost connection to MySQL server during query')
Usually it indicates network connectivity trouble and you should check the condition of your network if this error occurs frequently. If the error message includes “during query,” this is probably the case you are experiencing.
Sometimes the “during query” form happens when millions of rows are being sent as part of one or more queries. If you know that this is happening, you should try increasing net_read_timeout from its default of 30 seconds to 60 seconds or longer, sufficient for the data transfer to complete.
More rarely, it can happen when the client is attempting the initial connection to the server. In this case, if your connect_timeout value is set to only a few seconds, you may be able to resolve the problem by increasing it to ten seconds, perhaps more if you have a very long distance or slow connection. You can determine whether you are experiencing this more uncommon cause by using SHOW GLOBAL STATUS LIKE 'Aborted_connects'. It will increase by one for each initial connection attempt that the server aborts. You may see “reading authorization packet” as part of the error message; if so, that also suggests that this is the solution that you need.
If the cause is none of those just described, you may be experiencing a problem with BLOB values that are larger than max_allowed_packet, which can cause this error with some clients. Sometime you may see an ER_NET_PACKET_TOO_LARGE error, and that confirms that you need to increase max_allowed_packet.
#database #mysql #OperationalError #connection
Usually it indicates network connectivity trouble and you should check the condition of your network if this error occurs frequently. If the error message includes “during query,” this is probably the case you are experiencing.
Sometimes the “during query” form happens when millions of rows are being sent as part of one or more queries. If you know that this is happening, you should try increasing net_read_timeout from its default of 30 seconds to 60 seconds or longer, sufficient for the data transfer to complete.
More rarely, it can happen when the client is attempting the initial connection to the server. In this case, if your connect_timeout value is set to only a few seconds, you may be able to resolve the problem by increasing it to ten seconds, perhaps more if you have a very long distance or slow connection. You can determine whether you are experiencing this more uncommon cause by using SHOW GLOBAL STATUS LIKE 'Aborted_connects'. It will increase by one for each initial connection attempt that the server aborts. You may see “reading authorization packet” as part of the error message; if so, that also suggests that this is the solution that you need.
If the cause is none of those just described, you may be experiencing a problem with BLOB values that are larger than max_allowed_packet, which can cause this error with some clients. Sometime you may see an ER_NET_PACKET_TOO_LARGE error, and that confirms that you need to increase max_allowed_packet.
#database #mysql #OperationalError #connection
How to check
If you have local access to mySQL server you can check it by:
If you have remote access to
#mysql #version
MySQL
version:If you have local access to mySQL server you can check it by:
mysql -v
If you have remote access to
MySQL
you can first login to mysql using mysql -u USERNAME -p PASS -h REMOTE_HOST
. And then after successful login issue the below command:SELECT version();
#mysql #version
In order to connect directly to
If your
The interesting thing about this command is that you can give database name that you want to work on:
Now after connecting if you use
#database #mongodb #mongo
MongoDB
from your host:mongo YOUR_REMOTE_MONGO_SERVER:27017
If your
MongoDB
port is different, use your desired port rather than 27017.The interesting thing about this command is that you can give database name that you want to work on:
mongo YOUR_REMOTE_MONGO_SERVER:27017/YOUR_DB
Now after connecting if you use
db
command you should see your current db:rs0:PRIMARY> db
YOUR_DB
rs0:PRIMARY
will be shown when you use replication. Your case may be different.#database #mongodb #mongo
How to print a sentence when users on the server run mongo shell?
For
By default
That's it! Save the file and run
In order to disable dangerous functionalities:
Sample output:
#mongodb #mongo #shell #mongorc
For
DBAs
to limit some dangerous functionalities like dropping a database or it can be a helpful message. Or a greeting message. Or even printing the default database that he is already connected to.By default
mongoDB
looks for a file named .mongorc.js
in your home directory. So create a file ~/.mongorc.js
and put a content like below inside of it:print("Hello! Welcome to Alireza company :)");
print("Your database is set to: " + db);
That's it! Save the file and run
mongo
in your terminal, the output should be similar to the following:$ mongo
MongoDB shell version v3.6.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.2
Your database is set to: test
Hello! Welcome to Alireza company :)
>
In order to disable dangerous functionalities:
var no = function() { print("oops! You are not allowed to drop anything!!");};
// Prevent dropping databases
db.dropDatabase = DB.prototype.dropDatabase = no;
// Prevent dropping collections
DBCollection.prototype.drop =no;
// Prevent dropping indexes
DBCollection.prototype.dropIndex = no;
Sample output:
> db.dropDatabase('bi')
oops! You are not allowed to drop anything!!.
NOTE:
You can disable loading your .mongorc.js
by using the --norc
option when starting the shell.#mongodb #mongo #shell #mongorc
In order to connect to
Sample usages:
Read full details here:
- http://api.mongodb.com/python/current/examples/high_availability.html#connecting-to-a-replica-set
#database #mongodb #mongo #replica_set #replication #pymongo #arbiter #master #primary #slave
MongoDB replica set
in Python
you can give all server node addersses to MongoClient
. Addresses passed to MongoClient()
are called the seeds. As long as at least one of the seeds is online, MongoClient
discovers all the members in the replica set, and determines which is the current primary and which are secondaries or arbiters.Sample usages:
>>> MongoClient('localhost', replicaset='foo')
MongoClient(host=['localhost:27017'], replicaset='foo', ...)
>>> MongoClient('localhost:27018', replicaset='foo')
MongoClient(['localhost:27018'], replicaset='foo', ...)
>>> MongoClient('localhost', 27019, replicaset='foo')
MongoClient(['localhost:27019'], replicaset='foo', ...)
>>> MongoClient('mongodb://localhost:27017,localhost:27018/?replicaSet=foo')
MongoClient(['localhost:27017', 'localhost:27018'], replicaset='foo', ...)
Read full details here:
- http://api.mongodb.com/python/current/examples/high_availability.html#connecting-to-a-replica-set
#database #mongodb #mongo #replica_set #replication #pymongo #arbiter #master #primary #slave
Secondary Reads
By default an instance of MongoClient sends queries to the primary member of the replica set. To use secondaries for queries we have to change the read preference:
>>> client = MongoClient(
... 'localhost:27017',
... replicaSet='foo',
... readPreference='secondaryPreferred')
>>> client.read_preference
SecondaryPreferred(tag_sets=None)
Now all queries will be sent to the secondary members of the set. If there are no secondary members the primary will be used as a fallback. If you have queries you would prefer to never send to the primary you can specify that using the secondary read preference.
#mongodb #replica_set #replication #secondary #slave #pymongo