Skip to content

Instantly share code, notes, and snippets.

@fire
Last active August 29, 2015 14:24
Show Gist options
  • Save fire/cbc252b417870ed12231 to your computer and use it in GitHub Desktop.
Save fire/cbc252b417870ed12231 to your computer and use it in GitHub Desktop.

Smartos install

Download joyent smartos image.

Configure vm to have bridged networking and promiscious mode.

# Find if of Smartos base64 image
imgadm avail | grep base64
# Copy id and import the image
imgadm import 0edf00aa-0562-11e5-b92f-879647d45790 
# Create a container based on json information
vmadm create -f test.json

Copy of the json used in the vm creation.

{
 "brand": "joyent",
 "image_uuid": "0edf00aa-0562-11e5-b92f-879647d45790",
 "alias": "web01",
 "hostname": "web01",
 "max_physical_memory": 1750,
 "quota": 20,
 "resolvers": ["8.8.8.8", "208.67.220.220"],
 "nics": [
  {
    "nic_tag": "admin",
    "ip": "192.168.1.79",
    "netmask": "255.255.255.0",
    "gateway": "192.168.1.254"
  }
 ]
}
zlogin 644d572f-0e68-45d9-928a-f39d0f755dd7
pkgin update
pkgin -y upgrade 
pkgin -y in  build-essential flex bison openssl xml2 libxslt ossp-uuid git nano openjade docbook docbook-xsl dsssl-docbook-modular
sudo su - admin
git clone git://git.postgresql.org/git/postgres-xl
cd postgres-xl
patch -p0 < save.patch
echo export LANG=en_CA.UTF-8 >> ~/.bashrc
touch ~/.bashrc
locale
TARGET_DIR=/opt/pgxl sudo mkdir -p $TARGET_DIR sudo chown $USER $TARGET_DIR
./configure --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --enable-nls --prefix $TARGET_DIR --with-system-tzdata=/usr/share/lib/zoneinfo
make # Will fail
cd src/gtm
make LDFLAGS="-lnsl -lsocket" # Horrible hack
cd -
sudo ln -s /opt/local/bin/openjade  /opt/local/bin/jade 
#make check # Run self-test
sudo make install

Ensure that postgresql92-client is not install

sudo pkgin remove postgresql92-client

Install pgxc_ctl

cd contrib/pgxc_ctl
make
sudo make install

Using pgxc_ctl

ssh-keygen -t rsa -C "[email protected]"
# Remember to add the bin folder to your path.
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && echo "Key copied"
echo PATH=/usr/local/pgsql/bin:$PATH > ~/.bashrc
pgxc_ctl
prepare
init all
# Start all services:
start all
# Check if you connect
psql -h localhost -U admin postgres
#Use pgxc try 2

Benchmark

sudo pkgin -y in  postgresql92-pgbench
createdb -O admin winnings
pgbench -i -U admin winnings
pgbench -c 4 -S -t 2000 -U admin winnings
pgbench -c 4 -t 2000 -U admin winnings
pgbench -j4 -r -Mextended -c48 -t600 -Uadmin winnings
[admin@web01 ~]$ createdb -O admin winnings
bench -c 4 -S -t 2000 -U admin winnings
[admin@web01 ~]$ pgbench -i -U admin winnings
NOTICE:  table "pgbench_branches" does not exist, skipping
NOTICE:  table "pgbench_tellers" does not exist, skipping
NOTICE:  table "pgbench_accounts" does not exist, skipping
NOTICE:  table "pgbench_history" does not exist, skipping
creating tables...
10000 tuples done.
20000 tuples done.
30000 tuples done.
40000 tuples done.
50000 tuples done.
60000 tuples done.
70000 tuples done.
80000 tuples done.
90000 tuples done.
100000 tuples done.
set primary key...
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "pgbench_branches_pkey" for table "pgbench_branches"
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "pgbench_tellers_pkey" for table "pgbench_tellers"
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "pgbench_accounts_pkey" for table "pgbench_accounts"
vacuum...done.
[admin@web01 ~]$ pgbench -c 4 -S -t 2000 -U admin winnings
starting vacuum...end.
transaction type: SELECT only
scaling factor: 1
query mode: simple
number of clients: 4
number of threads: 1
number of transactions per client: 2000
number of transactions actually processed: 8000/8000
tps = 434.001312 (including connections establishing)
tps = 435.722063 (excluding connections establishing)
[admin@web01 ~]$ pgbench -c 4 -t 2000 -U admin winnings
starting vacuum...end.
transaction type: TPC-B (sort of)
scaling factor: 1
query mode: simple
number of clients: 4
number of threads: 1
number of transactions per client: 2000
number of transactions actually processed: 8000/8000
tps = 71.796585 (including connections establishing)
tps = 71.846106 (excluding connections establishing)

