Back to home page

Enduro/X

 
 

    


0001 Building Enduro/X On MacOS Platform
0002 ===================================
0003 :doctype: book
0004 
0005 == About manual
0006 This manual describes how to build 'Enduro/X' on fresh installed OS X. 
0007 Document is based on operating system version 10.11 (El Capitan). Generally 
0008 version is considered as development time only and experimental for production 
0009 use for low queue and message density setups. This is due to fact, that MAC OS X 
0010 does not provide Posix queue API and emulation is in use. During the porting 
0011 Enduro/X to OSX it have been monitored that system can freeze. How ever the 
0012 emulated queues on GNU/Linux works good. So there might be a bug in OSX Posix 
0013 thread mutex routines. Also OSX does not support robust mutexes which means, 
0014 that if some process get the lock for emulated queue and process is being killed, 
0015 then lock is never released and if this queue is *ndrxd(8)* main q, then 
0016 system is stalled. In future release this might be fixed with advancing 
0017 *tprecover(8)* to do pings to *ndrxd(8)* and doing kill and reboot the
0018 'ndrxd' in learning mode.
0019 
0020 
0021 == Overview
0022 
0023 Enduro/X normally use Operating System provided Posix kernel queues,
0024 however OS X does not have this subsystem, however Enduro/X provides queue 
0025 emulation via POSIX Threads functionality. This includes process shared 
0026 semaphores and memory mapped files. Enduro/X CMake scripts will automatically
0027 do the configuration and enable this functionality.
0028 
0029 In the result queues will we listed on file system. The recommendation is 
0030 to use separate folder this for example "/tmp/mq".
0031 
0032 This document covers only core functionality of the Enduro/X building. That's 
0033 mean that building of:
0034 
0035 . documentation;
0036 
0037 is out of the scope.
0038 
0039 == Operating System Configuration
0040 
0041 For OS configuration settings 
0042 see ex_adminman(guides)(Enduro/X Administration Manual, Setup System chapter).
0043 
0044 == Installation process
0045 
0046 This chapter describes how to install system dependencies needed from build
0047 and how to build Enduro/X it self.
0048 
0049 === Packages to be installed
0050 
0051 . Apple Xcode (https://developer.apple.com/xcode/) install from Appstore or 
0052 other sources
0053 
0054 . Git source code version control system
0055 
0056 . CMake (https://cmake.org/install/)
0057 
0058 . Install latest bison
0059 
0060 ---------------------------------------------------------------------
0061 $ brew install bison
0062 ---------------------------------------------------------------------
0063 
0064 
0065 === Getting the source code
0066 
0067 For test purposes we will parepare new user for which Enduro/X will built.
0068 
0069 ---------------------------------------------------------------------
0070 $ sudo -s
0071 # dscl . -create /Users/user1
0072 # dscl . -create /Users/user1 UserShell /bin/bash
0073 # dscl . -create /Users/user1 RealName "Test User" 
0074 # dscl . -create /Users/user1 UniqueID "510"
0075 # dscl . -create /Users/user1 PrimaryGroupID 20
0076 # dscl . -create /Users/user1 NFSHomeDirectory /Users/user1
0077 # dscl . -passwd /Users/user1 password 
0078 # su - user1
0079 $ cd /Users/user1
0080 $ git clone https://github.com/endurox-dev/endurox endurox
0081 ---------------------------------------------------------------------
0082 
0083 To work with CMake, you need to put the 'cmake' binary into the path. You may do that by
0084 
0085 ---------------------------------------------------------------------
0086 $ cat << EOF >> ~/.bashrc
0087 export PATH=/usr/local/opt/bison/bin:$PATH:/Applications/CMake.app/Contents/bin
0088 EOF
0089 
0090 $ chmod +x .bashrc
0091 ---------------------------------------------------------------------
0092 
0093 === Enduro/X basic Environment configuration for HOME directory
0094 This code bellow creates 'ndrx_home' executable file which loads basic environment, 
0095 so that you can use sample configuration provided by Enduro/X in 'sampleconfig' directory. 
0096 This also assumes that you are going to install to '$HOME/endurox/dist' folder.
0097 
0098 NOTE: If we install the libaries in dist/lib64, OS X will still try for to get the the
0099 shared libraries for origin build folders. Thus it is recommended to configure environment file
0100 bit more advanced, to enable OS X library loader to search original (build) lib folders firstly.
0101 
0102 NOTE: For test cases like 021 (XA Testing) and 028 (TMQUEUE) tests, the scripts uses
0103 'DYLD_FALLBACK_LIBRARY_PATH' environment variable. Hoever testing scripts are using '/bin/bash',
0104 which means that by enabled SIP (System Integrity Protection), the variable is dropped. Thus 
0105 pass all ATMI tests, you have to disable SIP.
0106 
0107 ---------------------------------------------------------------------
0108 
0109 $ bash
0110 
0111 $ cat << EOF > $HOME/ndrx_home
0112 #!/bin/bash
0113 
0114 echo "Loading ndrx_home ..."
0115 # Where app domain lives
0116 export NDRX_APPHOME=/Users/user1/endurox
0117 # Where NDRX runtime lives
0118 export NDRX_HOME=/Users/user1/endurox/dist
0119 # Debug config too
0120 export NDRX_DEBUG_CONF=/Users/user1/endurox/sampleconfig/debug.conf
0121 # NDRX config too.
0122 export NDRX_CONFIG=/Users/user1/endurox/sampleconfig/ndrxconfig.xml
0123 
0124 export PATH=$PATH:/Users/user1/endurox/dist/bin
0125 export FLDTBLDIR=/Users/user1/endurox/ubftest/ubftab
0126 
0127 # For testing firstly use original folder where dynamic libraries were built:
0128 for f in libthpool libexuuid libcgreen libubf libnstd libnetproto libatmi libpsstdlib libps libexnet libatmisrv libatmiclt tmqueue tmsrv; do
0129         export DYLD_FALLBACK_LIBRARY_PATH=\$DYLD_FALLBACK_LIBRARY_PATH:/Users/user1/endurox/$f
0130 done
0131 
0132 export NDRX_QPATH=/tmp/mq
0133 
0134 if [ ! -d "\$NDRX_QPATH" ]; then
0135         mkdir \$NDRX_QPATH
0136 fi
0137 
0138 # add install folder too
0139 export DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/Users/user1/endurox/dist/lib
0140 
0141 export NDRX_QPATH=/tmp/mq
0142 
0143 if [ ! -d "\$NDRX_QPATH" ]; then
0144         mkdir \$NDRX_QPATH
0145 fi
0146 
0147 # Speedup a bit q open & close
0148 export NDRX_MSGMAX=100
0149 export NDRX_MSGSIZEMAX=40000
0150 
0151 ################################################################################
0152 # In case if building with Postgresql DB database testing support
0153 # or building endurox-java with Oracle DB tests (03_xapostgres), then
0154 # configure bellow setting (demo values provided):
0155 # If so - uncomment bellow
0156 ################################################################################
0157 #export EX_PG_HOST=localhost
0158 #export EX_PG_USER=exdbtest
0159 #export EX_PG_PASS=exdbtest1
0160 # currently uses default port
0161 #export EX_PG_PORT=5432
0162 #export EX_PG_DB=xe
0163 
0164 EOF
0165 
0166 $ chmod +x $HOME/ndrx_home
0167 
0168 ---------------------------------------------------------------------
0169 
0170 === Configuring PostgreSQL
0171 
0172 If Enduro/X PostgreSQL driver is needed to be build for MacOS, the PostgreSQL
0173 needs to be installed for build and test purposes. For installation purposes 'brew'
0174 is used.
0175 
0176 --------------------------------------------------------------------------------
0177 
0178 $ su - user1
0179 $ brew update
0180 $ brew install postgresql
0181 
0182 --------------------------------------------------------------------------------
0183 
0184 Once PostgreSQL is installed, update the configuration and create the database.
0185 Also needs to ensure that *user1* has write permissions to 'var' folder:
0186 
0187 --------------------------------------------------------------------------------
0188 
0189 --- Add user to admin groups so that it has access to /usr/local/var
0190 sudo dseditgroup -o edit -a user1 -t user admin
0191 sudo dseditgroup -o edit -a user1 -t user wheel
0192 
0193 -- ensure that user1 has write permissions:
0194 $ sudo chmod g+w /usr/local/var/
0195 
0196 -- Create the DB for postgres. If installing Postgresql from other user, then
0197 -- folder needs to be removed.
0198 $ initdb /usr/local/var/postgres
0199 
0200 $ pg_ctl -D /usr/local/var/postgres -l logfile start
0201 
0202 $ createuser exdbtest
0203 
0204 $ createdb xe
0205 
0206 $ psql -d template1
0207 
0208 > alter user exdbtest with encrypted password 'exdbtest1';
0209 > grant all privileges on database xe to exdbtest;
0210 > \q
0211 
0212 --------------------------------------------------------------------------------
0213 
0214 Configuration files needs to be updated for authentication and distributed
0215 transactions must be enabled too.
0216 
0217 Edit */usr/local/var/postgres/postgresql.conf*, set "max_prepared_transactions"
0218 to 1000.
0219 
0220 --------------------------------------------------------------------------------
0221 max_prepared_transactions = 1000                # zero disables the feature
0222 --------------------------------------------------------------------------------
0223 
0224 For access permissions and network configuration, update 
0225 */usr/local/var/postgres/pg_hba.conf*, so that it contains following:
0226 
0227 --------------------------------------------------------------------------------
0228 local   all             all                                     peer
0229 host    all             all             127.0.0.1/32            md5
0230 host    all             all             ::1/128                 md5
0231 --------------------------------------------------------------------------------
0232 
0233 
0234 Restart PostgreSQL:
0235 --------------------------------------------------------------------------------
0236 $ pg_ctl -D /usr/local/var/postgres stop
0237 $ pg_ctl -D /usr/local/var/postgres start
0238 --------------------------------------------------------------------------------
0239 
0240 To add PostgreSQL to system startup, execute:
0241 
0242 --------------------------------------------------------------------------------
0243 
0244 $ brew services start postgresql
0245 
0246 --------------------------------------------------------------------------------
0247 
0248 *NOTE:* Auto startup adding works only in case if brew was installed from 'user1'.
0249 
0250 === Building the code
0251 
0252 This install the binary version to /Users/user1/endurox:
0253 
0254 ---------------------------------------------------------------------
0255 $ cd /Users/user1/endurox
0256 $ cmake -DDEFINE_DISABLEDOC=ON -DCMAKE_INSTALL_PREFIX:PATH=`pwd`/dist .
0257 $ make 
0258 $ make install
0259 ---------------------------------------------------------------------
0260 
0261 
0262 == Unit Testing
0263 
0264 Enduro/X basically consists of two parts:
0265 . XATMI runtime;
0266 . UBF/FML buffer processing. 
0267 Each of these two sub-systems have own units tests.
0268 
0269 === UBF/FML Unit testing
0270 ---------------------------------------------------------------------
0271 $ cd /Users/user1/endurox/ubftest
0272 $ ./ubfunit1 2>/dev/null
0273 Running "main" (76 tests)...
0274 Completed "ubf_basic_tests": 198 passes, 0 failures, 0 exceptions.
0275 Completed "ubf_Badd_tests": 225 passes, 0 failures, 0 exceptions.
0276 Completed "ubf_genbuf_tests": 334 passes, 0 failures, 0 exceptions.
0277 Completed "ubf_cfchg_tests": 2058 passes, 0 failures, 0 exceptions.
0278 Completed "ubf_cfget_tests": 2232 passes, 0 failures, 0 exceptions.
0279 Completed "ubf_fdel_tests": 2303 passes, 0 failures, 0 exceptions.
0280 Completed "ubf_expr_tests": 3106 passes, 0 failures, 0 exceptions.
0281 Completed "ubf_fnext_tests": 3184 passes, 0 failures, 0 exceptions.
0282 Completed "ubf_fproj_tests": 3548 passes, 0 failures, 0 exceptions.
0283 Completed "ubf_mem_tests": 4438 passes, 0 failures, 0 exceptions.
0284 Completed "ubf_fupdate_tests": 4613 passes, 0 failures, 0 exceptions.
0285 Completed "ubf_fconcat_tests": 4768 passes, 0 failures, 0 exceptions.
0286 Completed "ubf_find_tests": 5020 passes, 0 failures, 0 exceptions.
0287 Completed "ubf_get_tests": 5247 passes, 0 failures, 0 exceptions.
0288 Completed "ubf_print_tests": 5655 passes, 0 failures, 0 exceptions.
0289 Completed "ubf_macro_tests": 5666 passes, 0 failures, 0 exceptions.
0290 Completed "ubf_readwrite_tests": 5764 passes, 0 failures, 0 exceptions.
0291 Completed "ubf_mkfldhdr_tests": 5770 passes, 0 failures, 0 exceptions.
0292 Completed "main": 5770 passes, 0 failures, 0 exceptions.
0293 ---------------------------------------------------------------------
0294 
0295 === XATMI Unit testing
0296 ATMI testing might take some time. Also ensure that you have few Gigabytes of free 
0297 disk space, as logging requires some space. To run the ATMI tests do following:
0298 ---------------------------------------------------------------------
0299 $ cd /Users/user1/endurox/atmitest
0300 $ nohup ./run.sh &
0301 $ tail -f /Users/user1/endurox/atmitest
0302 ...
0303 ************ FINISHED TEST: [test028_tmq/run.sh] with 0 ************
0304 Completed "atmi_test_all": 28 passes, 0 failure, 0 exceptions.
0305 Completed "main": 28 passes, 0 failure, 0 exceptions.
0306 ---------------------------------------------------------------------
0307 
0308 == Limitations
0309 
0310 Due to fact that MacOS does not support System-V nor Posix queues, the queues
0311 are being emulated in Enduro/X based on shared memory. However, the implementation
0312 does not guarantee that processes can recover from crashes within the emulation
0313 library. Thus MacOS Enduro/X use is only recommended for development purposes.
0314 The commercial support for MacOS instances are not provided.
0315 
0316 If planning to use tmsrv or tmqueue with the MacOS, then please ensure that
0317 data folders are mounted on drivers which are case sensitive, as Enduro/X
0318 stores transactions logs and messages on disk identified by base64 encoding,
0319 which is case sensitive. Thus if using default MacOS settings (case insensitive),
0320 expect that transaction or message processing might randomly corrupt (e.g. lose
0321 messages, etc).
0322 
0323 == Conclusions
0324 At finish you have a configured system which is read to process the transactions
0325 by Enduro/X runtime. It is possible to copy the binary version ('dist') folder
0326 to other same architecture machine and run it there without need of building.
0327 
0328 :numbered!:
0329 
0330 [bibliography]
0331 Additional documentation 
0332 ------------------------
0333 This section lists additional related documents.
0334 
0335 [bibliography]
0336 .Resources
0337 - [[[BINARY_INSTALL]]] See Enduro/X 'binary_install' manual.
0338 
0339 
0340 ////////////////////////////////////////////////////////////////
0341 The index is normally left completely empty, it's contents being
0342 generated automatically by the DocBook toolchain.
0343 ////////////////////////////////////////////////////////////////