Solr: Starting Solr 4.7 for development purposes. 
[acool@localhost solr-4.7.0]$ date
Fri 25 Sep 2020 09:33:39 AM PDT
[acool@localhost solr-4.7.0]$
[acool@localhost solr-4.7.0]$
[acool@localhost solr-4.7.0]$ sudo yum install java-1.8.0-openjdk
...
[acool@localhost solr-4.7.0]$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
[acool@localhost solr-4.7.0]$
[acool@localhost solr-4.7.0]$
[acool@localhost solr-4.7.0]$ ll
total 460
-rw-r--r--. 1 acool acool 362968 Feb 21 2014 CHANGES.txt
drwxr-xr-x. 12 acool acool 4096 Feb 21 2014 contrib
drwxrwxr-x. 4 acool acool 4096 Feb 1 2020 dist
drwxrwxr-x. 17 acool acool 4096 Feb 1 2020 docs
drwxr-xr-x. 15 acool acool 4096 Feb 2 2020 example
drwxr-xr-x. 2 acool acool 32768 Feb 1 2020 licenses
-rw-r--r--. 1 acool acool 12646 Feb 18 2014 LICENSE.txt
-rw-r--r--. 1 acool acool 26762 Feb 18 2014 NOTICE.txt
-rw-r--r--. 1 acool acool 5344 Feb 18 2014 README.txt
-rw-r--r--. 1 acool acool 686 Feb 18 2014 SYSTEM_REQUIREMENTS.txt
[acool@localhost solr-4.7.0]$
[acool@localhost solr-4.7.0]$
[acool@localhost solr-4.7.0]$ # Starting server
[acool@localhost solr-4.7.0]$ cd example/
[acool@localhost example]$
[acool@localhost example]$ java -jar start.jar
...
[acool@localhost example]$
[acool@localhost example]$ # http://localhost:8983/solr should now render the dashboard
[acool@localhost example]$


12/7/2020 Sample query:
http://app01.example.com:8098/search/query/article_index?sort=score DESC
&q={!edismax}how to become a millionaire
&qf=authorName^6 objectId^4 headline^2 deck
&fq={!lucene}
edition:us
AND statusId:4
AND objectTypeId:(1 2 4 12 15)
AND publicationDateISO8601:[NOW-10YEAR TO NOW]
&qs=5
&bq=publicationDateISO8601:[NOW-2YEAR TO NOW]
&fl=*,score
&hl=true
&mm=3<80%
&wt=json
&rows=20
&start=0
&df=entspellcheck
&spellcheck=true
&spellcheck.q="how to become a millionaire"~10
&spellcheck.collate=true
&spellcheck.maxCollations=30
&spellcheck.maxCollationTries=30
&spellcheck.maxCollationEvaluations=30
&spellcheck.collateExtendedResults=true
&spellcheck.collateMaxCollectDocs=30
&spellcheck.count=10
&spellcheck.extendedResults=true
&spellcheck.maxResultsForSuggest=5
&spellcheck.alternativeTermCount=10
&spellcheck.accuracy=0.5


[ view entry ] ( 723 views )   |  print article
Generate wildcard TLS certificate with Let's Encrypt and Acme.sh 
// EXPORT DNS PROVIDER API KEYS
export GD_Key="XXXXXXXXX"
export GD_Secret="YYYYYYYY"

 # install acme.sh
[root@cia ~]#curl https://get.acme.sh | sh
...
[root@cia ~] # generate certificate
[root@cia ~] acme.sh --issue -d angelcool.net -d '*.angelcool.net' --dns dns_gd
[root@cia ~]
[root@cia ~] # install certificate where it can be read by nginx/apache server.
[root@cia ~] acme.sh --install-cert -d angelcool.net --key-file /etc/pki/tls/certs/wildcard-angelcool.net.key --fullchain-file /etc/pki/tls/certs/wildcard-angelcool.net.cert --reloadcmd "service nginx force-reload"
[root@cia ~]
[root@cia ~] # configure acme.sh auto upgrade
[root@cia ~] acme.sh --upgrade --auto-upgrade

Docs:
https://github.com/acmesh-official/acme.sh

The script also adds an entry to crontab for auto renewal.

Good luck!

[ view entry ] ( 663 views )   |  print article
Docker: Swarm Demo 
In this demo I:

a) create 3 CentOS 7 vagrant VMs
b) install docker in each VM
c) create a Docker Swarm (Swarm mode) with one manager and 2 workers
d) create a service with nginx image, update the service to use httpd image and update replicas memory limit

[acool@localhost docker-swarm-demo]$ date
Sat 22 Feb 2020 04:35:36 PM PST
[acool@localhost docker-swarm-demo]$ cat /etc/redhat-release
Fedora release 31 (Thirty One)
[acool@localhost docker-swarm-demo]$ vagrant --version
Vagrant 2.2.6
[acool@localhost docker-swarm-demo]$ tree
.
├── vagrant-box-1
│   └── Vagrantfile
├── vagrant-box-2
│   └── Vagrantfile
└── vagrant-box-3
└── Vagrantfile

