Originally, maptail was able to deploy on a web server host to view web service access logs in real time. Now there are multiple web servers that need to be monitored, which is a little troublesome. Therefore, one machine is used to monitor multiple web servers at the same time, because the essence of maptail is a demonstration of tail-f, we can combine this, that is, maptail only needs to have access_log, so we only need to synchronize the access logs on other web machines, inotify + rsync is a good choice. rsync is commonly used for "distribution". This time it is used for "aggregation ". The general structure is as follows:
Configuration process:
1. Upgrade Python to 2.6 ~ 2.7
- #mkdir/root/sourcesoft;cd!$
- #wgethttp://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
- #yuminstallgcc*
- #tar-zxvfPython-2.7.3.tgz
- #cdPython-2.7.3
- #./configure
- #make;makeinstall
- #cd/usr/bin
- #mvpythonpython.bak
- #ln-s/usr/local/bin/pythonpython
Ii. Install nodeJS
- #cd/root/sourcesoft
- #wgethttp://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
- #tar-zxvfnode-v0.8.16.tar.gz
- #cdnode-v0.8.16
- #./configure
- #make;makeinstall
If any problem occurs during the above process, you can solve the problem as follows:
1. If the software cannot be installed on yum, the following error occurs:
Note: If you have upgraded Python, the following message may be displayed: TherewasaproblemimportingoneofthePythonmodulesrequiredtorunyum.
- Solution:
- Find the yum file and edit the py file.
- # Whichyum
- /Usr/bin/yum
- # Vi/usr/bin/yum
- Set
- #! /Usr/bin/python
- Changed:
- Result of whereispython
- #! /Usr/bin/python2.4
2. the following error is prompted when nodejs is installed:
ImportError: Nomodulenamedbz2
- Solution:
- 1.
- # Yuminstall-ybzip2 *
- 2.
- # CdPython-2.7/Modules/zlib
- #./Configure; make; makeinstall
- 3.
- # CdPython-2.7/
- # Python2.7setup. pyinstall
3. Install and start the maptail Module
- #npminstallmaptail-g
Start:
- #nohup/usr/bin/tail-f/var/log/httpd/access_log|/usr/local/bin/node/usr/local/bin/maptail-h192.168.158.216-p8080&
4. browsing:
Enter http: // 192.168.158.216: 8080 in the browser to access
5. extended use of inotify + rsync for simultaneous monitoring of multiple hosts
1. Install inotify
- #tarxfinotify-tools-3.14.tar.gz
- #cdinotify-tools-3.14
- #./configure&&make&&makeinstall
2. Configuration:
192.168.158.219 ==> 192.168.158.216
Configuration on 219:
- #vim/root/scripts/in_rsync.sh
- #!/bin/bash
- host1=192.168.158.216
- src=/usr/local/apache/logs/web
- dst1=weblog219
- user1=root
- /usr/local/bin/inotifywait-mrq--timefmt'%d/%m/%y%H:%M'--format'%T%w%f%e'-emodify,delete,create,attrib$src\
- |whilereadfiles;do
- /usr/bin/rsync-zrtopg--delete--password-file=/etc/rsyncd.pass$src$user1@$host1::$dst1>/dev/null2>&1
- echo"${files}wasrsynced">>/tmp/rsync.log2>&1>/dev/null
- done
- #vim/etc/rsyncd.pass
- 123456
- #chmod600/etc/rsyncd.pass
- #nohup/root/scripts/in_rsync.sh&
Configuration on 216:
- # Vim/etc/rsyncd. conf
- Uid = root
- Gid = root
- Usechroot = no
- Maxconnections = 36000
- Strictmodes = yes
- Logfile =/var/log/rsyncd. log
- Pidfile =/var/run/rsyncd. pid
- Lockfile =/var/run/rsync. lock
- Logformat = % t % a % m % f % B
- [Weblog219]
- Path =/www/log219/
- Authusers = root
- Readonly = no
- Hostsallow = 192.168.158.0/24
- List = no
- Uid = root
- Gid = root
- Secretsfile =/etc/rsyncd. pass
- Ignoreerrors = yes
- # Vim/etc/rsyncd. pass
- Root: 123456
- # Chmod600/etc/rsyncd. pass
- #/Usr/bin/rsync -- daemon
6. Start and verify the new port
Nohup/usr/bin/tail-f/var/log/httpd/access_log |/usr/local/bin/node/usr/local/bin/maptail-h192.168.158.216-p8219 &
Enter http: // 192.168.158.216: 8080 and http: // 192.168.158.216: 8219 in the browser to view
This article is from the "Ro blog" blog, please be sure to keep this source http://luoweiro.blog.51cto.com/2186161/1169840