cgi-node

Dec 13, 07:52 AM

NOTICE CASE – instructions are WRONG. CgiNodeInfo() not cgiNodeInfo() !

Mark Edwards

,

---

mariadb 10.2 beta deepstream installation

Dec 12, 05:35 AM

mariadb 10.2 BETA written from here

INITIAL:

sudo yum —assumeyes update ;
sudo yum —assumeyes group install “Development Tools” ;
sudo yum —assumeyes install git wget curl ;
###########sudo yum —assumeyes install gcc gcc-c++ ;

NODE:

sudo -i ;
curl —silent —location https://rpm.nodesource.com/setup_7.x | bash – ;
yum —assumeyes install nodejs ;
which node ;
node —version ;

APACHE:

sudo yum —assumeyes install httpd ;
sudo systemctl start httpd.service ;
sudo systemctl enable httpd.service ;

MARIADB:

cat </etc/yum.repos.d/MariaDB.repo ;

  1. MariaDB 10.2 CentOS repository list – created 2016-12-12 17:34 UTC
  2. http://downloads.mariadb.org/mariadb/repositories/
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.2/centos7-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    END

yum —assumeyes install MariaDB-server MariaDB-client ;

mysql_install_db —user=mysql —basedir=/usr —datadir=/var/lib/mysql ;
systemctl start mariadb ;
systemctl enable mariadb ; ## optional !

mysql ; ## notice version number !
CREATE USER ‘john’@‘localhost’ IDENTIFIED BY ‘123’ ;
GRANT ALL ON . to ‘john’@‘localhost’ IDENTIFIED BY ‘123’ with max_queries_per_hour 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
CREATE DATABASE IF NOT EXISTS deepstream ;
GRANT ALL PRIVILEGES ON `deepstream`.* TO ‘john’@‘localhost’ ;
EXIT

mysql —user=john -p123 deepstream ;

DEEPSTREAM:

sudo wget https://bintray.com/deepstreamio/rpm/rpm -O /etc/yum.repos.d/bintray-deepstreamio-rpm.repo ;
sudo yum install —assumeyes deepstream.io ;
which deepstream;
deepstream —version ;

DEEPSTREAM-MARIADB CONNECTOR:

MANUALLY INSTALL plugin at /etc/deepstream/config.yml !
plugins: storage: name: deepstream.io-storage-mariadb options: ds_host: ‘localhost’ ds_user: ‘john’ ds_password: ‘123’ ds_databaseName: ‘deepstream’ ds_tableName: ‘deepstream_storage’ ds_keyType: ‘text’ ds_valueType: ‘text’ ds_splitter: ‘/’

(log out of root!)

mkdir server; cd server;

npm init;
npm install —save uws ; ## not sure if this is needed??
npm install —save deepstream.io ;
npm install —save deepstream.io-client-js ;
npm install —save perimetral/deepstream.io-storage-mariadb ; ## may be replaced
npm install —save dyncol ; ## only for blob/binary usage
npm install —save sequelize ; ## only for blob/binary usage

server.js:

cat <server.js ;
let ds = require(‘deepstream.io’);
let connector = require(‘deepstream.io-storage-mariadb’);
//let server = new Deepstream(); ### BAD – typo in instructions !
let server = new ds();

server.set(‘storage’, new connector({ mariasql: { host: ’127.0.0.1’, user: ‘john’, password: ‘123’, db: ‘deepstream’, }, table: { name: ‘deepstream_storage’, keyType: ‘text’, valueType: ‘text’, }, splitter: ‘/’,
}));

server.start() ;
END

node server.js ;

===================

example.js

mkdir ~/example; cd ~/example ;
npm init; ## answer questions
npm install —save deepstream.io-client-js ;

cat < example.js ;

const deepstream = require(‘deepstream.io-client-js’) ;
const util = require(‘util’) ;
const dsIpPort = ‘localhost:6020’ ;
const client = deepstream(dsIpPort).login() ;

var record = client.record.getRecord(‘Another-New-Record-Name’);

var testJson = { ‘newTestJson’ : [ { ‘firstKey’ : ‘this is my first key’ , ‘secondKey’ : ‘this is my second key’ } , { ‘thirdKey’ : ‘this is my third key’ , ‘fourthKey’ : ‘this is my fourth key’ } ] } ;

console.log(util.inspect(testJson));

record.whenReady( () => { // ? ? ? ? ? ? record.set(‘myTestJsonValue’, {x:2} ); //record.set(‘firstname’, ‘this is a test value’ ); //record.set(‘myTestJsonValue’, testJson );
});
END