3 directories, 3 files
[acool@localhost docker-swarm-demo]$
[acool@localhost docker-swarm-demo]$ cd vagrant-box-1
[acool@localhost vagrant-box-1]$ vagrant up
...
[acool@localhost vagrant-box-1]$ vagrant ssh
[vagrant@box1 ~]$
[vagrant@box1 ~]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[vagrant@box1 ~]$
[vagrant@box1 ~]$ ip address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:de:6e:43 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.102/24 brd 192.168.122.255 scope global noprefixroute dynamic eth0
valid_lft 3307sec preferred_lft 3307sec
inet6 fe80::5054:ff:fede:6e43/64 scope link
valid_lft forever preferred_lft forever
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo yum install docker
...
[vagrant@box1 ~]$ sudo systemctl start docker
[vagrant@box1 ~]$ sudo docker version
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-108.git4ef4b30.el7.centos.x86_64
Go version: go1.10.3
Git commit: 4ef4b30/1.13.1
Built: Tue Jan 21 17:16:25 2020
OS/Arch: linux/amd64

Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-108.git4ef4b30.el7.centos.x86_64
Go version: go1.10.3
Git commit: 4ef4b30/1.13.1
Built: Tue Jan 21 17:16:25 2020
OS/Arch: linux/amd64
Experimental: false
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ # disable firewall for the sake of keeping this demo simple
[vagrant@box1 ~]$ sudo systemctl disable firewalld.service
[vagrant@box1 ~]$

[acool@localhost docker-swarm-demo]$ # create box2 and box3 via vagrant

[vagrant@box2 ~]$
[vagrant@box2 ~]$ # install and start docker as previously shown in box1
[vagrant@box2 ~]$ # disable firewall as previously shown in box1
[vagrant@box2 ~]$
[vagrant@box2 ~]$ ip address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:e1:c4:f9 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.27/24 brd 192.168.122.255 scope global noprefixroute dynamic eth0
valid_lft 3436sec preferred_lft 3436sec
inet6 fe80::5054:ff:fee1:c4f9/64 scope link
valid_lft forever preferred_lft forever
[vagrant@box2 ~]$

[vagrant@box3 ~]$
[vagrant@box3 ~]$ # install and start docker as previously shown in box1
[vagrant@box3 ~]$ # disable firewall as previously shown in box1
[vagrant@box3 ~]$
[vagrant@box3 ~]$ ip address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:18:5a:8c brd ff:ff:ff:ff:ff:ff
inet 192.168.122.88/24 brd 192.168.122.255 scope global noprefixroute dynamic eth0
valid_lft 3323sec preferred_lft 3323sec
inet6 fe80::5054:ff:fe18:5a8c/64 scope link
valid_lft forever preferred_lft forever
[vagrant@box3 ~]$
[vagrant@box3 ~]$
[vagrant@box3 ~]$ # make sure all boxes can ping each other
[vagrant@box3 ~]$ ping -c2 192.168.122.102
PING 192.168.122.102 (192.168.122.102) 56(84) bytes of data.
64 bytes from 192.168.122.102: icmp_seq=1 ttl=64 time=0.562 ms
64 bytes from 192.168.122.102: icmp_seq=2 ttl=64 time=0.619 ms

--- 192.168.122.102 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.562/0.590/0.619/0.037 ms
[vagrant@box3 ~]$
[vagrant@box3 ~]$
[vagrant@box3 ~]$ ping -c2 192.168.122.27
PING 192.168.122.27 (192.168.122.27) 56(84) bytes of data.
64 bytes from 192.168.122.27: icmp_seq=1 ttl=64 time=0.457 ms
64 bytes from 192.168.122.27: icmp_seq=2 ttl=64 time=0.312 ms

--- 192.168.122.27 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.312/0.384/0.457/0.075 ms
[vagrant@box3 ~]$



The gist of this demo:

