In order to check the filesystem of the partition and where that partition maps to that address use:
#linux #mount #ext4 #nfs #filesystem #partition
mount -lIt will show for example that you have a partition that mounted by
NFS
or that a partition is ext4
and so on:/dev/mapper/vg-var on /var type ext4 (rw,relatime,stripe=384,data=ordered)
#linux #mount #ext4 #nfs #filesystem #partition
For optimal performance in terms of the storage layer, use disks backed by
Avoid
#mongodb #mongo #disk #raid #SSD
RAID-10
. RAID-5
and RAID-6
do not typically provide sufficient performance to support a MongoDB deployment.Avoid
RAID-0
with MongoDB deployments. While RAID-0
provides good write performance, it also provides limited availability and can lead to reduced performance on read operations, particularly when using Amazon’s EBS volumes.#mongodb #mongo #disk #raid #SSD
How to detect unused indexes on
#mongodb #mongo #index #unused_indexes
MongoDB
collections?db.your_collection.aggregate([{$indexStats:{}}]).pretty()
ops
displays operations per second on a specific index. If ops is very low compared to other indexes you can drop the index.#mongodb #mongo #index #unused_indexes
Tech C**P
#mongodb #backlog #road_map
The good news is
MongoDB
will support transactions from version 4.0 like any other DBMS systems like MySQL, Oracle,...OnePHP
a super simple and super lightweight PHP framework
that works in just a few lines:// index.php
require_once('src/OnePHP/one_framework.php');
$app = new \OnePHP\App();
$app->get('/:name',function( $name ) use ( $app ){//Action
echo "Hello $name";
});
$app->listen();
To install using composer:
composer create-project julces/oneframework
Why
OnePHP
:1- Restful Routes
2- Easy and clean (GET, POST, PUT, DELETE...) Requests management
3- Restful Response with HTTP Status Code and custom Headers
4- PHP native Views
5- No dependencies, add extra libraries only when you need it.
#php #framework #onePHP
If you have a dedicated server only for
Set the readahead setting to 0 regardless of storage media type (spinning, SSD, etc.).
Setting a higher readahead benefits sequential I/O operations. However, since
In general, set the readahead setting to 0 unless testing shows a measurable, repeatable, and reliable benefit in a higher readahead value. MongoDB Professional Support can provide advice and guidance on non-zero readahead configurations.
Ensure that readahead settings for the block devices that store the database files are appropriate. For random access use patterns, set low readahead values. A readahead of 32 (16 kB) often works well.
For a standard block device, you can run
#mongodb #mongo #ra #readahead #mmapv1 #wiredtiger
MongoDB
database I would I highly recommend to set block size as mongo suggested for their engines.For the WiredTiger storage engine:
Set the readahead setting to 0 regardless of storage media type (spinning, SSD, etc.).
Setting a higher readahead benefits sequential I/O operations. However, since
MongoDB
disk access patterns are generally random, setting a higher readahead provides limited benefit or performance degradation. As such, for most workloads, a readahead of 0 provides optimal MongoDB
performance.In general, set the readahead setting to 0 unless testing shows a measurable, repeatable, and reliable benefit in a higher readahead value. MongoDB Professional Support can provide advice and guidance on non-zero readahead configurations.
For the MMAPv1 storage engine:
Ensure that readahead settings for the block devices that store the database files are appropriate. For random access use patterns, set low readahead values. A readahead of 32 (16 kB) often works well.
For a standard block device, you can run
sudo blockdev --report
to get the readahead settings and sudo blockdev --setra <value> <device>
to change the readahead settings. Refer to your specific operating system manual for more information.#mongodb #mongo #ra #readahead #mmapv1 #wiredtiger
In
This is a nice way to swap variables without using a third variable.
#python #swap #swap_variables
python
in order to swap variables you can use unpack feature:>>> a, b = 1, 2
>>> a, b = b, a
>>> a, b
(2, 1)
This is a nice way to swap variables without using a third variable.
#python #swap #swap_variables
Extended unpacking (`Python 3 Only`):
This way first and last list element will be unpacked into
#python #python3 #unpack #extended_unpack
>>> a, *b, c = [1, 2, 3, 4, 5]
>>> a
1
>>> b
[2, 3, 4]
>>> c
5
This way first and last list element will be unpacked into
a
and c
and other values will be inside of b
variable.#python #python3 #unpack #extended_unpack
Learn the Zen of Python:
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
By importing
this
in your python console you will get the zen of python as above. :)#python #this #zen_of_python #zen
Tech C**P
Learn the Zen of Python: >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better…
Wikipedia
Zen of Python
collection of guiding principals for python programming language
Click
is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It’s the “Command Line Interface Creation Kit”. It’s highly configurable but comes with sensible defaults out of the box.- http://click.pocoo.org/6/
#python #argparse #click #command_line_interface
Backup and Restor from couchDB
- https://github.com/danielebailo/couchdb-dump
#database #couchdb #couch #couchBase #backup
GitHub
GitHub - danielebailo/couchdb-dump: Bash command line scripts to dump &restore a couchdb database
Bash command line scripts to dump &restore a couchdb database - danielebailo/couchdb-dump
Format a volume as XFS in Debian
First of all install
xfsprogs
:apt-get install xfsprogs
Make sure your formatting a right drive! Use
ls
to list drives:root@debian:~# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb /dev/sdb1 /dev/sdc
In this installation I will format the drive /sdc, I know this because this is a blank drive with no partitions.
Now we partition the drive with the help of
fdisk
. fdisk
can be scary if you have never used it before, in order to partition the drive use the commands below. Note: this will create one big partition, use the values inside the brackets [] as a guide.root@debian:~# fdisk /dev/sdb
Command (m for help): [n]
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): [p]
Partition number (1-4, default 1): [1]
First sector (2048-335544319, default 2048): [press Enter]
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-335544319, default 335544319): [press Enter]
Using default value 335544319
Command (m for help): [w]
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Because we installed
xfsprogs
we can make use of mkfs.xfs
to format the partition we created in the step above. -L
will label the drive as media:root@debian:~# mkfs.xfs -L media /dev/sdc1
Create a mount point:
root@debian:/dev# mkdir /mnt/dat1
Mount the drive:
root@debian:~# mount -t xfs /dev/sdc1 /mnt/dat1
Let’s check the newly mounted volume, visible at the bottom:
root@debian:/dev# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 1.9G 46G 4% /
udev 80M 4.0K 80M 1% /dev
tmpfs 36M 272K 35M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 88M 0 88M 0% /run/shm
/dev/sdc1 160G 33M 160G 1% /mnt/dat1
To permanently mount the new volume every time the system boots you will need to edit and add a new entry to /etc/ fstab. You can use the echo command to easily add the new entry:
root@debian:# echo '/dev/sdc1 /mnt/dat1 xfs defaults 0 0' >> /etc/fstab
Or manually add the entry below to fstab with the text editor of your choice:
/dev/sdc1 /mnt/dat1 xfs defaults 0 0
XFS
is a good file system for those of us working with large files. This is a recommended filesystem for those working with MongoDB wiredTiger
too.#linux #filesystem #xfs #fdisk #mount #df #fstab #xfsprogs #mkfs_xfs
Today I had to migrate the ODM class from
Go take a look at your code see whether you can change the backend DB easily from your current database to another database? Will you scratch your head when CTO says, ok we are moving to
Some people may argue that we don't change backend DB that much and we do not ever change the backend DB! This a naive consideration and I would highly recommend to think over. Because this code change flexibility shows how well your structure is implemented. How well you have programmed.
#couchdb #mongodb
CouchDB
to MongoDB
for a specific module. As we didn't combine logic into our backend database we easily changed db to MongoDB
.Go take a look at your code see whether you can change the backend DB easily from your current database to another database? Will you scratch your head when CTO says, ok we are moving to
BlahDB
, what would you do? How much flexibilty you have?Some people may argue that we don't change backend DB that much and we do not ever change the backend DB! This a naive consideration and I would highly recommend to think over. Because this code change flexibility shows how well your structure is implemented. How well you have programmed.
#couchdb #mongodb