July 2019
M T W T F S S
« Jun    
1234567
891011121314
15161718192021
22232425262728
293031  

Categories

WordPress Quotes

I've learned that you shouldn't go through life with a catcher's mitt on both hands; you need to be able to throw something back.
Maya Angelou
July 2019
M T W T F S S
« Jun    
1234567
891011121314
15161718192021
22232425262728
293031  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (36)
Ansibile (19)
Apache (134)
Asterisk (2)
cassandra (2)
Centos (211)
Centos RHEL 7 (267)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (30)
Eassy (11)
ELKS (1)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
health (1)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (7)
Ldap (5)
Linux (188)
Linux Commands (166)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (24)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (35)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (35)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (62)
Uncategorized (29)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

19 visitors online now
0 guests, 19 bots, 0 members

Hit Counter provided by dental implants orange county

Open vSwitch installation on CentOS 7.2

Open vSwitch installation on CentOS 7.2
Open vSwitch (OVS) is a production quality, multilayer virtual switch software available for various platforms. The server platforms include x86 based latest Linux distributions e.g. Debian 16 LTS or CentOS 7.2. Popular SDN switch operating system development company Pica8 also bundles the OVS in a custom Ubuntu version for Pronto, Dell, and many other switches.

Below is an effort to provide easy installation instructions for OVS on CentOS 7.2 and also to integrate OVS with the OpenDaylight. Note this blog is updated to use OVS version 2.5.1 (bug fix release for OVS 2.5.0).

Install the requisite packages.
#yum -y install make gcc openssl-devel autoconf automake rpm-build redhat-rpm-config python-devel openssl-devel kernel-devel kernel-debug-devel libtool wget
Necessary steps for building RPM
#mkdir -p ~/rpmbuild/SOURCES
#wget http://openvswitch.org/releases/openvswitch-2.8.0.tar.gz
#cp openvswitch-2.8.0.tar.gz ~/rpmbuild/SOURCES/
#tar xfz openvswitch-2.8.0.tar.gz
#sed ‘s/openvswitch-kmod, //g’ openvswitch-2.8.0/rhel/openvswitch.spec > openvswitch-2.8.0/rhel/openvswitch_no_kmod.spec
Build the RPM
#rpmbuild -bb –nocheck ~/openvswitch-2.8.0/rhel/openvswitch_no_kmod.spec
Install the RPM
#ls -l ~/rpmbuild/RPMS/x86_64/
#yum localinstall ~/rpmbuild/RPMS/x86_64/openvswitch-2.8.0-1.x86_64.rpm
Start the OVS service and enable it for the next boot
#systemctl start openvswitch.service
#chkconfig openvswitch on
This process will install the OVS on the server and start the process. Firewall should be open to accept the incoming TCP connection at port 6633.

Check that the command-line tools are ready
ovs-vsctl -V
NOW, if you’re using SELinux in enfocing mode and try to start the service, you’ll find some errors. Please follow the steps to solve it.
yum install policycoreutils-python
mkdir /etc/openvswitch
semanage fcontext -a -t openvswitch_rw_t “/etc/openvswitch(/.*)?”
restorecon -Rv /etc/openvswitch
Start OpenvSwitch
/etc/init.d/openvswitch start

Test the OVS Version
#ovs-vsctl -V

Useful OVS commands
#ovs-vsctl show
#ovs-ofctl show br0

Create a new OVS Bridge, add physical ports, connect OVS with ODL controller
#ovs-vsctl add-br ovsbr0
#ovs-vsctl set bridge ovsbr0 protocols=OpenFlow13
#ovs-vsctl list controller
#ovs-vsctl add-port ovsbr0 eth4
#ovs-vsctl add-port ovsbr0 eth8
#ovs-vsctl set-controller ovsbr0 tcp:192.168.1.57:6633
#ovs-vsctl show

Openstack log files

OpenStack log files contains different structures and distributed across multiple folders which make a real challenge to provide real proactive insights on your deployment. Loom Cloud Intelligence can simply save your time and make sense of your Openstack deployment on going issues.
Most services use the convention of writing their log files to subdirectories of the /var/log directory, as listed in the following list.

Compute nova-*
/var/log/nova

Image Service glance-*
/var/log/glance

Block Storage cinder-*
/var/log/cinder

Identity service keystone-*
/var/log/keystone

Networking neutron-*
/var/log/neutron

Dashboard horizon
/var/log/apache2 or /var/log/httpd

Orchestration service heat
/var/log/heat

Telemetry service ceilometer
/var/log/ceilometer