[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker swarm init --advertise-addr 192.168.122.102
Swarm initialized: current node (325hn4zrumoinjslhiw3p9c1j) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join \
--token SWMTKN-1-1qm592qpo4j2ka5nxqx98vizi6z9dtag4rou49zxvrr7rww72g-agsgzbalcyw0c7saupqvk90sl \
192.168.122.102:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$


[vagrant@box2 ~]$
[vagrant@box2 ~]$
[vagrant@box2 ~]$ sudo docker swarm join \
> --token SWMTKN-1-1qm592qpo4j2ka5nxqx98vizi6z9dtag4rou49zxvrr7rww72g-agsgzbalcyw0c7saupqvk90sl \
> 192.168.122.102:2377
This node joined a swarm as a worker.
[vagrant@box2 ~]$
[vagrant@box2 ~]$


[vagrant@box3 ~]
[vagrant@box3 ~]
[vagrant@box3 ~]$ sudo docker swarm join \
> --token SWMTKN-1-1qm592qpo4j2ka5nxqx98vizi6z9dtag4rou49zxvrr7rww72g-agsgzbalcyw0c7saupqvk90sl \
> 192.168.122.102:2377
This node joined a swarm as a worker.
[vagrant@box3 ~]
[vagrant@box3 ~]


[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
325hn4zrumoinjslhiw3p9c1j * box1 Ready Active Leader
78uis92n6z7lg2glmsbkzuag0 box3 Ready Active
ehjej7f2ol2svf4nci0k9x4if box2 Ready Active
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ # lets create a service
[vagrant@box1 ~]$ sudo docker service create --replicas 5 -p 80:80 --name web nginx
ytr9c94iieku7akjlp1gsq8mt
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker service ls
ID NAME MODE REPLICAS IMAGE
ytr9c94iieku web replicated 0/5 nginx:latest
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker service ps web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
n4n6xun4dlmn web.1 nginx:latest box2 Running Preparing 20 seconds ago
ks1cnh8oko1r web.2 nginx:latest box3 Running Running less than a second ago
lhqha4nd2sj2 web.3 nginx:latest box1 Running Preparing 20 seconds ago
dy48ok6b1clb web.4 nginx:latest box2 Running Preparing 20 seconds ago
81dkfenyjrbz web.5 nginx:latest box3 Running Running less than a second ago
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ # nginx should be available via any box ip in your browser: http://192.168.122.88/, http://192.168.122.27/ or http://192.168.122.102/
[vagrant@box1 ~]$
[vagrant@box1 ~]$ # we can try curl too
[vagrant@box1 ~]$
[vagrant@box1 ~]$ curl 192.168.122.102
...
[vagrant@box1 ~]$ curl 192.168.122.88
...
[vagrant@box1 ~]$ curl 192.168.122.27
...

[vagrant@box2 ~]$ # lets see how much memory each replica is assigned
[vagrant@box2 ~]$
[vagrant@box2 ~]$ sudo docker stats --no-stream
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
19467a26755f 0.00% 1.402 MiB / 487.1 MiB 0.29% 8.65 kB / 9.52 kB 0 B / 0 B 2
427cf3658a03 0.00% 1.383 MiB / 487.1 MiB 0.28% 4.65 kB / 2.86 kB 1.83 MB / 0 B 2
[vagrant@box2 ~]$
[vagrant@box2 ~]$

[vagrant@box1 ~]$ # lets update each replica memory limit to 250M
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker service update --limit-memory 250M web
web
[vagrant@box1 ~]$
[vagrant@box1 ~]$


[vagrant@box3 ~]$ # verify memory adjustment
[vagrant@box3 ~]$
[vagrant@box3 ~]$ sudo docker stats --no-stream
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
8990a7fa2489 0.00% 1.375 MiB / 250 MiB 0.55% 2.19 kB / 1.31 kB 0 B / 0 B 2
e6d71ec0caf8 0.00% 1.375 MiB / 250 MiB 0.55% 2.62 kB / 1.31 kB 0 B / 0 B 2
[vagrant@box3 ~]$

[vagrant@box1 ~]$
[vagrant@box1 ~]$ # lets update our service with a different image, we'll try httpd instead of nginx :)
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker service update --image httpd web
web
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker service ps web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
opf7ks9q5rj4 web.1 httpd:latest box2 Running Starting less than a second ago
sbbs4g9shkzm \_ web.1 nginx:latest box2 Shutdown Shutdown 5 seconds ago
n4n6xun4dlmn \_ web.1 nginx:latest box2 Shutdown Shutdown 3 minutes ago
vvv6018iym4j web.2 nginx:latest box3 Running Running 3 minutes ago
ks1cnh8oko1r \_ web.2 nginx:latest box3 Shutdown Shutdown 3 minutes ago
nl0oddf682d3 web.3 nginx:latest box1 Running Running 3 minutes ago
lhqha4nd2sj2 \_ web.3 nginx:latest box1 Shutdown Shutdown 3 minutes ago
xgcgisnlz5kd web.4 nginx:latest box1 Running Running 3 minutes ago
dy48ok6b1clb \_ web.4 nginx:latest box2 Shutdown Shutdown 3 minutes ago
jw9btp4h734o web.5 nginx:latest box3 Running Running 3 minutes ago
81dkfenyjrbz \_ web.5 nginx:latest box3 Shutdown Shutdown 3 minutes ago
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker service ls
ID NAME MODE REPLICAS IMAGE
ytr9c94iieku web replicated 5/5 httpd:latest
[vagrant@box1 ~]$
[vagrant@box1 ~]$ # all nodes should render apache httpd welcome message now!
[vagrant@box1 ~]$
[vagrant@box1 ~]$ # lets increase the number of replicas
[vagrant@box1 ~]$ sudo docker service scale web=8
web scaled to 8
[vagrant@box1 ~]$
[vagrant@box1 ~]$ sudo docker service ls
ID NAME MODE REPLICAS IMAGE
ytr9c94iieku web replicated 8/8 httpd:latest
[vagrant@box1 ~]$
[vagrant@box1 ~]$ exit
logout
Connection to 192.168.122.102 closed.
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$


Enjoy!

[ view entry ] ( 751 views )   |  print article
Vagrant: Creating two CentOS VMs and ping each other. 
[acool@localhost ~]$ date
Fri 21 Feb 2020 02:53:59 PM PST
[acool@localhost ~]$
[acool@localhost ~]$ cat /etc/redhat-release
Fedora release 31 (Thirty One)
[acool@localhost ~]$
[acool@localhost ~]$ sudo dnf install vagrant-libvirt
...
[acool@localhost ~]$ vagrant --version
Vagrant 2.2.6
[acool@localhost ~]$
[acool@localhost ~]$ mkdir vagrant-box-1
[acool@localhost ~]$ cd vagrant-box-1/
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
[acool@localhost vagrant-box-1]
[acool@localhost vagrant-box-1]$ vagrant up
...
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$ vagrant status
Current machine states:

default running (libvirt)

The Libvirt domain is running. To stop this machine, you can run
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$ # you can now visually access this VM via "Boxes" which is like virt-manager
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$ # or you can ssh into this box via vagrant
[acool@localhost vagrant-box-1]$ vagrant ssh
Last login: Fri Feb 21 23:05:54 2020 from 192.168.122.1
[vagrant@localhost ~]$
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[vagrant@localhost ~]$
[vagrant@localhost ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:7f:e1:0c brd ff:ff:ff:ff:ff:ff
inet 192.168.122.194/24 brd 192.168.122.255 scope global noprefixroute dynamic eth0
valid_lft 3068sec preferred_lft 3068sec
inet6 fe80::5054:ff:fe7f:e10c/64 scope link
valid_lft forever preferred_lft forever
[vagrant@localhost ~]$
[vagrant@localhost ~]$
[vagrant@localhost ~]$ exit
logout
Connection to 192.168.122.194 closed.
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$
[acool@localhost vagrant-box-1]$ # lets create another box
[acool@localhost vagrant-box-1]$ cd ../ && mkdir vagrant-box-2
[acool@localhost ~]$
[acool@localhost ~]$ cd vagrant-box-2
[acool@localhost vagrant-box-2]$
[acool@localhost vagrant-box-2]$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
[acool@localhost vagrant-box-2]$
[acool@localhost vagrant-box-2]$ vagrant up
...
[acool@localhost vagrant-box-2]$
[acool@localhost vagrant-box-2]$ vagrant ssh
Last login: Fri Feb 21 23:17:20 2020 from 192.168.122.1
[vagrant@localhost ~]$
[vagrant@localhost ~]$ ip a show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:69:74:25 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.27/24 brd 192.168.122.255 scope global noprefixroute dynamic eth0
valid_lft 2908sec preferred_lft 2908sec
inet6 fe80::5054:ff:fe69:7425/64 scope link
valid_lft forever preferred_lft forever
[vagrant@localhost ~]$
[vagrant@localhost ~]$ # let's ping box-1 from box-2
[vagrant@localhost ~]$ ping -c 2 192.168.122.194
PING 192.168.122.194 (192.168.122.194) 56(84) bytes of data.
64 bytes from 192.168.122.194: icmp_seq=1 ttl=64 time=0.589 ms
64 bytes from 192.168.122.194: icmp_seq=2 ttl=64 time=0.548 ms

--- 192.168.122.194 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.548/0.568/0.589/0.031 ms
[vagrant@localhost ~]$
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[vagrant@localhost ~]$ exit
logout
Connection to 192.168.122.27 closed.
[acool@localhost vagrant-box-2]$
[acool@localhost vagrant-box-2]$
[acool@localhost vagrant-box-2]$
[acool@localhost vagrant-box-2]$# le's cleanup our tests
[acool@localhost vagrant-box-2]$ vagrant destroy
...
[acool@localhost vagrant-box-1]$ vagrant destroy


[ view entry ] ( 738 views )   |  print article
Riak: Enabling Solr Search 
General notes about Riak Search -ac

# install java JRE (so solr can run)
[entadmin@dev3 equeuelib]$ sudo yum install java-1.8.0-openjdk

# enable it in riak.conf: search=on
# reload/restart riak as needed

#create index (can also be done via PHP)
[aesteban@localhost ansible]$ curl -X PUT riak.example.com:8098/search/index/story_index

# associate index to bucket (can also be done via PHP)
[aesteban@localhost ansible]$ curl -X PUT riak.example.com:8098/buckets/story/props -H'content-type:application/json' -d'{"props":{"search_index":"story_index"}}'

# verify it by viewing bucket props, search for 'search_index'
riak.example.com:8098/buckets/story/props

# add indexable fields to a Story object per se
eg: authorId_i and publicationDate_dt

# query it !
riak.example.com:8098/search/query/story_index?wt=json&q=authorId_i:8144

# it returns all story keys associated with that author.

# looks like there's sort capabilities available too:
riak.example.com:8098/search/query/story_index?wt=json&q=authorId_i:8144&sort=publicationDate_dt%20desc

# by default it seems to put a limit of 10 rows, we can change that...
riak.example.com:8098/search/query/story_index?wt=json&q=authorId_i:8144&sort=publicationDate_dt%20desc&rows=50

# Solr dashboard riak.example.com:8093/internal_solr/#/story_index


PHP

$indexes = [
[
"name" => "story_index",
"bucket" => "story"
]
];

$node = (new \Basho\Riak\Node\Builder)
->atHost('riak host')
->onPort('riak port'))
->build();

$riak = new \Basho\Riak ([$node]);

foreach ($indexes as $index)
{
// creates index
$response = (new \Basho\Riak\Command\Builder\Search\StoreIndex($riak))
->withName( $index['name'] )
->usingSchema('_yz_default')
->build()
->execute();
// associates index with bucket
(new \Basho\Riak\Command\Builder\Search\AssociateIndex($riak))
->withName( $index['name'] )
->buildBucket($index['bucket'])
->build()
->execute();
}



Docs:
http://docs.basho.com/riak/kv/2.2.3/dev ... ge/search/
https://docs.riak.com/riak/kv/latest/developing/usage/search/index.html

Default schema:
https://raw.githubusercontent.com/basho/yokozuna/develop/priv/default_schema.xml


12/7/2020

Sample query
$query = [
// "defType" => "edismax", // query parser
"sort" => "score DESC", // override default score sorting
"q" => "{!edismax}{$parameters['phrase']}", // query
"qf" => "authorName^6 objectId^4 headline^2 deck", // query fields
"fq" => "{!lucene}
edition:{$parameters['edition']}
AND statusId:4
AND objectTypeId:(1 2 4 12 15)
AND publicationDateISO8601:[NOW-10YEAR TO NOW]", // filter query
"qs" => "5", // query phrase slop
"bq" => "publicationDateISO8601:[NOW-2YEAR TO NOW]", // boost query
"fl" => "*,score", // field list
"hl" => "true", // highlight
"mm" => "3<80%", // minimum match
"wt" => "json", // response writer
"rows" => $rows, // rows
"start" => $start, // offset

// spell check parameters
"df" => "entspellcheck",
"spellcheck" => "true" ,
"spellcheck.q" => "\"{$parameters['phrase']}\"~10" , // proximity added
// "spellcheck.build" => "true" ,
"spellcheck.collate" => "true" ,
"spellcheck.maxCollations" => "30" ,
"spellcheck.maxCollationTries" => "30" ,
"spellcheck.maxCollationEvaluations" => "30" ,
"spellcheck.collateExtendedResults" => "true" ,
"spellcheck.collateMaxCollectDocs" => "30" ,
"spellcheck.count" => "10" ,
// "spellcheck.dictionary" => 'wordbreak' ,
"spellcheck.extendedResults" => "true" ,
// "spellcheck.onlyMorePopular" => "true" ,
"spellcheck.maxResultsForSuggest" => "5" ,
"spellcheck.alternativeTermCount" => "10" ,
// "spellcheck.reload" => "true",
"spellcheck.accuracy" => "0.5" ,
];


Which will be something like this:
http://app01.example.com:8098/search/query/article_index?sort=score DESC
&q={!edismax}how to become a millionaire
&qf=authorName^6 objectId^4 headline^2 deck
&fq={!lucene}
edition:us
AND statusId:4
AND objectTypeId:(1 2 4 12 15)
AND publicationDateISO8601:[NOW-10YEAR TO NOW]
&qs=5
&bq=publicationDateISO8601:[NOW-2YEAR TO NOW]
&fl=*,score
&hl=true
&mm=3<80%
&wt=json
&rows=20
&start=0
&df=entspellcheck
&spellcheck=true
&spellcheck.q="how to become a millionaire"~10
&spellcheck.collate=true
&spellcheck.maxCollations=30
&spellcheck.maxCollationTries=30
&spellcheck.maxCollationEvaluations=30
&spellcheck.collateExtendedResults=true
&spellcheck.collateMaxCollectDocs=30
&spellcheck.count=10
&spellcheck.extendedResults=true
&spellcheck.maxResultsForSuggest=5
&spellcheck.alternativeTermCount=10
&spellcheck.accuracy=0.5


[ view entry ] ( 760 views )   |  print article
BASH Fun: Running a command at a specific time using 'at'. 
[acool@acool2 ~]$ sudo yum install at
...
[acool@acool2 ~]$ sudo systemctl start atd
[acool@acool2 ~]$ sudo systemctl enable atd


[acool@acool2 ~]$ date
Mon Apr 15 16:09:15 PDT 2019
[acool@acool2 ~]$
[acool@acool2 ~]$ echo 'date >> at-fun.txt' | at now + 1 minute
job 79 at Mon Apr 15 16:10:00 2019
[acool@acool2 ~]$
[acool@acool2 ~]$ atq
79 Mon Apr 15 16:10:00 2019 a acool
[acool@acool2 ~]$
[acool@acool2 ~]$ cat at-fun.txt
Mon Apr 15 16:10:00 PDT 2019


[acool@acool2 ~]$
[acool@acool2 ~]$ cat at-fun.txt
[acool@acool2 ~]$ echo 'php -v >> at-fun.txt' | at 4:16 PM April 15 2019
job 84 at Mon Apr 15 16:16:00 2019
[acool@acool2 ~]$
[acool@acool2 ~]$ date
Mon Apr 15 16:15:21 PDT 2019
[acool@acool2 ~]$ atq
84 Mon Apr 15 16:16:00 2019 a acool
[acool@acool2 ~]$
[acool@acool2 ~]$ cat at-fun.txt
PHP 7.0.27 (cli) (built: Apr 4 2018 13:48:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
[acool@acool2 ~]$

https://stackoverflow.com/questions/55524769

[ view entry ] ( 860 views )   |  print article
Memcached: Looping through a set of servers to delete a key. 
Cool way to make sure a key does not exist in a group of memcached servers. Handy when troubleshooting or when cached data needs a purge. Tested:
[aesteban@localhost ~]$ 
[aesteban@localhost ~]$ for i in {1..6};do ( echo 'delete events.slick-range') | nc server-${i}.example.com 11211; done;
NOT_FOUND
NOT_FOUND
NOT_FOUND
DELETED
NOT_FOUND
NOT_FOUND
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$

Try adding a delay if the above doesn't seem to work:
[aesteban@localhost ~]$ 
[aesteban@localhost ~]$ for i in {1..6};do ( sleep 2; echo 'delete events.slick-range') | nc -d 2 server-${i}.example.com 11211; done;
NOT_FOUND
NOT_FOUND
NOT_FOUND
DELETED
NOT_FOUND
NOT_FOUND
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$




BONUS (6/12/2019) - Find out the expiration date for a key:
(sleep 1; echo "stats cachedump 7 0"; sleep 1; echo "quit";) | nc www-server01.example.com  11211 | grep 'memc.sess.tpnm0jd8aottlturb0ml510sd0'


Increase/decrease the slab (seven) number as need until the key is found.

[ view entry ] ( 837 views )   |  print article
MySQL Fun: Master-Slave Replication Example With Docker 
# for historical purposes:
[acool@localhost ~]$ date
Thu Jan 24 18:44:23 PST 2019
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ cat /etc/redhat-release
Fedora release 28 (Twenty Eight)
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker --version
Docker version 1.13.1, build 1556cce-unsupported
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker network create mysql-cluster
72af69d434e8cefa031555d2ba6039c2260aa73fe27df380b9454e3790c89337
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker network ls
NETWORK ID NAME DRIVER SCOPE
5dfcb11eac94 bridge bridge local
c146b3afd86e host host local
72af69d434e8 mysql-cluster bridge local
1299a7349094 none null local
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ tree mysql-fun
mysql-fun
├── master
│   ├── config
│   │   └── mysqld.cnf
│   └── data
└── slave
├── config
│   └── mysqld.cnf
└── data

6 directories, 2 files
[acool@localhost ~]$
[acool@localhost ~]$ cat mysql-fun/master/config/mysqld.cnf
[mysqld]
server_id = 1
log_bin = /var/log/mysql/mysql-bin-master
[acool@localhost ~]$
[acool@localhost ~]$ cat mysql-fun/slave/config/mysqld.cnf
[mysqld]
server_id = 2
relay_log = /var/log/mysql/mysql-relay-slave-bin
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ getenforce
Permissive
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql 5.7 5cd9bd4c8a5e 3 days ago 372 MB
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker run -v /home/acool/mysql-fun/slave/config:/etc/mysql/conf.d -v /home/acool/mysql-fun/slave/data/:/var/lib/mysql/:rw --detach --network mysql-cluster --name=slave-mysql --env="MYSQL_ROOT_PASSWORD=temp123" mysql:5.7
599f302193cda964ada60d42e90324705c8d5b578c805c57f395958b97ed6702
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker run -v /home/acool/mysql-fun/master/config:/etc/mysql/conf.d -v /home/acool/mysql-fun/master/data/:/var/lib/mysql/:rw --detach --network mysql-cluster --name=master-mysql --env="MYSQL_ROOT_PASSWORD=temp123" mysql:5.7
32d0c2ecc7e6d17ae99ebabd6c75f0566846d60451bfb953b747b767dda92129
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32d0c2ecc7e6 mysql:5.7 "docker-entrypoint..." 15 seconds ago Up 14 seconds 3306/tcp, 33060/tcp master-mysql
599f302193cd mysql:5.7 "docker-entrypoint..." 46 seconds ago Up 44 seconds 3306/tcp, 33060/tcp slave-mysql
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker inspect master-mysql |grep \"IPAddress\"
"IPAddress": "",
"IPAddress": "172.18.0.3",
[acool@localhost ~]$
[acool@localhost ~]$ sudo docker inspect slave-mysql |grep \"IPAddress\"
"IPAddress": "",
"IPAddress": "172.18.0.2",
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ mysql -h 172.18.0.3 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> CREATE USER 'replication_user'@'%' IDENTIFIED BY 'ru_temp123';
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW MASTER STATUS;
+-------------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------------+----------+--------------+------------------+-------------------+
| mysql-bin-master.000003 | 763 | | | |
+-------------------------+----------+--------------+------------------+-------------------+
1 row in set (0.01 sec)

mysql>
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ mysql -h 172.18.0.2 -p -u root
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> SELECT @@server_id;
+-------------+
| @@server_id |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)

mysql> CHANGE MASTER TO MASTER_HOST = '172.18.0.3', MASTER_USER = 'replication_user', MASTER_PASSWORD = 'ru_temp123', MASTER_LOG_FILE = 'mysql-bin-master.000003', MASTER_LOG_POS = 763;
Query OK, 0 rows affected, 1 warning (0.10 sec)

mysql> START SLAVE;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW SLAVE STATUS\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.18.0.3
Master_User: replication_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin-master.000003
Read_Master_Log_Pos: 763
Relay_Log_File: mysql-relay-slave-bin.000002
Relay_Log_Pos: 327
Relay_Master_Log_File: mysql-bin-master.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 763
Relay_Log_Space: 540
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 60c1469e-2049-11e9-89ca-0242ac120003
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)

ERROR:
No query specified

mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
[acool@localhost ~]$
[acool@localhost ~]$ # create new database in master
[acool@localhost ~]$ mysql -h 172.18.0.3 -p -u root
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> CREATE DATABASE users;
Query OK, 1 row affected (0.01 sec)

mysql>
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| users |
+--------------------+
5 rows in set (0.00 sec)

mysql> exit
Bye
[acool@localhost ~]$ # confirm database creation was replicated to slave
[acool@localhost ~]$
[acool@localhost ~]$ mysql -h 172.18.0.2 -p -u root
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| users |
+--------------------+
5 rows in set (0.00 sec)

mysql> exit
Bye
[acool@localhost ~]$
[acool@localhost ~]$ # Exercise finished! SQL statements are being replicated from master to slave :)
[acool@localhost ~]$


[ view entry ] ( 846 views )   |  print article
Docker: CentOS 7 Fun. 
[aesteban@localhost ~]$ 
[aesteban@localhost ~]$
[aesteban@localhost ~]$ cat /etc/redhat-release
Fedora release 24 (Twenty Four)
[aesteban@localhost ~]$
[aesteban@localhost ~]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[aesteban@localhost ~]$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[aesteban@localhost ~]$
[aesteban@localhost ~]$ sudo docker pull centos:7
Trying to pull repository docker.io/library/centos ...
7: Pulling from docker.io/library/centos

a02a4930cb5d: Pull complete
Digest: sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426
Status: Downloaded newer image for docker.io/centos:7
[aesteban@localhost ~]$
[aesteban@localhost ~]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos 7 1e1148e4cc2c 6 days ago 201.8 MB
[aesteban@localhost ~]$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[aesteban@localhost ~]$ sudo docker run -d --privileged -p 80:80 docker.io/centos:7 /sbin/init
f0faf6197fbc696796333bfc81f25d537a1aba170b81f2076010222e84284b36
[aesteban@localhost ~]$
[aesteban@localhost ~]$ sudo docker exec -it f0faf6197fbc696796333bfc81f25d537a1aba170b81f2076010222e84284b36 bash
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# yum install epel-release
...
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# yum install nginx
...
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# systemctl start nginx
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2018-12-12 02:55:32 UTC; 4s ago
Process: 2643 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 2642 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 2641 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 2644 (nginx)
CGroup: /system.slice/docker-f0faf6197fbc696796333bfc81f25d537a1aba170b81f2076010222e84284b36.scope/system.slice/nginx.service
├─2644 nginx: master process /usr/sbin/nginx
├─2645 nginx: worker process
├─2646 nginx: worker process
├─2647 nginx: worker process
└─2648 nginx: worker process

Dec 12 02:55:31 f0faf6197fbc systemd[1]: Starting The nginx HTTP and reverse proxy server...
Dec 12 02:55:31 f0faf6197fbc nginx[2642]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 12 02:55:31 f0faf6197fbc nginx[2642]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Dec 12 02:55:32 f0faf6197fbc systemd[1]: Started The nginx HTTP and reverse proxy server.
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# exit
exit
[aesteban@localhost ~]$
[aesteban@localhost ~]$ # localhost should now be accessible in browser
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$ sudo docker exec -it f0faf6197fbc systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2018-12-12 02:55:32 UTC; 1min 57s ago
Process: 2643 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 2642 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 2641 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 2644 (nginx)
CGroup: /system.slice/docker-f0faf6197fbc696796333bfc81f25d537a1aba170b81f2076010222e84284b36.scope/system.slice/nginx.service
├─2644 nginx: master process /usr/sbin/nginx
├─2645 nginx: worker process
├─2646 nginx: worker process
├─2647 nginx: worker process
└─2648 nginx: worker process

Dec 12 02:55:31 f0faf6197fbc systemd[1]: Starting The nginx HTTP and reverse proxy server...
Dec 12 02:55:31 f0faf6197fbc nginx[2642]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 12 02:55:31 f0faf6197fbc nginx[2642]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Dec 12 02:55:32 f0faf6197fbc systemd[1]: Started The nginx HTTP and reverse proxy server.
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$ sudo docker exec -it f0faf6197fbc bash
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# systemctl status postfix
Unit postfix.service could not be found.
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# systemctl status memcached
Unit memcached.service could not be found.
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# # We can install postfix and memcached with yum using the same procedure!
[root@f0faf6197fbc /]#
[root@f0faf6197fbc /]# # Exercise Done :) !!


[ view entry ] ( 1008 views )   |  print article
PostgreSQL Fun 

#Fedora 23
[acool@localhost ~]$ sudo dnf install postgresql-server.x86_64
[acool@localhost ~]$ sudo postgresql-setup --initdb
[acool@localhost ~]$ sudo systemctl start postgresql
[acool@localhost ~]$ sudo su - postgres
-bash-4.3$
-bash-4.3$
-bash-4.3$ createuser --pwprompt acool
Enter password for new role:
Enter it again:
-bash-4.3$
-bash-4.3$
-bash-4.3$ psql
psql (9.4.9)
Type "help" for help.
postgres=#
postgres=#
postgres=#
postgres-# # list databases
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)

