You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2019/02/04 15:27:45 UTC
svn commit: r1852934 - in /uima/uima-ducc/trunk:
uima-ducc-duccdocs/src/site/tex/duccbook/part4/ uima-ducc-examples/
uima-ducc-examples/src/main/reliable/
uima-ducc-examples/src/main/reliable/etc/
uima-ducc-examples/src/main/reliable/etc/keepalived/ ui...
Author: degenaro
Date: Mon Feb 4 15:27:45 2019
New Revision: 1852934
URL: http://svn.apache.org/viewvc?rev=1852934&view=rev
Log: (empty)
Added:
uima/uima-ducc/trunk/uima-ducc-examples/.pydevproject
uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/
uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/
uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/
uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived.conf
uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived_evaluator.py (with props)
uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/sysconfig/
uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/sysconfig/keepalived
Modified:
uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part4/reliable.tex
Modified: uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part4/reliable.tex
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part4/reliable.tex?rev=1852934&r1=1852933&r2=1852934&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part4/reliable.tex (original)
+++ uima/uima-ducc/trunk/uima-ducc-duccdocs/src/site/tex/duccbook/part4/reliable.tex Mon Feb 4 15:27:45 2019
@@ -16,11 +16,19 @@
% specific language governing permissions and limitations
% under the License.
%
+
+\let\oldv\verbatim
+\let\oldendv\endverbatim
+
+\def\greybatim{\par\setbox0\vbox\bgroup\oldv}
+\def\endgreybatim{\oldendv\egroup\fboxsep0pt \noindent\colorbox[gray]{0.8}{\usebox0}\par}
+
% Create well-known link to this spot for HTML version
\ifpdf
\else
\HCode{<a name='DUCC_RELIABLE'></a>}
\fi
+
\chapter{Reliable DUCC}
\label{chap:reliable}
@@ -42,48 +50,304 @@
which can be found at this web address:
\url{https://docs.oracle.com/cd/E37670_01/E41138/html/section_uxg_lzh_nr.html}.
- Sample MASTER /etc/keepalived/keepalived.conf
+% ========================================
+\begin{minipage}{\textwidth}
+% ========================================
+
+ Sample /etc/sysconfig/keepalived
+
+ \begin{greybatim}
- \begin{verbatim}
- ! Configuration File for keepalived
+# Options for keepalived. See `keepalived --help' output and keepalived(8) and
+# keepalived.conf(5) man pages for a list of all options. Here are the most
+# common ones :
+#
+# --vrrp -P Only run with VRRP subsystem.
+# --check -C Only run with Health-checker subsystem.
+# --dont-release-vrrp -V Dont remove VRRP VIPs & VROUTEs on daemon stop.
+# --dont-release-ipvs -I Dont remove IPVS topology on daemon stop.
+# --dump-conf -d Dump the configuration data.
+# --log-detail -D Detailed log messages.
+# --log-facility -S 0-7 Set local syslog facility (default=LOG_DAEMON)
+#
- vrrp_instance VI_1 {
- state MASTER
- interface eth0
- virtual_router_id 51
- priority 100
- advert_int 1
- authentication {
- auth_type PASS
- auth_pass 1111
- }
- virtual_ipaddress {
- 192.168.6.253
- }
- }
+KEEPALIVED_OPTIONS="-D -P"
+
+ \end{greybatim}
+
+ \medskip
+ IMPORTANT: Specify {\em -P} to enable keepalived IP takeover.
+
+ \medskip
+ See example here:
+ \begin{verbatim}
+ examples/reliable/etc/sysconfig/keepalived
\end{verbatim}
+
+% ========================================
+\end{minipage}
+% ========================================
+
+% ========================================
+\begin{minipage}{\textwidth}
+% ========================================
+
+ Sample MASTER /etc/keepalived/keepalived.conf
+
+ \begin{greybatim}
+
+! Configuration File for keepalived
+
+global_defs {
+ script_user ducc
+ enable_script_security
+}
+
+vrrp_script chk_ducc {
+ script "/etc/keepalived/keepalived_evaluator.py"
+ interval 5 # check every 5 seconds
+ fall 2 # require 2 failures for KO
+ rise 1 # require 1 successes for OK
+}
+
+vrrp_instance VI_1 {
+ state MASTER
+ interface bond0
+ virtual_router_id 51
+ priority 100
+ advert_int 1
+ authentication {
+ auth_type PASS
+ auth_pass 1111
+ }
+ virtual_ipaddress {
+ 9.59.193.8
+ }
+ track_script {
+ chk_ducc
+ }
+}
+
+ \end{greybatim}
+
+% ========================================
+\end{minipage}
+% ========================================
+
+% ========================================
+\begin{minipage}{\textwidth}
+% ========================================
Sample BACKUP /etc/keepalived/keepalived.conf
- \begin{verbatim}
- ! Configuration File for keepalived
+ \begin{greybatim}
+
+! Configuration File for keepalived
+
+global_defs {
+ script_user ducc
+ enable_script_security
+}
+
+vrrp_script chk_ducc {
+ script "/etc/keepalived/keepalived_evaluator.py"
+ interval 5 # check every 5 seconds
+ fall 2 # require 2 failures for KO
+ rise 1 # require 1 successes for OK
+}
+
+vrrp_instance VI_1 {
+ state BACKUP
+ interface bond0
+ virtual_router_id 51
+ priority 100
+ advert_int 1
+ authentication {
+ auth_type PASS
+ auth_pass 1111
+ }
+ virtual_ipaddress {
+ 9.59.193.8
+ }
+ track_script {
+ chk_ducc
+ }
+}
+
+ \end{greybatim}
+
+% ========================================
+\end{minipage}
+% ========================================
+
+ \medskip
+ In this example, the IP address 9.59.193.8 is managed by the keepalived daemons.
+ It is assigned to the current DUCC master.
+ If can float to another host when the presently assigned master is no longer viable.
- vrrp_instance VI_1 {
- state BACKUP
- interface eth0
- virtual_router_id 51
- priority 100
- advert_int 1
- authentication {
- auth_type PASS
- auth_pass 1111
- }
- virtual_ipaddress {
- 192.168.6.253
- }
- }
+ \medskip
+ See example here:
+ \begin{verbatim}
+ examples/reliable/etc/keepalived/keepalived.conf
\end{verbatim}
+
+% ========================================
+\begin{minipage}{\textwidth}
+% ========================================
+
+ Sample /etc/keepalived/keepalived\_evaluator.py
+
+ \begin{greybatim}
+
+#!/usr/bin/env python
+# -----------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# -----------------------------------------------------------------------
+
+import sys
+
+version_min = [2, 7]
+version_info = sys.version_info
+version_error = False
+if(version_info[0] < version_min[0]):
+ version_error = True
+elif(version_info[0] == version_min[0]):
+ if(version_info[1] < version_min[1]):
+ version_error = True
+if(version_error):
+ print('Python minimum requirement is version '+str(version_min[0])+'.'+str(version_min[1]))
+ sys.exit(1)
+
+import os
+import subprocess
+import traceback
+
+ducc_runtime = '/home/ducc/ducc_runtime'
+ducc_status = os.path.join(ducc_runtime,'bin/ducc_status')
+
+state_dir = fpath = __file__.split('/')[0]
+
+ \end{greybatim}
+
+% ========================================
+\end{minipage}
+% ========================================
+
+% ========================================
+\begin{minipage}{\textwidth}
+% ========================================
+
+ \begin{greybatim}
+
+class Keepalived_Evaluator():
+
+ flag_error = True
+ flag_debug = False
+ flag_info = True
+
+ def __init__(self):
+ pass
+
+ def _cn(self):
+ return self.__class__.__name__
+
+ def _mn(self):
+ return traceback.extract_stack(None,2)[0][2]
+
+ def error(self,mn,text):
+ if(self.flag_error):
+ print mn+' '+text
+
+ def debug(self,mn,text):
+ if(self.flag_debug):
+ print mn+' '+text
+
+ def info(self,mn,text):
+ if(self.flag_info):
+ print mn+' '+text
+
+ def do_cmd(self,cmd):
+ mn = self._mn()
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ text = 'out:'+str(out)
+ self.debug(mn,text)
+ text = 'err:'+str(err)
+ self.debug(mn,text)
+ return out,err
+
+ def get_ducc_status(self):
+ mn = self._mn()
+ cmd = [ducc_status,'--target','localhost']
+ out, err = self.do_cmd(cmd)
+ if('down=0' in out):
+ status = 0
+ else:
+ status = 1
+ text = str(status)
+ self.debug(mn,text)
+ return status
+
+ \end{greybatim}
+% ========================================
+\end{minipage}
+% ========================================
+
+% ========================================
+\begin{minipage}{\textwidth}
+% ========================================
+
+ \begin{greybatim}
+
+ def main(self, argv):
+ mn = self._mn()
+ rc = 0
+ try:
+ rc = self.get_ducc_status()
+ except Exception as e:
+ lines = traceback.format_exc().splitlines()
+ for line in lines:
+ text = line
+ self.error(mn,text)
+ rc = 1
+ text = 'rc='+str(rc)
+ self.info(mn,text)
+ sys.exit(rc)
+
+if __name__ == "__main__":
+ instance = Keepalived_Evaluator()
+ instance.main(sys.argv[1:])
+
+ \end{greybatim}
+
+% ========================================
+\end{minipage}
+% ========================================
+
+ \medskip
+ The script
+ \begin{verbatim}
+ /etc/keepalived/keepalived_evaluator.py
+ \end{verbatim}
+ determines the viability of DUCC on the present host, returning 0 when viable or 1 otherwise.
+ Note that in this example the value of {\em ``ducc\_runtime''} is hard-coded.
+
Linux Commands
Starting keepalived
@@ -96,13 +360,17 @@
Querying keepalived
\begin{verbatim}
- > /sbin/ip addr show dev eth0
- 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
- link/ether 00:21:5e:20:02:84 brd ff:ff:ff:ff:ff:ff
- inet 192.168.3.7/16 brd 192.168.255.255 scope global eth0
- inet 192.168.6.253/32 scope global eth0
- inet6 fe80::221:5eff:fe20:284/64 scope link
- valid_lft forever preferred_lft forever
+ > /sbin/ip addr show dev bond0
+ 8: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
+ link/ether 0c:c4:7a:bc:e6:7a brd ff:ff:ff:ff:ff:ff
+ inet 10.185.47.235/23 brd 10.185.47.255 scope global bond0
+ valid_lft forever preferred_lft forever
+ inet 9.59.193.235/23 brd 9.59.193.255 scope global bond0:0
+ valid_lft forever preferred_lft forever
+ inet 9.59.193.8/32 scope global bond0
+ valid_lft forever preferred_lft forever
+ inet6 fe80::ec4:7aff:febc:e67a/64 scope link
+ valid_lft forever preferred_lft forever
\end{verbatim}
Stopping keepalived
@@ -117,7 +385,7 @@
be configured in the {\em site.ducc.properties} file. Example:
\begin{verbatim}
- ducc.head = 192.168.6.253
+ ducc.head = 9.59.193.8
\end{verbatim}
Use the virtual IP address configured for your host machines keepalived.
Added: uima/uima-ducc/trunk/uima-ducc-examples/.pydevproject
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-examples/.pydevproject?rev=1852934&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-examples/.pydevproject (added)
+++ uima/uima-ducc/trunk/uima-ducc-examples/.pydevproject Mon Feb 4 15:27:45 2019
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?><pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
+</pydev_project>
Added: uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived.conf
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived.conf?rev=1852934&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived.conf (added)
+++ uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived.conf Mon Feb 4 15:27:45 2019
@@ -0,0 +1,31 @@
+! Configuration File for keepalived
+
+global_defs {
+ script_user ducc
+ enable_script_security
+}
+
+vrrp_script chk_ducc {
+ script "/etc/keepalived/keepalived_evaluator.py"
+ interval 5 # check every 5 seconds
+ fall 2 # require 2 failures for KO
+ rise 1 # require 1 successes for OK
+}
+
+vrrp_instance VI_1 {
+ state BACKUP
+ interface bond0
+ virtual_router_id 51
+ priority 100
+ advert_int 1
+ authentication {
+ auth_type PASS
+ auth_pass 1111
+ }
+ virtual_ipaddress {
+ 9.59.193.8
+ }
+ track_script {
+ chk_ducc
+ }
+}
Added: uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived_evaluator.py
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived_evaluator.py?rev=1852934&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived_evaluator.py (added)
+++ uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived_evaluator.py Mon Feb 4 15:27:45 2019
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+# -----------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# -----------------------------------------------------------------------
+
+import sys
+
+version_min = [2, 7]
+version_info = sys.version_info
+version_error = False
+if(version_info[0] < version_min[0]):
+ version_error = True
+elif(version_info[0] == version_min[0]):
+ if(version_info[1] < version_min[1]):
+ version_error = True
+if(version_error):
+ print('Python minimum requirement is version '+str(version_min[0])+'.'+str(version_min[1]))
+ sys.exit(1)
+
+import os
+import subprocess
+import traceback
+
+ducc_runtime = '/home/ducc/ducc_runtime'
+ducc_status = os.path.join(ducc_runtime,'bin/ducc_status')
+
+state_dir = fpath = __file__.split('/')[0]
+
+class Keepalived_Evaluator():
+
+ flag_error = True
+ flag_debug = False
+ flag_info = True
+
+ def __init__(self):
+ pass
+
+ def _cn(self):
+ return self.__class__.__name__
+
+ def _mn(self):
+ return traceback.extract_stack(None,2)[0][2]
+
+ def error(self,mn,text):
+ if(self.flag_error):
+ print mn+' '+text
+
+ def debug(self,mn,text):
+ if(self.flag_debug):
+ print mn+' '+text
+
+ def info(self,mn,text):
+ if(self.flag_info):
+ print mn+' '+text
+
+ def do_cmd(self,cmd):
+ mn = self._mn()
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ text = 'out:'+str(out)
+ self.debug(mn,text)
+ text = 'err:'+str(err)
+ self.debug(mn,text)
+ return out,err
+
+ def get_ducc_status(self):
+ mn = self._mn()
+ cmd = [ducc_status,'--target','localhost']
+ out, err = self.do_cmd(cmd)
+ if('down=0' in out):
+ status = 0
+ else:
+ status = 1
+ text = str(status)
+ self.debug(mn,text)
+ return status
+
+ def main(self, argv):
+ mn = self._mn()
+ rc = 0
+ try:
+ rc = self.get_ducc_status()
+ except Exception as e:
+ lines = traceback.format_exc().splitlines()
+ for line in lines:
+ text = line
+ self.error(mn,text)
+ rc = 1
+ text = 'rc='+str(rc)
+ self.info(mn,text)
+ sys.exit(rc)
+
+if __name__ == "__main__":
+ instance = Keepalived_Evaluator()
+ instance.main(sys.argv[1:])
+
Propchange: uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived_evaluator.py
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/keepalived/keepalived_evaluator.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/sysconfig/keepalived
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/sysconfig/keepalived?rev=1852934&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/sysconfig/keepalived (added)
+++ uima/uima-ducc/trunk/uima-ducc-examples/src/main/reliable/etc/sysconfig/keepalived Mon Feb 4 15:27:45 2019
@@ -0,0 +1,15 @@
+# Options for keepalived. See `keepalived --help' output and keepalived(8) and
+# keepalived.conf(5) man pages for a list of all options. Here are the most
+# common ones :
+#
+# --vrrp -P Only run with VRRP subsystem.
+# --check -C Only run with Health-checker subsystem.
+# --dont-release-vrrp -V Dont remove VRRP VIPs & VROUTEs on daemon stop.
+# --dont-release-ipvs -I Dont remove IPVS topology on daemon stop.
+# --dump-conf -d Dump the configuration data.
+# --log-detail -D Detailed log messages.
+# --log-facility -S 0-7 Set local syslog facility (default=LOG_DAEMON)
+#
+
+KEEPALIVED_OPTIONS="-D -P"
+