Configuration

pgxcOwner=admin
pgxcUser=$pgxcOwner
tmpDir=/tmp
localTmpDir=$tmpDir
configBackup=n

gtmName=gtm
gtmMasterServer=167.114.191.108
gtmMasterPort=20001
gtmMasterDir=$HOME/pgxc/nodes/gtm
gtmExtraConfig=none
gtmMasterSpecificExtraConfig=none

coordMasterDir=$HOME/pgxc/nodes/coord
coordSlaveDir=$HOME/pgxc/nodes/coord_slave
coordArchLogDir=$HOME/pgxc/nodes/coord_archlog
coordNames=(coord0)
coordPorts=(5432)
poolerPorts=(20010)
coordPgHbaEntries=(all)
coordMasterServers=(167.114.191.108)
coordMasterDirs=($coordMasterDir)
coordMaxWALsernder=0
coordMaxWALSenders=($coordMaxWALsender)
coordSlave=n
coordExtraConfig=coordExtraConfig
cat > $coordExtraConfig <<EOF
#================================================
# Added to all the coordinator postgresql.conf
# Original: $coordExtraConfig
log_destination = 'stderr'
logging_collector = on
log_directory = 'pg_log'
listen_addresses = '*'
max_connections = 100
log_filename = 'coordinator.log'
EOF
coordSpecificExtraConfig=(none)
coordExtraPgHba=none
coordSpecificExtraPgHba=(none)

datanodeMasterDir=$HOME/pgxc/nodes/dn_master
datanodeSlaveDir=$HOME/pgxc/nodes/dn_slave
datanodeArchLogDir=$HOME/pgxc/nodes/datanode_archlog
primaryDatanode=PGXL0
datanodeNames=(PGXL0 PGXL1)
datanodePorts=(21000 21001)
datanodePoolerPorts=(21011 21012)
datanodePgHbaEntries=(all)

datanodeMasterServers=(167.114.191.108 167.114.191.108)
datanodeMasterDirs=($datanodeMasterDir/0 $datanodeMasterDir/1)
datanodeMaxWalSender=5
datanodeMaxWALSenders=($datanodeMaxWalSender $datanodeMaxWalSender)
datanodeSlave=n
datanodeExtraConfig=none
datanodeSpecificExtraConfig=(none)
datanodeExtraPgHba=none
datanodeSpecificExtraPgHba=(none)
datanodeAdditionalSlaves=n

Add another data node to configuration.

add datanode master PGXL1 167.114.191.108 21001 21020 $HOME/pgxc/nodes/dn_master/1 none none none
add coordinator master coord2 localhost 15342 20020 $HOME/pgxc/nodes/coord_master/coord2 none none

Benchmarking postgresql

https://github.com/brianfrankcooper/YCSB.git

