Skip to content

Instantly share code, notes, and snippets.

@leommoore
leommoore / systemd_services.md
Last active April 25, 2024 02:46
Systemd Services 101

Check that your system supports systemd

pidof systemd
2733

If this return a number then your system supports systemd. Most Linux distributions in 2017 support systemd.

Check out the proceses currently running.

Since systemd starts the process then all processes will be children of systemd

@leommoore
leommoore / btoa-atob.js
Last active November 19, 2017 08:00
btoa & atob
function btoa(str) {
if ((typeof str) !== 'string') {
str = JSON.stringify(str);
}
var buffer;
if (str instanceof Buffer) {
buffer = str;
@leommoore
leommoore / 00.howto_install_phantomjs.md
Last active January 9, 2019 15:38 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 2.1.1

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@leommoore
leommoore / mongodb_3.2.x_reporting.md
Last active November 9, 2020 18:11
MongoDB 3.2.x Reporting

MongoDB 3.2.x Reporting

The find() operator creates a cursor to the data. The client can then parse through the data and do calculations on the data for reports purposes. However, with large data sets this is not practical. It makes far more sense for the server to do the calculations and return the result. This can save a considerable amount of unnecessary network traffic. You can however run the count on the cursor without much overhead.

db.mycollection.find().count()

Mongo has two other methods for reporting on data:

  • Aggregation
  • Map-Reduce
@leommoore
leommoore / mongodb_ssl_with_letsencrypt.md
Last active August 16, 2022 17:35
MongoDB 3.2.x SSL with Letsencrypt

MongoDB 3.2.x SSL with Letsencrypt

Letsencrypt is an initative which aims to increase the use of encryption for websites. It basically allows people to apply for free certificates provided that they prove the they control the requested domain. We will look at the what is needed to secure your MongoDB installation. For more details on setting up a MongoDB server see MongoDB 3.2.x.

Set the hostname

We sould to set the hostname to match the name of the certificate we are going to optain.

sudo hostname mongo0.example.com

Then update the hostname file to set the server name permanently.

@leommoore
leommoore / mongodb_3.2.x_security.md
Last active October 19, 2018 00:39
MongoDB 3.2.x Security

#MongoDB 3.2.x Security

##Network Ports The standard ports used by mongo are:

ProcessRoleDefault Port
@leommoore
leommoore / mongodb_3.2.x_logging.md
Last active July 4, 2021 10:51
MongoDB 3.2.x Logging

MongoDB 3.2.x Logging

The main log file is the mongod.log. You can specify the log file location when you are starting the mongod process but if you have installed on Ubuntu from a package then you log file will normally be located in /var/log/mongodb/mongod.log.

You can tail the log file using:

tail -f /var/log/mongodb/mongod.log

From the Mongo shell you can also view the log file using:

show logs

@leommoore
leommoore / mongodb_3.2.x_sharding.md
Last active May 7, 2019 11:50
MongoDB 3.2.x Sharding

#MongoDB 3.2.x Sharding Sharding is used when the database is too large to run on a single server and you need to spread the load across multiple servers. The name itself refers to the breaking (sharding) of the data into seperate groups of data which will reside on different servers.

##Configuration Server Start the server on your server (myserver0)

mongod --configsvr --dbpath /data

On myserver1 start the shard giving the configuration server as the --configdb option

@leommoore
leommoore / mongodb_3.2.x_replica_sets_on_aws_ec2.md
Last active March 15, 2022 22:28
MongoDB 3.2.x Replica Sets on AWS EC2

#MongoDB 3.2.x Replica Sets on AWS EC2 A MongoDB replica set provides a mechanism to allow for a reliable database services. The basic replica set consists of three servers, a primary, a secondary and an arbitrator. The primary and secondary both hold a copy of the data. The arbitrator is normally a low spec server which just monitors the other servers and help with the failover process. In production, there can be more than three servers.

To setup mongo as a replica set on Amazon Web Services EC2 you need to first setup a security group with ssh on port 22 and mongodb on port 27017. You then need to create three servers. Select Ubuntu 14.04 LTS x64 and a micro (or bigger depending on your database size, ideally you should have enough memory to match your database size) instance for the primary and secondary and a nano instance for the arbitrator.

##Adjust the File System on each Server The operating system by default will update the last access time on a file. In a high data throughput database application

@leommoore
leommoore / mongodb_3.2.x.md
Last active August 16, 2022 17:35
Mongo 3.2.x

#MongoDB 3.2.x

##Install MongoDB To install MongoDB on ubuntu from precompiled version.

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.2.5.tgz
gzip -d mongodb-linux-x86_64-ubuntu1404-3.2.5.tgz
tar -xvf mongodb-linux-x86_64-ubuntu1404-3.2.5.tar

Then check put what is in the bin directory