All nodes misc (swift, dnsmasq)
/var/log/syslog

Compute nodes libvirt
/var/log/libvirt/libvirtd.log

Compute nodes Console (boot upmessages) for VM instances: /var/lib/nova/instances/instance-/console.log

Block Storage nodes cinder-volume
/var/log/cinder/cinder-volume.log

How to confiugre logging in Openstack enviroment?

Separately configure the Compute service (nova), the Identity service (keystone), the Image service (glance), and, if you are using it, the Block Storage service (cinder) to send log messages to syslog. Open these configuration files:

/etc/nova/nova.conf
/etc/keystone/keystone.conf
/etc/glance/glance-api.conf
/etc/glance/glance-registry.conf
/etc/cinder/cinder.conf
In each configuration file, add these lines:

debug = False

use_syslog = True

syslog_log_facility = LOG_LOCAL0

In addition to enabling syslog, these settings also turn off debugging output from the log.

OpenStack Cheat Sheet 2017

OpenStack different services have very powerful command line interfaces, with lots of different options.

Here is quick reference of the most used command-line commands:

General:

You will probably want to know what is the name of your openstack deployment? Aka Queens, Pines, Ocata, Newton but also to Mitaka, Liberty, Kilo & Juno.
Which OpenStack version is installed?

$ openstack –version
Once you have the version, check here for the name.
Same way for other specific services too, for example:

$ nova-manage –version
$ cinder-manage –version
$ glance-manage –version
Identity Service (aka Keystone):

List all users

$ openstack user list
List Identity service catalog

$ openstack catalog
List all services in service catalog

$ openstack service list
Compute (aka Nova)

List instances, notice status of instance

$ openstack server list
List images

$ openstack image list
List flavors

$ openstack flavor list
Boot an instance using flavor and image names

$ openstack server create –image IMAGE –flavor FLAVOR INSTANCE_NAME
$ openstack server create –image cirros-0.4.8-x86_64-uec –flavor m1.large\
NewInstance
Login to a Linux instance

# ip netns

# ip netns exec NETNS_NAME ssh USER@SERVER

# ip netns exec qdhcp-34343ds43-2323-4f9c-5432-0432885dgtf2 \

ssh cirros@10.0.0.2
*Note, in CirrOS the password for user cirros is “cubswin:)”.

Show details of instance

$ openstack server show NAME
$ openstack server show NewInstance
View console log of instance

$ openstack console-log NewInstance
Set metadata on an instance

$ nova meta volumeTwoImage set newmeta=’my new meta data’
Create an instance snapshot

$ openstack image-create volumeImage snapshot1OfVolumeImage
$ openstack image-show snapshot1OfVolumeImage

Stop, Pause, resize, rebuild and offcourse reboot an instance

Pause

$ openstack server pause NAME
$ openstack server pause myinstance
Unpause

$ openstack server unpause NAME
Stop

$ openstack server stop NAME
Start

$ openstack server start NAME
Resize

$ openstack server resize NAME FLAVOR
$ openstack server resize myinstance m2.large
$ openstack server resize –confirm myinstance
Rebuild

$ openstack server rebuild NAME IMAGE
$ openstack server rebuild myinstance cirros-121
Reboot

$ openstack server reboot NAME
$ openstack server reboot myinstance
Image Service (aka Glance)

List images you can access

$ openstack image list
Delete specified image

$ openstack image delete IMAGE
Describe a specific image

$ openstack image show IMAGE
Update image

$ openstack set imageIMAGE
Networking Service (aka Neutron)

Create network

$ openstack network create NAME
Create a subnet

$ openstack subnet create –subnet-pool SUBNET –network NETWORK SUBNET_NAME
$ openstack subnet create –subnet-pool 10.0.0.2/30 –network network1 subnetwork1
List network and subnet

$ neutron net-list
$ neutron subnet-list
Examine details of network and subnet

$ neutron net-show ID_OR_NAME_OF_NETWORK
$ neutron subnet-show ID_OR_NAME_OF_NETWORK
Block Storage Service (aka Cinder)

Create a new volume

$ openstack volume create –size SIZE_IN_GB NAME
$ openstack volume create –size 10 MyVolume
Boot an instance and attach to volume

$ openstack server create –image cirros-qcow2 –flavor m2.large MyVolume
List volumes

$ openstack volume list
Attach volume to instance after instance is active, and volume is available

$ openstack server add volume INSTANCE_ID VOLUME_ID
Manage volumes after login into the instance

List storage devices

# fdisk -l
Make filesystem on volume

# mkfs.ext3 /dev/vdb
Create a mountpoint

# mkdir /myspace
Mount the volume at the mountpoint

# mount /dev/vdb /myspace
Create a file on the volume

# touch /myspace/helloworld.txt
# ls /myspace
Unmount the volume

# umount /myspace
Troubleshooting

(1) In case you tried run one of the above commands and received the following error “Missing value auth-url required for auth plugin password”, simply follow this article and you are good to go.

expect,sshpass,pash

expect,sshpass,pash
rpm -qa expect

yum install expect -y

useradd mohan

echo 123456|passwd –stdin mohan

su – mohan

ssh-keygen -t dsa -P ” -f ~/.ssh/id_dsa >/dev/null 2>&1

yum install lrzsz -y

cat mohan_sshkey.exp
#!/usr/bin/expect
if { $argc !=2 } {
send_user “usage: expect mohan_sshkey.exp file host\n”
exit
}
#define var
set file [lindex $argv 0]
set host [lindex $argv 1]
set password “123456”
#spawn scp /etc/hosts root@10.0.0.142:/etc/hosts
#spawn scp -P52113 $file testserver@$host:$dir
spawn ssh-copy-id -i $file “-p 22 oldgirl888@$host”
expect {
“yes/no” {send “yes\r” ;exp_continue}
“password” {send “$password\r”}
}
expect cof
exit -onexit {
send_user “testserver say good bye to you!\n”
}
#script usage
#expect testserver-6.exp file host dir
#example
#expect mohan_sshkey.exp file host dir
#expect mohan_sshkey.exp ~/etc/hosts 10.0.0.41:~

expect mohan_sshkey.exp .ssh/id_dsa.pub 192.168.1.21

#!/bin/sh
. /etc/init.d/functions
for ip in 8 31 41
do
expect mohan_sshkey.exp ~/.ssh/id_dsa.pub 192.168.1.$ip >/dev/null 2>&1
if [ $? -eq 0 ];then
action “$ip” /bin/true
else
action “$ip” /bin/false
fi
done

oracle backup

#!/bin/bash
#oracle_backup.sh version1.0 chmod 700
#00 00 * * * /usr/local/scripts/oracle_backup.sh
#chmod 700 /usr/local/scripts/oracle_backup.sh
#You must first import the environment variables in the Oracle user’s bash_profile file
#Must be used to define the DBA account first dpdata1 path and authorized directory to read and write, modify the dpdata1 group

export ORACLE_BASE=/usr/local/u01/oracle
export ORACLE_HOME=/usr/local/u01/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=oracle11
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
datetime=$(date +”%Y%m%d”)
dpdata1_dir=”/data/backup/oracle_backup”
oracle_u01=”u01″
oracle_u02=”u02″
oracle_password1=”u01_password”
oracle_password2=”u02_password”

expdp ${oracle_u01}/${oracle_password1} directory=dpdata1 dumpfile=${oracle_u01}_${datetime} logfile=${oracle_u01}_${datetime}.log

if [ $? -ne 0 ];then
echo “$(date +”%Y-%m-%d_%H:%M:%S”)oracle_${oracle_u01}_backup_file!” > ${dpdata1_dir}/${datetime}_err.log
fi

expdp ${oracle_u02}/${oracle_password2} directory=dpdata1 dumpfile=${oracle_u02}_${datetime} logfile=${oracle_u02}_${datetime}.log

if [ $? -ne 0 ];then
echo “$(date +”%Y-%m-%d_%H:%M:%S”)oracle_${oracle_u02}_backup_file!” >> ${dpdata1_dir}/${datetime}_err.log
fi

/usr/bin/bzip2 -z ${dpdata1_dir}/*${datetime}*
find $dpdata1_dir -type f -ctime +30 -name “*.bz2” -exec rm -vf {} \;

Kubernetes

What is Kubernetes?
Kubernetes is a Google open source container cluster management system, based on Docker build containers, the use of Kubernetes can manage a number of Docker host in the container.
The main functions are as follows:
1) abstracts multiple Docker hosts into one resource to manage containers in a clustered manner, including task scheduling, resource management, resilient scaling, rolling upgrades, and more.
2) Use the layout system (YAML File) to quickly build container clusters, provide load balancing, solve container direct correlation and communication problems
3) automatically manage and repair the container, simply say, such as creating a cluster, there are ten containers, if a container is closed, then, will try to restart or re-allocation of containers, always ensure that there will be ten containers in operation, Kill the excess.

What is Kubernetes?
Kubernetes is a Google open source container cluster management system, based on Docker build containers, the use of Kubernetes can manage a number of Docker host in the container.
The main functions are as follows:
1) abstracts multiple Docker hosts into one resource to manage containers in a clustered manner, including task scheduling, resource management, resilient scaling, rolling upgrades, and more.
2) Use the layout system (YAML File) to quickly build container clusters, provide load balancing, solve container direct correlation and communication problems
3) automatically manage and repair the container, simply say, such as creating a cluster, there are ten containers, if a container is closed, then, will try to restart or re-allocation of containers, always ensure that there will be ten containers in operation, Kill the excess.
Kubernetes role composition:
1) Pod
Pod is the smallest unit of kubernetes, a pod can be composed of one or more containers;
The same Pod can only run on the same host, share the same volumes, network, namespace;
2) ReplicationController (RC)
RC is used to manage the pod. An RC can consist of one or more pods. After the RC is created, the system creates the number of pods based on the number of copies defined. In the course of running, if the number of Pod is less than defined, it will restart the stop or reassign Pod, otherwise kill the excess. Of course, you can also dynamically stretch the size of the Pods or familiar.
RC is associated with the corresponding Pods through the label, and in the rolling upgrade, the RC uses a Pod that replaces the entire Pods to be updated.
3) Service
Service defines the abstract resources of a Pod logical set, and the containers in the Pod collection provide the same functionality. The collection is created according to the defined Label and selector. When a Service is created, a Cluster IP is assigned. This IP provides a unified access interface with the defined port and implements load balancing.
4) Label
Label is used to distinguish between Pod, Service, RC key / value key pairs;
Pod, Service, RC can have multiple labels, but each label’s key can only correspond to one;
Mainly to the Service request through the lable forwarding to the backend to provide services Pod collection;
Kubernetes components:
1) kubectl
The client command line tool formats the accepted command and sends it to the kube-apiserver as the operating entry for the entire system.
2) kube-apiserver
As a control entry for the entire system, the REST API service provides an interface.
3) kube-controller-manager
Used to perform the background tasks in the entire system, including node status, Pod number, Pods and Service associations.
4) kube-scheduler
Responsible for node resource management, accepting pods tasks from kube-apiserver, and assigning them to a node.
5) etcd
Responsible for service discovery and configuration sharing between nodes.
6) kube-proxy
Run on each compute node, responsible for Pod network proxy. Timing from the etcd to obtain the service information to do the appropriate strategy.
7) kubelet
Run on each compute node, as an agent, accept the Pods task assigned to the node and manage the container, periodically get the container status, and feed it back to kube-apiserver.
8) DNS
An optional DNS service for creating DNS records for each Service object so that all Pods can access the service through DNS.

redis 3

CentOS Redis 3 and 6.8 installed on the startup script, strong Redis is not to say, and directly see the following article explain.

Step 1: Download, compile and install

cd /opt
wget http://download.redis.io/releases/redis-3.2.5.tar.gz

tar zxvf redis-3.2.5.tar.gz

cd redis-3.2.5

yum install -y gcc*
yum install -y tcl
make MALLOC=libc
make
make test

cd deps
make hiredis jemalloc linenoise lua geohash-int
cd ..
make install

[root@cluster1 redis-3.2.5]# cd utils/
[root@cluster1 utils]# ls
build-static-symbols.tcl corrupt_rdb.c generate-command-help.rb hyperloglog lru redis_init_script redis-sha1.rb speed-regression.tcl
cluster_fail_time.tcl create-cluster hashtable install_server.sh redis-copy.rb redis_init_script.tpl releasetools whatisdoing.sh
[root@cluster1 utils]# chmod +x install_server.sh
[root@cluster1 utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default – /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default – /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default – /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service…
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server…
Installation successful!

daemonize no
port 6379
logfile “”
pidfile /var/run/redis.pid
# requirepass foobared
dir ./

daemonize yes
port 6379
logfile “/var/log/redis/6379.log”
pidfile /var/run/redis_6379.pid
requirepass 9k3NgZq%gO
dir /data/redis

grep vm.overcommit_memory /etc/sysctl.conf
echo “vm.overcommit_memory = 1” >> /etc/sysctl.conf
sed -i “s/vm.overcommit_memory = 0/vm.overcommit_memory = 1/g” /etc/sysctl.conf
sysctl -p

Redis
chkconfig redis on
chkconfig –list redis
service redis start
service redis stop

update Redis on CentOS 6.5

First, make sure the following repos, EPEL and REMI, are installed:
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-6.rpm
Check the version of Redis in REMI repo: (As of June 2015, the version is 2.8.13)
yum –enablerepo=remi info redis
Then install related dependency (jemalloc) from EPEL repo:
sudo yum –enablerepo=epel install jemalloc
Before installation, you should stop the old Redis daemon:
sudo service redis stop
Then install the newer version of Redis:
sudo yum –enablerepo=remi install redis
Edit Redis configuration file if needed:
sudo vi /etc/redis.conf
Restart Redis daemon, and make it auto-start on reboot:
sudo service redis start
sudo chkconfig redis on
Finally, check the version of currently installed Redis:
redis-cli info | grep redis_version

redis

Centos 6.8

cd /opt
wget http://download.redis.io/releases/redis-3.0.5.tar.gz
tar zxvf redis-3.0.5.tar.gz
cd redis-3.0.5
make && make install

mkdir /etc/redis
mkdir /var/log/redis
mkdir -p /data/redis
cd /opt/redis-3.0.5
cp redis.conf /etc/redis/7963.conf
vi /etc/redis/7963.conf

daemonize no
port 6379
logfile “”
pidfile /var/run/redis.pid
# requirepass foobared
dir ./
??
daemonize yes
port 7963
logfile “/var/log/redis/7963.log”
pidfile /var/run/redis_7963.pid
requirepass 9k3NgZq%gO!W7x-0y=LI
dir /data/redis

sed -i “s/daemonize no/daemonize yes/g” /etc/redis/7963.conf
sed -i “s/port 6379/port 7963/g” /etc/redis/7963.conf
sed -i “s/pidfile \/var\/run\/redis.pid/pidfile \/var\/run\/redis_7963.pid/g” /etc/redis/7963.conf
sed -i “s/logfile \”\”/logfile \”\/var\/log\/redis\/7963.log\”/g” /etc/redis/7963.conf
sed -i “s/# requirepass foobared/requirepass 9k3NgZq%gO!W7x-0y=LI/g” /etc/redis/7963.conf
sed -i “s/dir .\//dir \/data\/redis/g” /etc/redis/7963.conf

grep vm.overcommit_memory /etc/sysctl.conf

echo “vm.overcommit_memory = 1” >> /etc/sysctl.conf

sed -i “s/vm.overcommit_memory = 0/vm.overcommit_memory = 1/g” /etc/sysctl.conf

sysctl -p

cd /opt/redis-3.0.5
cp utils/redis_init_script /etc/init.d/redis
vi /etc/init.d/redis
vi /etc/init.d/redis
———————————–

# chkconfig: 2345 90 10
# description: Simple Redis init.d scrip
REDISPORT=6379
REDISPORT=7963

CONF=”/etc/redis/${REDISPORT}.conf”
PASS=`grep “requirepass ” $CONF | awk {print’$2′}`
$CLIEXEC -p $REDISPORT shutdown
if [ -z “$PASS” ]
then
$CLIEXEC -p $REDISPORT shutdown
else
$CLIEXEC -p $REDISPORT -a $PASS shutdown
fi

sed -i “1 a # chkconfig: 2345 90 10” /etc/init.d/redis
sed -i “2 a # description: Simple Redis init.d scrip” /etc/init.d/redis
sed -i “s/REDISPORT=6379/REDISPORT=7963/g” /etc/init.d/redis
sed -i $’13 a PASS=`grep “requirepass ” $CONF | awk {print\’$2\’}`’ /etc/init.d/redis
sed -i “s/PORT shutdown/PORT -a \$PASS shutdown/g” /etc/init.d/redis

Redis
chkconfig redis on
chkconfig –list redis
service redis start
service redis stop

CentOS 7 Redis

## RHEL/CentOS 7 64-Bit ##
wget http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -ivh epel-release-7-5.noarch.rpm

yum repolist

yum -y update
yum install redis php-pecl-redis
systemctl start redis-server.service
systemctl enable redis-server.service
systemctl is-active redis-server.service

phpRedisAdmin RedisWeb Redis

git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
cd phpRedisAdmin/includes
cp config.sample.inc.php config.inc.php

# nano config.inc.php
RedisAdmin???????Apache

### nano /etc/httpd/conf.d/redisadmin.conf
### Now add the following ###
#
# Web Interface for RedisAdmin
#


Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from

Alias /redisAdmin /downloads/phpRedisAdmin
Alias /redisadmin /downloads/phpRedisAdmin

### nano /scripts/redis-check.sh
#!/bin/bash
PS=$(which ps)
GREP=$(which grep)
WHEN=$(date +”%Y-%m-%d-%H:%M:%S”)
if ! $PS aux | $GREP “redis.conf” | $GREP -v grep 2>&1 > /dev/null; then
/etc/init.d/redis restart
echo ‘Restarted Redis @’ $WHEN
fi
#Check Second instance
if ! $PS aux | $GREP “redis2.conf” | $GREP -v grep 2>&1 > /dev/null; then
/etc/init.d/redis2 restart
echo ‘Restarted Redis2 @’ $WHEN
fi

chmod +x /scripts/redis-check.sh

### nano /var/spool/cron/root
*/3 * * * * /bin/bash /script/redis-check.sh >> /var/log/redis-check.log

http://www.linuxidc.com/Linux/2016-06/132687.htm

tar xf redis-3.0.7.tar.gz -C /usr/local
mv redis-3.0.7 redis
cd /usr/local
make
make install
cp utils/redis_init_script /etc/init.d/redis

vim /etc/init.d/redis
# chkconfig: 2345 88 45
chmod +x /etc/init.d/redis
chkconfig –add redis

vim /usr/local/redis/redis.conf
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
port 7001
logfile “redis_7001.log”
dir “/data/redis/7001”
appendonly yes #????aof

mkdir /etc/redis/{7001,7002} -pv
mkdir /data/redis/{7001,7002} -pv
mkdir /etc/redis/{7003,7004} -pv
mkdir /data/redis/{7003,7004} -pv
mkdir /etc/redis/{7005,7006} -pv
mkdir /data/redis/{7005,7006} -pv
cd /etc/redis

sed ‘s/6379/7001/g’ /usr/local/redis/redis.conf > /etc/redis/7001/redis.conf
sed ‘s/6379/7002/g’ /usr/local/redis/redis.conf > /etc/redis/7002/redis.conf
sed ‘s/6379/7003/g’ /usr/local/redis/redis.conf > /etc/redis/7003/redis.conf
sed ‘s/6379/7004/g’ /usr/local/redis/redis.conf > /etc/redis/7004/redis.conf
sed ‘s/6379/7005/g’ /usr/local/redis/redis.conf > /etc/redis/7005/redis.conf
sed ‘s/6379/7006/g’ /usr/local/redis/redis.conf > /etc/redis/7006/redis.conf