sudo pkgin -y in apache-maven
psql -U admin winnings
\d
createdb -U admin ycsb
psql -U admin ycsb
CREATE TABLE usertable
(
YCSB_KEY VARCHAR(2048) NOT NULL PRIMARY KEY,
FIELD1 VARCHAR(2048),
FIELD2 VARCHAR(2048),
FIELD3 VARCHAR(2048),
FIELD4 VARCHAR(2048),
FIELD5 VARCHAR(2048),
FIELD6 VARCHAR(2048),
FIELD7 VARCHAR(2048),
FIELD8 VARCHAR(2048),
FIELD9 VARCHAR(2048),
FIELD10 VARCHAR(2048)
)distribute by hash (YCSB_KEY); 
./bin/ycsb shell basic
sudo pkgin -y in jdbc-postgresql92
nano db.properties

jdbc.driver=com.mysql.jdbc.Driver
db.url=jdbc:postgresql:ycsb
db.user=admin
db.passwd=

admin@web01 ~/ycsb-0.1.4/jdbc-binding/lib]$ ln -s  /opt/local//lib/java/postgresql92.jar .
./bin/ycsb load jdbc -P workloads/workloada -P jdbc-binding/conf/db.properties -s
./bin/ycsb run jdbc -P workloads/workloada -P jdbc-binding/conf/db.properties -s
# change database so it is soft linked to a timezone database

References

http://www.postmind.net/pgxl_docker-en.html - Accessed Sun Dec 28 18:00:21 PST 2014

http://www.kelvinwong.ca/tag/pgbench/ - Sun Dec 28 22:59:30 PST 2014

http://deepdive.stanford.edu/doc/advanced/pgxl.html - Wed, 1 Jul 2015 17:59:51 -0700

diff --git doc-xc/src/sgml/Makefile doc-xc/src/sgml/Makefile
index 9c69b15..6ca1cf0 100644
--- doc-xc/src/sgml/Makefile
+++ doc-xc/src/sgml/Makefile
@@ -367,7 +367,7 @@ clean: clean-man clean-sgml
clean-man:
rm -rf fixedman/ fixed-man-stamp
-.PHONY: clean-sgml:
+.PHONY: clean-sgml
clean-sgml:
rm -rf $(ALLSGML)
diff --git src/backend/Makefile src/backend/Makefile
index ad175be..d916f13 100644
--- src/backend/Makefile
+++ src/backend/Makefile
@@ -43,6 +43,7 @@ OBJS = $(SUBDIROBJS) $(LOCALOBJS) \
$(top_builddir)/src/port/libpgport_srv.a \
$(top_builddir)/src/common/libpgcommon_srv.a \
$(top_builddir)/src/interfaces/libpq/fe-connect.o \
+ $(top_builddir)/src/interfaces/libpq/fe-secure-openssl.o \
$(top_builddir)/src/interfaces/libpq/fe-secure.o \
$(top_builddir)/src/interfaces/libpq/fe-misc.o \
$(top_builddir)/src/interfaces/libpq/fe-protocol3.o \
diff --git src/backend/pgxc/pool/pgxcnode.c src/backend/pgxc/pool/pgxcnode.c
index 38b22ee..e02c3f3 100644
--- src/backend/pgxc/pool/pgxcnode.c
+++ src/backend/pgxc/pool/pgxcnode.c
@@ -21,6 +21,9 @@
*-------------------------------------------------------------------------
*/
+#ifdef __sun
+#include "sys/filio.h"
+#endif
#include "postgres.h"
#include <sys/select.h>
#include <sys/time.h>
diff --git src/backend/pgxc/pool/poolcomm.c src/backend/pgxc/pool/poolcomm.c
index 4a3c755..3601dd0 100644
--- src/backend/pgxc/pool/poolcomm.c
+++ src/backend/pgxc/pool/poolcomm.c
@@ -11,6 +11,11 @@
*-------------------------------------------------------------------------
*/
+#ifdef __sun
+#define _XOPEN_SOURCE 500
+#define _XOPEN_SOURCE_EXTENDED 1
+#define uint uint32_t
+#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
@@ -27,7 +32,6 @@
#include "storage/ipc.h"
#include "utils/elog.h"
#include "miscadmin.h"
-
static int pool_recvbuf(PoolPort *port);
static int pool_discardbytes(PoolPort *port, size_t len);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment