Skip to content

Commit

Permalink
update installation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonng committed May 4, 2021
1 parent ca78427 commit 00c38cc
Show file tree
Hide file tree
Showing 15 changed files with 1,235 additions and 223 deletions.
23 changes: 6 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

#########################################################
# binaries
#########################################################
pigsty
bin/publish

#########################################################
# pigsty pro
#########################################################
/roles/grafana/files/dashboards/pigsty-full
roles/grafana/files/customize/public.tar.gz
/roles/service/tasks/vip_l4_reload.yml
public/

#########################################################
# packages cache
Expand All @@ -28,29 +33,13 @@ vagrant/.vagrant
# macos files
.DS_Store


#########################################################
# temp files
#########################################################
/temp/
/archive/
pigsty
.pigsty/

# shortcut
dashboard.yml


#########################################################
# environment configurations
#########################################################
# private config
conf/

# private template
templates/*-tt.conf
templates/*-tt.yml
templates/*-tt.sh
templates/pre.sh
templates/pre.yml

176 changes: 80 additions & 96 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#==============================================================#
# File : Makefile
# Ctime : 2019-04-13
# Mtime : 2021-04-22
# Mtime : 2021-04-29
# Desc : Makefile shortcuts
# Path : Makefile
# Copyright (C) 2018-2021 Ruohang Feng
Expand All @@ -13,113 +13,95 @@ VERSION=0.9
default: up

###############################################################
# Sandbox Quick Start Guide
# META NODE BOOTSTRAP COMMAND #
###############################################################

# FIRST-TIME PREPAREDNESS
# 1. make deps Install MacOS deps with homebrew
# 2. make download Get pigsty.tgz and pkg.tgz from CDN
# 3. make start Pull-up vm nodes and setup ssh access
# 4. make dns Write static DNS (only run on first time)
#=============================================================#
# quick start:
# 1. /bin/bash -c "$(curl -fsSL https://pigsty.cc/install)"
# 2. cd ~/pigsty ; make pkg # (optional)
# 3. make meta
#=============================================================#

# BOOTSTRAP
# 1. make meta Bootstrap meta node (extract pkg.tgz, install ansible, get binaries)
# 2. make infra Init infrastructure on meta node (and a pg-meta database, minimal setup)
# 3. make pgsql Init additional 3-node pgsql cluster `pg-test` on node-1, node-2, node-3
# install pigsty on ~/pigsty
install:
/bin/bash -c "$(curl -fsSL https://pigsty.cc/install)"

# download optional offline installation packages (optional, for centos7.8 only)
# BUT if your meta node DOES NOT HAVE INTERNET ACCESS
# You may have to copy/ftp/scp pkg.tgz & pigsty.tgz into meta node manually
pkg:
bin/get_pkg

###############################################################
# BOOTSTRAP
###############################################################
# upload pigsty & pkg tarball and bootstrap meta node
# (which means you can initiate control from meta node then)
# before running this, make sure pigsty resource file exists
# files/release/v${VERSION}/{pigsty,pkg}.tgz
meta: upload boot
# install ansible and init infrastructure
meta: boot infra

# install ansible (and use /tmp/pkg.tgz if exists)
boot:
sudo bin/boot

# standard infra init procedure (init infra on meta)
# init infrastructure with ansible on meta node
infra:
ssh meta 'cd pigsty && ./infra.yml'
./infra.yml

# standard pgsql init procedure (init 3-node cluster pg-test)
pgsql:
ssh meta 'cd pigsty && ./pgsql.yml -l pg-test'
# make offline installation packages (to /tmp/pkg.tgz)
cache:
sudo bin/cache

# sandbox init playbook (init 4-node at one-pass, 2~3x faster than infra + pgsql)
init: sandbox
# upgrade switch to meta db inventory instead of static config
upgrade:
bin/upgrade


###############################################################
# FIRST-TIME Preparedness
# SANDBOX BOOTSTRAP COMMAND #
###############################################################
# download pigsty resources
download: pigsty.tgz pkg.tgz
# these command are used for local vagrant sandbox environment

# start will pull-up node and write ssh-config
start: up ssh sync

# write sandbox vm ssh config (only run on first time)
ssh:
bin/ssh
# PREPAREDNESS (on your host, to setup vagrant sandbox env)
# 1. make deps Install MacOS deps with homebrew
# 2. make download Get pigsty.tgz and pkg.tgz from CDN
# 3. make start Pull-up vm nodes and setup ssh access
# 4. make dns Write static DNS (only run on first time)
# 5. make copy Copy pigsty resource to sandbox meta node

# write static dns records (sudo password required) (only run on first time)
dns:
sudo bin/dns
# BOOTSTRAP (inside vm meta node, same as standard procedure)
# make meta Bootstrap meta node (extract pkg.tgz, install ansible, get binaries)


###############################################################
# MacOS Sandbox Deps
###############################################################
brew:
#=============================================================#
# PREPAREDNESS
#=============================================================#
# install macos sandbox software dependencies
deps:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install vagrant virtualbox ansible

# download pigsty resources (and copy to files/pkg.tgz )
download: pkg
cp -f /tmp/pkg.tgz files/pkg.tgz
curl -fsSL https://pigsty.cc/pigsty.tgz -o files/pigsty.tgz

###############################################################
# Playbooks
###############################################################
# remove pgsql cluster pg-test
pgsql-rm:
ssh meta 'cd pigsty && ansible-playbook pgsql-remove.yml -l pg-test'
# start will pull-up node and write ssh-config
start: up ssh sync

# fast sandbox init playbook (2~4x fast than infra first pgsql next)
sandbox:
ssh meta 'cd pigsty && ./sandbox.yml -l pg-test'
# write static dns records (sudo password required) (only run on first time)
dns:
sudo bin/dns

# write sandbox vm ssh config (only run on first time)
ssh:
bin/ssh

###############################################################
# Bootstrap
###############################################################
# upload pigsty.tgz and extract to ~/pigsty
upload:
ssh -t meta 'sudo rm -rf ~/pigsty.tgz ~/pigsty'
# copy pigsty.tgz and pkg.tgz to sandbox meta node
copy:
scp files/release/v${VERSION}/pigsty.tgz meta:~/pigsty.tgz
ssh -t meta 'tar -xf pigsty.tgz'
scp files/release/v${VERSION}/pkg.tgz meta:/tmp/pkg.tgz
# ssh -t meta 'tar -xf pigsty.tgz'

# bootstrap meta node with pkg.tgz and extract binaries
boot:
ssh -t meta 'sudo bash ~/pigsty/bin/boot'
ssh -t meta 'sudo bash ~/pigsty/bin/get_bin'


###############################################################
# Download Resource
###############################################################
# pigsty source code packages
pigsty.tgz:
mkdir -p files/release/v${VERSION}/
curl http://pigsty-1304147732.cos.accelerate.myqcloud.com/v${VERSION}/pigsty.tgz -o /tmp/pigsty.tgz

# offline installation packages
pkg.tgz:
mkdir -p files/release/v${VERSION}/
curl http://pigsty-1304147732.cos.accelerate.myqcloud.com/v${VERSION}/pkg.tgz -o files/pkg.tgz


###############################################################
#=============================================================#
# vagrant management
###############################################################
#=============================================================#
# create a new local sandbox (assume cache exists)
new: clean up
min: meta-up meta infra
Expand All @@ -138,6 +120,7 @@ resume:
cd vagrant && vagrant resume
provision:
cd vagrant && vagrant provision

# sync ntp time
sync:
echo meta node-1 node-2 node-3 | xargs -n1 -P4 -I{} ssh {} 'sudo ntpdate -u pool.ntp.org'; true
Expand All @@ -162,10 +145,10 @@ node-new:
cd vagrant && vagrant up node-1 node-2 node-3


###############################################################
# Bench Shortcuts
###############################################################

#=============================================================#
# benchmark Shortcuts
#=============================================================#
# list pg-test clusters
rl:
ssh -t node-1 "sudo -iu postgres patronictl -c /pg/bin/patroni.yml list -W"
Expand Down Expand Up @@ -196,27 +179,28 @@ r3:



###############################################################
# project
###############################################################
#=============================================================#
# project misc
#=============================================================#

# generate playbook svg graph
svg:
bin/play_svg

# use local meta node make offline installation packages
cache:
scp bin/cache meta:/tmp/cache
ssh meta 'sudo /tmp/cache'
scp meta:/tmp/pkg.tgz files/release/v${VERSION}/pkg.tgz
# copy cached pkg.tgz from meta node
pkg.tgz:
scp meta:/tmp/pkg.tgz files/pkg.tgz

# make pigsty source code tarball
release:
bin/release ${VERSION}

# copy pigsty source to meta node (DEBUG)
cp: release
scp files/release/v${VERSION}/pigsty.tgz meta:~/pigsty.tgz
ssh meta 'sudo rm -rf pigsty; tar -xf pigsty.tgz; rm -rf pigsty.tgz'
# publish will publish pigsty to pigsty.cc
publish:
bin/publish ${VERSION}

# print quick-start tips
tip:
cat bin/install | tail -n1

.PHONY: default meta infra pgsql init download start ssh dns brew pgsql-rm sandbox upload boot pigsty.tgz pkg.tgz new min clean up halt down status suspend resume provision sync st stop meta-up node-up meta-new node-new rl ri rw ro rw2 ro2 r1 r2 r3 svg cache release cp
.PHONY: default install pkg meta boot infra deps download start dns ssh copy new min clean up halt down status suspend resume provision sync st stop meta-up node-up meta-new node-new rl ri rw ro rw2 ro2 r1 r2 r3 svg cache release pub cp
Loading

0 comments on commit 00c38cc

Please sign in to comment.