postgres-#
postgres-# #list users (roles)
postgres-# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
acool | | {}
postgres | Superuser, Create role, Create DB, Replication | {}

postgres-#
postgres=#
postgres=# ALTER USER acool SUPERUSER;
ALTER ROLE
postgres=# ALTER USER acool CREATEROLE;
ALTER ROLE
postgres=# ALTER USER acool CREATEDB;
ALTER ROLE
postgres=# ALTER USER acool REPLICATION;
ALTER ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
acool | Superuser, Create role, Create DB, Replication | {}
postgres | Superuser, Create role, Create DB, Replication | {}

postgres=#


[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ cat postgresql-test.sql
CREATE TABLE soccer_teams
(
name varchar(250),
city varchar(250)
);
[acool@localhost ~]$
[acool@localhost ~]$ createdb my-db-test
[acool@localhost ~]$
[acool@localhost ~]$ psql -d my-db-test
psql (9.4.9)
Type "help" for help.

my-db-test=#
my-db-test=#
my-db-test=# \i postgresql-test.sql
CREATE TABLE
my-db-test=#
my-db-test=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------+-------+-------
public | soccer_teams | table | acool
(1 row)

my-db-test=#
my-db-test-#
my-db-test-# \d+ soccer_teams
Table "public.soccer_teams"
Column | Type | Modifiers | Storage | Stats target | Description
--------+------------------------+-----------+----------+--------------+-------------
name | character varying(250) | | extended | |
city | character varying(250) | | extended | |

my-db-test=#
my-db-test=# INSERT INTO soccer_teams(name,city) VALUES('LA Galaxy','Los Angeles');
INSERT 0 1
my-db-test=#
my-db-test=# SELECT * FROM soccer_teams;
name | city
-----------+-------------
LA Galaxy | Los Angeles
(1 row)

my-db-test-#
my-db-test-# \q
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$ psql -V
psql (PostgreSQL) 9.4.9
[acool@localhost ~]$
[acool@localhost ~]$
[acool@localhost ~]$

// other crap
postgres=# #delete user (without roles?, DROP ROLE acool works too?, objects depend on it?)
postgres=# DROP USER acool;
DROP ROLE


[ view entry ] ( 1256 views )   |  print article

<<First <Back | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Next> Last>>


2024 By Angel Cool