/usr/local/redis/src/redis-server /etc/redis/700[1-6]/redis.conf

yum -y install ruby rubygems

gem install redis

cp /usr/local/redis/src/redis-trib.rb /usr/bin/redis-trib

redis-trib create –replicas 1 192.168.130.242:7001 192.168.130.242:7002
192.168.130.243:7003 192.168.130.243:7004 192.168.130.244:7005 192.168.130.244:7006

Centos 6.8

cd /opt
wget http://download.redis.io/releases/redis-3.0.5.tar.gz
tar zxvf redis-3.0.5.tar.gz
cd redis-3.0.5
make && make install

mkdir /etc/redis
mkdir /var/log/redis
mkdir -p /data/redis
cd /opt/redis-3.0.5
cp redis.conf /etc/redis/7963.conf
vi /etc/redis/7963.conf

daemonize no
port 6379
logfile “”
pidfile /var/run/redis.pid
# requirepass foobared
dir ./
??
daemonize yes
port 7963
logfile “/var/log/redis/7963.log”
pidfile /var/run/redis_7963.pid
requirepass 9k3NgZq%gO!W7x-0y=LI
dir /data/redis

sed -i “s/daemonize no/daemonize yes/g” /etc/redis/7963.conf
sed -i “s/port 6379/port 7963/g” /etc/redis/7963.conf
sed -i “s/pidfile \/var\/run\/redis.pid/pidfile \/var\/run\/redis_7963.pid/g” /etc/redis/7963.conf
sed -i “s/logfile \”\”/logfile \”\/var\/log\/redis\/7963.log\”/g” /etc/redis/7963.conf
sed -i “s/# requirepass foobared/requirepass 9k3NgZq%gO!W7x-0y=LI/g” /etc/redis/7963.conf
sed -i “s/dir .\//dir \/data\/redis/g” /etc/redis/7963.conf

grep vm.overcommit_memory /etc/sysctl.conf

echo “vm.overcommit_memory = 1” >> /etc/sysctl.conf

sed -i “s/vm.overcommit_memory = 0/vm.overcommit_memory = 1/g” /etc/sysctl.conf