node example.js ;

#######deepstream install storage mariadb ;

  1. ln -s
  2. /var/lib/deepstream/deepstream.io-storage-mariadb/src/connector.js
  3. /var/lib/deepstream/deepstream.io-storage-deepstream.io-storage-mariadb ;


https://www.npmjs.com/package/deepstream.io-storage-mariadb
===

##git clone https://github.com/perimetral/deepstream.io-storage-mariadb

  1. ?? ln -s /root/node_modules/deepstream.io-storage-cockroachdb/src/connector.js

Mark Edwards

,

---

roger ailes

Nov 12, 09:40 AM

When is Donald Trump going to stop embarrassing his friends, let alone the whole country?

source

Donald Trump’s surprise and unprovoked attack on Megyn Kelly during her show last night is as unacceptable as it is disturbing. Megyn Kelly represents the very best of American journalism and all of us at FOX News Channel reject the crude and irresponsible attempts to suggest otherwise. I could not be more proud of Megyn for her professionalism and class in the face of all of Mr. Trump’s verbal assaults. Her questioning of Mr. Trump at the debate was tough but fair, and I fully support her as she continues to ask the probing and challenging questions that all presidential candidates may find difficult to answer. Donald Trump rarely apologizes, although in this case, he should. We have never been deterred by politicians or anyone else attacking us for doing our job, much less allowed ourselves to be bullied by anyone and we’re certainly not going to start now. All of our journalists will continue to report in the fair and balanced way that has made FOX News Channel the number one news network in the industry.

roger ailes
Mark Edwards

,

---

express from scratch

Oct 14, 04:32 AM

to install express from scratch:

open port:

  • Go to cloud.google.com
  • Go to my Console
  • Choose you Project.
  • Choose “Compute Engine”
  • Choose “Networks”
  • Choose the interface for you Instances.
  • In firewalls section, Go to Create New.
  • Create your rule, in this case “Protocols & Ports” would be “tcp:9090” i guess.
  • Save.

sudo yum —assumeyes group install “Development Tools” ;

curl o https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash ;

nvm install node ;

#############sudo yum —assumeyes install httpd mod_ssl ;
#############sudo /usr/sbin/apachectl start ;

Mark Edwards

,

---

cockroachdb

Oct 3, 04:49 AM

NOTE: pay particular attention to the “—store” name – maybe better not to rely on —store defaults??

NOTE: probably best to only run one node – it appears that starting up two (or more) nodes then trying to start just one does not work.

installation and initial setup:

###########sudo su; ## this line should NOT be cut-pasted, since what follows it will be ignored….

set -o vi;
sudo yum —assumeyes update ;
sudo yum —assumeyes group install “Development Tools” ;
sudo yum —assumeyes install golang ; ## cockroachdb requires golang
#

mkdir ~/go ;
export GOPATH=~/go ;
export PATH=$PATH:$GOPATH/bin ;
go version ;

##mkdir ~/cockroachdb ;

sudo curl https://binaries.cockroachdb.com/cockroach-latest.linux-amd64.tgz > ~/cockroach.tgz;
sudo gzip -d ~/cockroach.tgz ;
sudo tar -xvf ~/cockroach.tar ;
sudo rm -v -f ~/cockroach.tar;
###cd cockroach-latest.linux-amd64 ;
sudo mv —interactive —verbose ~/cockroach-latest.linux-amd64/cockroach /usr/local/bin/ ;
sudo rmdir —verbose ~/cockroach-latest.linux-amd64/ ;

  1. export PATH=$PATH:/root/cockroachdb/cockroach-latest.linux-amd64 ; ???
  2. cd ; ???
    cockroach version ;

##

  1. NOTE: sudo cockroach DOES NOT WORK – root is not allowed to start cockroach!

cockroach start —background —insecure ; ## skip the CA certificate stuff (for now)
cockroach start —background —insecure —logtostderr ; ## note optional logging errors!

build: beta-20160929 2016/09/29 17:51:34 (go1.7.1) admin: http://localhost:8080 sql: postgresql://rootlocalhost:26257?sslmode=disable logs: cockroach-data/logs store0: path=cockroach-data

(http-host comes from the google-console in this case)

cockroach start —store=node2 —insecure —port=26258 —http-port=8081 —join=localhost:26257 —background ;

  1. this one did not work for some reason:

cockroach start —store=node2 \ —insecure \ —port=26258 \ —http-host=10.138.0.2 \ —http-port=8081 \ —join=localhost:26257 \ —background ;

