This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CONTAINER_INDEX=$1 | |
CONTAINER_NAME="mongo"$1 | |
DATA_VOLUME="mongo-data-volume"$1 | |
mkdir $CONTAINER_NAME | |
DB_PORT=$((30000+$CONTAINER_INDEX)) | |
HTTP_PORT=$((28017+$CONTAINER_INDEX)) | |
NETWORK_NAME=$2 | |
REPLICASET_NAME=$3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CONTAINER_INDEX=$1 | |
CONTAINER_NAME="mongo"$1 | |
mkdir $CONTAINER_NAME | |
DB_PORT=$((30000+$CONTAINER_INDEX)) | |
HTTP_PORT=$((28017+$CONTAINER_INDEX)) | |
NETWORK_NAME=$2 | |
REPLICASET_NAME=$3 | |
# Set oplog size. | |
oplogSizeMB=128 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Setup Docker | |
NETWORK_NAME=${1:-my-mongo-cluster} | |
REPLICASET_NAME=${2:-my-mongo-set} | |
# Remove old network if has. | |
docker network rm my-mongo-cluster | |
# Create docker network name. | |
docker network create $NETWORK_NAME | |
# List docker network. | |
docker network ls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install homebrew. | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
# Install go. | |
brew install go | |
# Export path as homebrew suggest. | |
echo export PATH=$PATH:/usr/local/opt/go/libexec/bin >> ~/.bashrc | |
# Export gopath to $HOME/go | |
echo 'export GOPATH=$HOME/go' >> ~/.bash_profile | |
# Excute bash_profile. | |
. ~/.bash_profile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Docker on Ubuntu 14.04.4 x64 | |
# Ref https://docs.docker.com/engine/installation/linux/ubuntulinux/ | |
# No interactive for now. | |
export DEBIAN_FRONTEND=noninteractive | |
# Update your APT package index. | |
sudo apt-get -y update | |
# Update package information, ensure that APT works with the https method, and that CA certificates are installed. | |
sudo apt-get -y install apt-transport-https ca-certificates | |
# Add the new GPG key. | |
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
RS_INDEX=$1 | |
RS_NAME="rs"$1 | |
mkdir $RS_NAME | |
PORT=$((27017+$RS_INDEX)) | |
cat <<EOF > $RS_NAME.conf | |
systemLog: | |
destination: file | |
path: "var/log/mongodb/mongod.log" | |
logAppend: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List existing mongo process | |
pgrep mongo | |
# Kill existing process if has. | |
pkill mongo | |
# Clear old folder if has. | |
rm -rf rs0 && rm -rf rs1 | |
# Create log folder. | |
mkdir -p ./var/log/mongodb | |
# Create replica set 0 | |
. rs.sh 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Cleanup docker files: untagged containers and images. | |
# https://github.com/blueyed/dotfiles/blob/master/usr/bin/docker-cleanup | |
# Use `docker-cleanup -n` for a dry run to see what would be deleted. | |
untagged_containers() { | |
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1. | |
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6). | |
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470 | |
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Will install Docker Compose 1.7.1 | |
# Ref https://docs.docker.com/compose/install/ | |
# You can get version number from https://github.com/docker/compose/releases | |
curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose | |
# Apply executable permissions to the binary: | |
chmod +x /usr/local/bin/docker-compose | |
# Test the installation. | |
docker-compose --version | |
# Expected docker-compose version 1.7.1, build 0a9ab35 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Docker on Ubuntu 14.04 | |
# Ref https://docs.docker.com/engine/installation/linux/ubuntulinux/ | |
# Update your APT package index. | |
sudo apt-get update | |
# Ensure that APT works with the https method, and that CA certificates are installed. | |
sudo apt-get install apt-transport-https ca-certificates | |
# Add the new GPG key. | |
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D | |
# Add docker.list | |
sudo echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list |