sysctl -p

cd /opt/redis-3.0.5
cp utils/redis_init_script /etc/init.d/redis
vi /etc/init.d/redis
vi /etc/init.d/redis
———————————–

# chkconfig: 2345 90 10
# description: Simple Redis init.d scrip
REDISPORT=6379
REDISPORT=7963

CONF=”/etc/redis/${REDISPORT}.conf”
PASS=`grep “requirepass ” $CONF | awk {print’$2′}`
$CLIEXEC -p $REDISPORT shutdown
if [ -z “$PASS” ]
then
$CLIEXEC -p $REDISPORT shutdown
else
$CLIEXEC -p $REDISPORT -a $PASS shutdown
fi

sed -i “1 a # chkconfig: 2345 90 10” /etc/init.d/redis
sed -i “2 a # description: Simple Redis init.d scrip” /etc/init.d/redis
sed -i “s/REDISPORT=6379/REDISPORT=7963/g” /etc/init.d/redis
sed -i $’13 a PASS=`grep “requirepass ” $CONF | awk {print\’$2\’}`’ /etc/init.d/redis
sed -i “s/PORT shutdown/PORT -a \$PASS shutdown/g” /etc/init.d/redis

Redis
chkconfig redis on
chkconfig –list redis
service redis start
service redis stop

CentOS 7 Redis

## RHEL/CentOS 7 64-Bit ##
wget http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -ivh epel-release-7-5.noarch.rpm

yum repolist

yum -y update
yum install redis php-pecl-redis
systemctl start redis-server.service
systemctl enable redis-server.service
systemctl is-active redis-server.service

phpRedisAdmin RedisWeb Redis

git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
cd phpRedisAdmin/includes
cp config.sample.inc.php config.inc.php

# nano config.inc.php
RedisAdmin???????Apache

### nano /etc/httpd/conf.d/redisadmin.conf
### Now add the following ###
#
# Web Interface for RedisAdmin
#


Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from

Alias /redisAdmin /downloads/phpRedisAdmin
Alias /redisadmin /downloads/phpRedisAdmin

### nano /scripts/redis-check.sh
#!/bin/bash
PS=$(which ps)
GREP=$(which grep)
WHEN=$(date +”%Y-%m-%d-%H:%M:%S”)
if ! $PS aux | $GREP “redis.conf” | $GREP -v grep 2>&1 > /dev/null; then
/etc/init.d/redis restart
echo ‘Restarted Redis @’ $WHEN
fi
#Check Second instance
if ! $PS aux | $GREP “redis2.conf” | $GREP -v grep 2>&1 > /dev/null; then
/etc/init.d/redis2 restart
echo ‘Restarted Redis2 @’ $WHEN
fi

chmod +x /scripts/redis-check.sh

### nano /var/spool/cron/root
*/3 * * * * /bin/bash /script/redis-check.sh >> /var/log/redis-check.log

http://www.linuxidc.com/Linux/2016-06/132687.htm

tar xf redis-3.0.7.tar.gz -C /usr/local
mv redis-3.0.7 redis
cd /usr/local
make
make install
cp utils/redis_init_script /etc/init.d/redis

vim /etc/init.d/redis
# chkconfig: 2345 88 45
chmod +x /etc/init.d/redis
chkconfig –add redis

vim /usr/local/redis/redis.conf
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
port 7001
logfile “redis_7001.log”
dir “/data/redis/7001”
appendonly yes #????aof

mkdir /etc/redis/{7001,7002} -pv
mkdir /data/redis/{7001,7002} -pv
mkdir /etc/redis/{7003,7004} -pv
mkdir /data/redis/{7003,7004} -pv
mkdir /etc/redis/{7005,7006} -pv
mkdir /data/redis/{7005,7006} -pv
cd /etc/redis

sed ‘s/6379/7001/g’ /usr/local/redis/redis.conf > /etc/redis/7001/redis.conf
sed ‘s/6379/7002/g’ /usr/local/redis/redis.conf > /etc/redis/7002/redis.conf
sed ‘s/6379/7003/g’ /usr/local/redis/redis.conf > /etc/redis/7003/redis.conf
sed ‘s/6379/7004/g’ /usr/local/redis/redis.conf > /etc/redis/7004/redis.conf
sed ‘s/6379/7005/g’ /usr/local/redis/redis.conf > /etc/redis/7005/redis.conf
sed ‘s/6379/7006/g’ /usr/local/redis/redis.conf > /etc/redis/7006/redis.conf