build: beta-20160929 2016/09/29 17:51:34 (go1.7.1) admin: http://10.138.0.2:8081 sql: postgresql://rootcockroach-db:26258?sslmode=disable logs: node2/logs store0: path=node2 join0: localhost:26257

cockroach node status —insecure ; ## shows status of all nodes (2017-10-27 added “—insecure)
cockroach quit —port=26257 —insecure ; ## stop node

========================================================
all examples are —insecure – how to secure:

(notice use of internal and external IP numbers for google VPS instance)

cockroach cert create-ca \ —certs-dir=./path-to-certs-directory \ —ca-key=./path-to-ca-key/ca-key ;

cockroach cert create-node localhost 35.196.129.11 \ —certs-dir=./path-to-certs-directory \ —ca-key=./path-to-ca-key/ca-key ;

cockroach cert create-client markedwards \ —certs-dir=./path-to-certs-directory \ —ca-key=./path-to-ca-key/ca-key ;

cockroach user set markedwards \ —certs-dir=./path-to-certs-directory \ —host=35.196.129.11 \ —password ;

cockroach start —certs-dir=./path-to-certs-directory \ —host=10.142.0.16 \ —http-host=localhost \ —background ;

cockroach node ls —certs-dir=./path-to-certs-directory \ —host=35.196.129.11 ;

cockroach node status —certs-dir=./path-to-certs-directory \ —host=35.196.129.11 ;

cockroach quit —host=35.196.129.11 \ —certs-dir=./path-to-certs-directory ;

cockroach sql -e ‘GRANT ALL ON DATABASE bank TO markedwards’ \ —certs-dir=./path-to-certs-directory \ —host=35.196.129.11 ;

cockroach sql -e ‘GRANT SELECT, INSERT, UPDATE ON bank.users TO markedwards’ \ —certs-dir=./path-to-certs-directory \ —host=35.196.129.11 ;

==
feathers file edits:

./src/sequelize.js: dialect: ‘postgres’, dialectOptions: { ssl: true }, /* added dialectOptions */ ./config/default.json: “postgres”: “postgres://markedwards:aaaaaa@35.196.129.11:26257/bank”

======================================================

  1. create a database “bank” , create a user “maxroach” and give maxroach priveleges

cockroach sql -e ‘CREATE DATABASE bank;’ —insecure ;
cockroach user set maxroach —insecure ; ## create user maxroach
cockroach sql -e ‘GRANT ALL ON DATABASE bank TO maxroach;’ —insecure ;

cockroach sql —user=maxroach —insecure; ## (2017-10-27 added “—insecure)

###############create database bank; SHOW DATABASES; /* notice comment has closed star-slash */ SET DATABASE=bank ; /* comments has to be closed like this */ CREATE TABLE accounts ( id INT PRIMARY KEY , balance DECIMAL , createdat TIMESTAMP , updatedat TIMESTAMP ) ; SHOW COLUMNS FROM accounts; INSERT INTO accounts VALUES ( unique_rowid(), 10000.50 ) ; /* notice unique_id() ! */ SELECT * FROM accounts ;

========================
—insecure – seems to be the only way thus far to allow for anything other than “localhost”
https://www.cockroachlabs.com/docs/secure-a-cluster.html

============== N O D E ===

NODE installation:

sudo firewall-cmd —zone=dmz —add-port=26257/tcp —permanent ; sudo firewall-cmd —reload ;

sudo curl —silent —location https://rpm.nodesource.com/setup_8.x | sudo bash – ;

sudo yum —assumeyes install nodejs ;

node —version ; ## look for v8.8.1 (at the time of this writing)

== posgres example:

https://www.cockroachlabs.com/docs/stable/build-a-nodejs-app-with-cockroachdb.html – node.js app (2017-10-27 !!)
mkdir ./node-test; cd ./node-test;
npm install async pg —save ;
curl https://raw.githubusercontent.com/cockroachdb/docs/master/_includes/app/basic-sample.js > basic-sample.js;
node basic-sample.js ; ## worked 2017-10-27

== sequelize example
https://www.cockroachlabs.com/docs/stable/build-a-nodejs-app-with-cockroachdb-sequelize.html

mkdir ~/sequelize-example; cd ~/sequelize-example;
curl https://raw.githubusercontent.com/cockroachdb/docs/master/_includes/app/sequelize-basic-sample.js > sequelize-basic-sample.js ;
npm install sequelize sequelize-cockroachdb —save ;
node sequelize-basic-sample.js ;

==============

https://www.cockroachlabs.com/docs/constraints.html

??????
update -what about this?
https://www.cockroachlabs.com/docs/serial.html
CREATE TABLE serial (a SERIAL PRIMARY KEY, b STRING, c BOOL);
???????

