Docker: reference information for SWARMS, NODES, SERVICES, STACKS and NETWORKS 
[vagrant@box1 ~]$ date
Fri Dec 11 18:34:51 UTC 2020
[vagrant@box1 ~]$
[vagrant@box1 ~]$ docker --version
Docker version 20.10.0, build 7287ab3
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ ########## Docker SWARM info ##########
[vagrant@box1 ~]$ docker swarm

Usage: docker swarm COMMAND

Manage Swarm

Commands:
ca Display and rotate the root CA
init Initialize a swarm
join Join a swarm as a node and/or manager
join-token Manage join tokens
leave Leave the swarm
unlock Unlock swarm
unlock-key Manage the unlock key
update Update the swarm

Run 'docker swarm COMMAND --help' for more information on a command.
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ ########## Docker NODE info ##########
[vagrant@box1 ~]$ docker node

Usage: docker node COMMAND

Manage Swarm nodes

Commands:
demote Demote one or more nodes from manager in the swarm
inspect Display detailed information on one or more nodes
ls List nodes in the swarm
promote Promote one or more nodes to manager in the swarm
ps List tasks running on one or more nodes, defaults to current node
rm Remove one or more nodes from the swarm
update Update a node

Run 'docker node COMMAND --help' for more information on a command.
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ ########## Docker SERVICE info ##########
[vagrant@box1 ~]$ docker service

Usage: docker service COMMAND

Manage services

Commands:
create Create a new service
inspect Display detailed information on one or more services
logs Fetch the logs of a service or task
ls List services
ps List the tasks of one or more services
rm Remove one or more services
rollback Revert changes to a service's configuration
scale Scale one or multiple replicated services
update Update a service

Run 'docker service COMMAND --help' for more information on a command.
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ ########## Docker STACK info ##########
[vagrant@box1 ~]$ docker stack

Usage: docker stack [OPTIONS] COMMAND

Manage Docker stacks

Options:
--orchestrator string Orchestrator to use (swarm|kubernetes|all)

Commands:
deploy Deploy a new stack or update an existing stack
ls List stacks
ps List the tasks in the stack
rm Remove one or more stacks
services List the services in the stack

Run 'docker stack COMMAND --help' for more information on a command.
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ ########## Docker NETWORK info ##########
vagrant@box1 ~]$ docker network

Usage: docker network COMMAND

Manage networks

Commands:
connect Connect a container to a network
create Create a network
disconnect Disconnect a container from a network
inspect Display detailed information on one or more networks
ls List networks
prune Remove all unused networks
rm Remove one or more networks

Run 'docker network COMMAND --help' for more information on a command.
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$ ########## All the crap available under Docker binary ##########
[vagrant@box1 ~]$
[vagrant@box1 ~]$ docker

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
--config string Location of client config files (default "/home/vagrant/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker
context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/home/vagrant/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/home/vagrant/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/home/vagrant/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit

Management Commands:
app* Docker App (Docker Inc., v0.9.1-beta3)
builder Manage builds
buildx* Build with BuildKit (Docker Inc., v0.4.2-docker)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes

Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.
To get more help with docker, check out guides at https://docs.docker.com/go/guides/
[vagrant@box1 ~]$
[vagrant@box1 ~]$
[vagrant@box1 ~]$


[ view entry ] ( 548 views )   |  print article
Nagios: Miscellaneous notes on installing and configuring Nagios. 
[acool@localhost ~]$ 
[acool@localhost ~]$ date
Mon 07 Dec 2020 05:45:53 PM PST
[acool@localhost ~]$
[acool@localhost ~]$ cat /etc/redhat-release
Fedora release 31 (Thirty One)
[acool@localhost ~]$
[acool@localhost ~]$ sudo dnf install httpd nagios nagios-common nagios-plugins-all
Last metadata expiration check: 0:36:12 ago on Mon 07 Dec 2020 05:09:52 PM PST.
Package httpd-2.4.46-1.fc31.x86_64 is already installed.
Package nagios-4.4.5-7.fc31.x86_64 is already installed.
Package nagios-common-4.4.5-7.fc31.x86_64 is already installed.
Package nagios-plugins-all-2.3.3-2.fc31.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[acool@localhost ~]$
[acool@localhost ~]$ cat /etc/httpd/conf.d/nagios.conf
...
[acool@localhost ~]$
[acool@localhost ~]$ # default password for web ui nagiosadmin:nagiosadmin? I think yes.
[acool@localhost ~]$ ll /etc/nagios/
total 92
-rw-rw-r--. 1 root root 13699 Apr 7 2020 cgi.cfg
-rw-rw-r--. 1 root root 45886 Nov 4 23:23 nagios.cfg
-rw-r--r--. 1 root root 12839 Apr 29 2020 nrpe.cfg
drwxr-x---. 2 root nagios 4096 Nov 5 11:05 objects
-rw-r-----. 1 root apache 27 Apr 7 2020 passwd
drwxr-x---. 2 root nagios 4096 Nov 3 12:22 private
[acool@localhost ~]$
[acool@localhost ~]$ # http://localhost:8080/nagios/ should now load (adjust port as needed)


TODO: nagiosgraph. NEEDS TESTING!!

A.- Looks like we need this in commands.cfg :

define command {
command_name process-service-perfdata-for-nagiosgraph
command_line /usr/local/nagiosgraph/bin/insert.pl
}

B.- And this in templates.cfg :

define service {
name graphed-service
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j
register 0
}

C.- Then we need to add 'graphed-service' to services in localhost.cfg for example:

# Define a service to "ping" the local machine
define service {

use local-service,graphed-service; Name of service template to use
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}

D.- In these in /etc/nagios/nagios.cfg : - NEEDS TO BE VERIFIED

process_performance_data=1
service_perfdata_file=/tmp/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph

More hints :
[root@localhost nagiosgraph]# 
[root@localhost nagiosgraph]# grep -nri nagiosgraph /etc/httpd/
/etc/httpd/conf/httpd.conf:354:#### NAGIOSGRAPH #####
/etc/httpd/conf/httpd.conf:355:include /usr/local/nagiosgraph/etc/nagiosgraph-apache.conf
[root@localhost nagiosgraph]#


See nagiosgraph settings:

http://localhost:8080/nagiosgraph/cgi-b ... config.cgi


[ view entry ] ( 615 views )   |  print article
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

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


2024 By Angel Cool