/usr/local/redis/src/redis-server /etc/redis/700[1-6]/redis.conf

yum -y install ruby rubygems

gem install redis

cp /usr/local/redis/src/redis-trib.rb /usr/bin/redis-trib

redis-trib create –replicas 1 192.168.130.242:7001 192.168.130.242:7002
192.168.130.243:7003 192.168.130.243:7004 192.168.130.244:7005 192.168.130.244:7006

Mysql

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server

systemctl start mysqld

[root@clusterserver1 ~]# systemctl start mysqld
[root@clusterserver1 ~]# systemctl enable mysqld
[root@clusterserver1 ~]# systemctl status mysqld

[root@clusterserver1 ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
… Success!

By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
– Dropping test database…
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
… Failed! Not critical, keep moving…
– Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
… Success!

All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Cleaning up…
[root@clusterserver1 ~]# systemctl restart mysqld

[root@clusterserver1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.33 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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>

create database testdb;
create user ‘testuser’@’localhost’ identified by ‘password’;
grant all on testdb.* to ‘testuser’ identified by ‘password’;

mysql> create database testdb;
Query OK, 1 row affected (0.00 sec)

mysql> create user ‘testuser’@’localhost’ identified by ‘password’;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on testdb.* to ‘testuser’ identified by ‘password’;
Query OK, 0 rows affected (0.00 sec)

mysql>

create database testdb;
grant all on testdb.* to ‘testuser’ identified by ‘password’;

mysql -u testuser -p

use testdb;
create table customers (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);

[root@clusterserver1 ~]# mysql -u testuser -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.33 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> use testdb;
Database changed
mysql> create table customers (customer_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, first_name TEXT, last_name TEXT);
Query OK, 0 rows affected (0.01 sec)

mysql>

Reset the MySQL Root Password

If you forget your root MySQL password, it can be reset.

Stop the current MySQL server instance, then restart it with an option to not ask for a password.

systemctl stop mysqld
mysqld_safe –skip-grant-tables &

Reconnect to the MySQL server with the MySQL root account.

mysql -u root

Use the following commands to reset root’s password. Replace password with a strong password.

use mysql;
update user SET PASSWORD=PASSWORD(“password”) WHERE USER=’root’;
flush privileges;
exit

Then restart MySQL.

systemctl start mysqld

Tune MySQL

MySQL Tuner is a Perl script that connects to a running instance of MySQL and provides configuration recommendations based on workload. Ideally, the MySQL instance should have been operating for at least 24 hours before running the tuner. The longer the instance has been running, the better advice MySQL Tuner will give.

Download MySQL Tuner to your home directory.

wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl

To run it:

perl ./mysqltuner.pl

You will be asked for the MySQL root user’s name and password. The output will show two areas of interest: General recommendations and Variables to adjust.

MySQL Tuner is an excellent starting point to optimize a MySQL server but it would be prudent to perform additional research for configurations tailored to the application(s) utilizing MySQL on your Linode.

docker cmd

Basic Instructions

Download the image file

$ docker pull image_name

Activate or deactivate the container
$ docker [start|stop] container_name

Download the image file

$ docker pull image_name

Activate or deactivate the container

$ docker [start|stop] container_name
Build -> Start -> Execute command ( -ti parameter)

$ docker run -ti –name container_name image_name command
Build -> Start -> Execute command -> Delete Container ( -rm parameters)

$ docker run –rm -ti image_name command
file system and the corresponding port ( -v and -p parameter)

$ docker run -ti –rm -p 80:80 -v /your_path:/container_path -e PASSWORD=1234 image_name
Docker Clear (cleanup) instruction
Delete all container being executed

$ docker kill $(docker ps -q)

Remove dangling image file

docker rmi $(docker images -q -f dangling=true)

Remove all stopped container

docker rm $(docker ps -a -q)
Docker machine instruction

Start machine

$ docker-machine start machine_name

Specifies the machine to set the docker

$ eval “$(docker-machine env machine_name)”
Interactive instruction with container

Instruction in the container

$ docker exec -ti container_name command

Online Watch container logs

$ docker logs -ft container_name

Storage container being implemented into image files

$ docker commit -m “message” -a “author” container_name username/image_name:tag

docker compose format

docker-compose.yml following format

version: “2”
service:
container_name: “hello-world”
image: golang
command: “go run hello-world.go”
ports
– “80:8080”
volumes:
– /hello-world:/root/hello-world
redis:
image: redis

Build -> Execute container

$ docker-compose up
These are commonly used docker instruction, be sure to learn for beginners.