parent/child:
CREATE TABLE grandParentTable ( id INT PRIMARY KEY , grandParentTable_name VARCHAR NOT NULL ); CREATE TABLE parentTable ( id INT PRIMARY KEY , grandParentTable INT NOT NULL REFERENCES grandParentTable(id) , parentTable_name VARCHAR NOT NULL , INDEX (grandParentTable) );
CREATE TABLE childTable ( id INT PRIMARY KEY , parentTable INT NOT NULL REFERENCES parentTable(id) , childTable_name VARCHAR NOT NULL , INDEX (parentTable) );
CREATE TABLE newkey ( id INT PRIMARY KEY , newkey_value VARCHAR NOT NULL );
CREATE TABLE childTable ( id INT PRIMARY KEY , parentTable INT NOT NULL REFERENCES parentTable (id) , newkey INT NOT NULL REFERENCES newkey (id) , childTable_name VARCHAR NOT NULL , INDEX (parentTable ) , index (newkey) );

GRANT SELECT, INSERT ON transanlys.childtable TO maxroach;
GRANT SELECT, INSERT ON transanlys.parenttable TO maxroach;
GRANT SELECT, INSERT ON transanlys.grandparenttable TO maxroach;
SHOW GRANTS ON transanlys.parenttable FOR maxroach;
——————-+—————+———————- | Table | User | Privileges |
——————-+—————+———————- | parentTable | maxroach | INSERT,SELECT |
——————-+—————+———————-

INSERT INTO grandparenttable ( id , grandParentTable_name ) VALUES ( unique_rowid() , ‘grandParentTable-1’ ) ; INSERT INTO parenttable ( id , grandParentTable , parentTable_name ) SELECT unique_rowid() , id , ‘parentTable-1’ FROM grandparenttable WHERE 1 AND grandParentTable_name = ‘grandParentTable-1’ ; INSERT INTO childtable ( id , parentTable , childTable_name ) SELECT unique_rowid() , id , ‘childTable-1’ FROM parenttable WHERE 1 AND parentTable_name = ‘parentTable-1’ ; SHOW INDEXES from childtable; SHOW CONSTRAINTS from childtable;

======================

SET database = ‘transanlys’;
DROP TABLE childtable;

CREATE TABLE childTable (id INT PRIMARY KEY, parentTable INT NOT NULL REFERENCES parentTable (id), newkey INT NOT NULL REFERENCES newkey (id), childTable_name VARCHAR NOT NULL, INDEX (parentTable ), index (newkey) );

DELETE FROM childtable; DELETE FROM parenttable; DELETE FROM grandparenttable; delete from newkey ;

GRANT SELECT, INSERT ON transanlys.childtable TO maxroach;

(run node script)

SELECT count(*) FROM parenttable
, newkey
, childtable
WHERE (newkey.id = childtable.newkey)
AND (parenttable.id = childtable.parenttable)
AND (newkey.id = 5);

===================================================
2017-04-07:
to install/run cockroachdb from docker (to get around the stupid -msse4.2 error)
curl -fsSL https://get.docker.com/ | sh ;
systemctl start docker;
systemctl status docker;
docker run hello-world ; ## test!
git clone https://github.com/cockroachdb/cockroach.git ;
git submodule update —init ;
(edit rocksdb/cgo_flags.go file and remove the -msse4.2 on line eight)
export GOPATH=~/go;
export PATH=$PATH/$GOPATH/bin ;
build/builder.sh make build ;
./cockroach version ;

============================================
2017-04-12 – create a deepstream cockroach table:

create table sequelizeTable
( sequelizeId SMALLSERIAL PRIMARY KEY
, teacherEmail VARCHAR
, sequelizeName VARCHAR
, sequelizeAddress VARCHAR
, transactionID VARCHAR
, createdAt TIMESTAMP
, updatedAt TIMESTAMP
) ;
============================================
FIREWALL ISSUE: to test:

yum —assumeyes install httpd ;
systemctl start httpd.service ;
echo ‘test apache test’ >/var/www/html/index.html ;

(see if page will load)

https://superuser.com/questions/794104/how-to-permanently-disable-firewall-in-red-hat-linux
service iptables save
service iptables stop
chkconfig iptables off

to enable default port 26257:
firewall-cmd —zone=public —add-port=26257/tcp —permanent ;
firewall-cmd —reload;
#########################################################

yum —assumeyes install jemalloc-devel ; ## ????? (in case you have to build) ???

======= LOAD-STRESS TEST ===========================

CREATE TABLE alternateParent
( id INT PRIMARY KEY
, alternateParent_value VARCHAR NOT NULL
);

CREATE TABLE grandParentTable
( id INT PRIMARY KEY
, grandParentTable_name VARCHAR NOT NULL
);

CREATE TABLE parentTable
( id INT PRIMARY KEY
, grandParentTable INT NOT NULL REFERENCES grandParentTable(id) ON DELETE CASCADE ON UPDATE CASCADE
, parentTable_name VARCHAR NOT NULL
, INDEX (grandParentTable)
);

CREATE TABLE childTable
( id INT PRIMARY KEY
, parentTable INT NOT NULL REFERENCES parentTable (id) ON DELETE CASCADE ON UPDATE CASCADE
, alternateParent INT NOT NULL REFERENCES alternateParent (id) ON DELETE CASCADE ON UPDATE CASCADE
, childTable_name VARCHAR NOT NULL
, INDEX (parentTable )
, index (alternateParent)
);

cat loadGrandParent.js

let maxGrandParent = 100;
let grandParentKey= 0;
for ( grandparentIncr=1; grandparentIncr <= maxGrandParent; grandparentIncr++ ) { grandParentKey++; var grandparentData = ‘Grandparent Value: ‘ + grandParentKey;
console.log(`INSERT INTO “grandparenttable” (“id”,“grandparenttable_name”) VALUES (${grandParentKey}, ‘${grandparentData}’); `);
}

cat loadParent.js

let maxParent = 50;
let parentKey = 0;
for ( var grandParentIncr = 1; grandParentIncr <= 100; grandParentIncr++ ) { grandParentData = ‘Grandparent Value: ‘ + grandParentIncr; for ( var parentIncr = 1; parentIncr <= maxParent; parentIncr++ ) { parentKey++; var parentData = grandParentData + ‘ Parent Data: ‘ + parentKey;
console.log(`INSERT INTO “parenttable” (“id”,“grandparenttable”,“parenttable_name”) VALUES (${parentKey}, ${grandParentIncr}, ‘${parentData}’); `); }

}

cat loadAlternateParent.js let maxAlternateParent = 10000; let alternateParentKey= 0; for ( alternateparentIncr=1; alternateparentIncr <= maxAlternateParent; alternateparentIncr++ ) { alternateParentKey++; var saveKey = alternateParentKey * 100; var altData = ‘Alternative Parent! ‘ + saveKey; console.log(`INSERT INTO “alternateparent” (“id”,“alternateparent_value”) VALUES (${saveKey}, ‘${altData}’); `); }

cat loadChild.js
let maxChild = 20;
let childKey = 0;
for ( var parentIncr = 1; parentIncr <= 5000; parentIncr++ ) { for ( var childIncr = 1; childIncr <= maxChild; childIncr++ ) { childKey++; var childData = ‘Parent data: ‘ + parentIncr + ‘ Child Data! ‘ ; var alternateParentKey = (Math.floor(childKey / 10)+1) * 100 ;
console.log(`INSERT INTO “childtable” (“id”,“parenttable”,“alternateparent”,“childtable_name”) VALUES (${childKey}, ${parentIncr}, ${alternateParentKey}, ‘${childData}’); `); }
}

WITH SEQUELIZE CALLS:
cat loadChild.js
const sleep = require(‘sleep’);

const Sequelize = require(‘sequelize’);
const sequelize = new Sequelize(‘bank’, ‘feathersuser’, ‘aaaaaa’, { host: ’159.203.111.167’, port: 26257, dialect: ‘postgres’, dialectOptions: { ssl: true }, operatorsAliases: false, pool: { max: 5, min: 0, acquire: 30000, idle: 10000 }
});

sequelize .authenticate() .then(() => { console.log(‘Connection has been established successfully.’); }) .catch(err => { console.error(‘Unable to connect to the database:’, err); });

let maxChild = 10;
let childKey = 0;

sequelize.query(“SELECT id, parentTable_name FROM parentTable WHERE 1=1”).spread( (results, metadata) => { results.forEach((element, index, array) => { console.log(element.id); console.log(element.parenttable_name); for ( var childIncr = 1; childIncr <= maxChild; childIncr++ ) { childKey++; var childData = element.parenttable_name + ‘ Child Data: ‘ + childKey; sequelize.query(`INSERT INTO childTable (id, parentTable, alternateParent, childTable_name) VALUES (${childKey}, ${element.id}, 12345, ‘${childData}’); `); } })
})

================================================

Mark Edwards

,

---

« Older Newer »

Manage