Use Saltstack to deploy ganglia clients gmond and gangliagmond
Process:
1. install some dependent packages
2. Compile and install the libconfuse package
3. Compile and install ganglia
4. Configure gmond and start gmond
Preparation:
1. One master
2. source file:
Salt: // tools/Ganglia/package/ganglia-3.6.0.tar.gz
Salt: // tools/Ganglia/package/confuse-2.7.tar.gz
3. Eight minion servers
Software is installed in/usr/local/
Start:
(Here I write sls files separately for ease of adjustment and understanding)
1. Install Dependencies
# Check package && installpkg: cmd.run: - name: yum install -y gcc glibc glibc-common rrdtool rrdtool-devel apr apr-devel expat expat-devel pcre pcr e-devel dejavu-lgc-sans-mono-fonts dejavu-sans-mono-fonts zlib-devel
2. Compile and install libconfuse
# Get confuseconfuse-2.7: file.managed: - name: /home/tools/Ganglia/package/confuse-2.7.tar.gz - source: salt://tools/Ganglia/package/confuse-2.7.tar.gz# Extract itextract-confuse: cmd.run: - cwd: /home/tools/Ganglia/package - name: tar xvf confuse-2.7.tar.gz - require: - file: confuse-2.7# Configure itconfigure-confuse: cmd.run: - name: ./configure CFLAGS=-fPIC --disable-nls && make && make install - cwd: /home/tools/Ganglia/package/confuse-2.7 - unless: test -d /usr/local/confuse
Row 3 copies the file to the minion directory.
Row 5th is the source of the file. For details about copying the entire folder, refer to the previous article.
The second line is the current folder when the command is executed.
The fourth line is the executed command.
Rows 12th and 13 are the final goal. Only when the result is reached will the succeed be returned.
The first line is to determine whether a folder exists. If the folder exists, the name command is not executed. If the folder does not exist, the command is executed.
3. Compile and install ganlia
# Get itganglia-3.6.0: file.managed: - name: /home/tools/Ganglia/package/ganglia-3.6.0.tar.gz - source: salt://tools/Ganglia/package/ganglia-3.6.0.tar.gz# Extract itextract-ganglia: cmd.run: - cwd: /home/tools/Ganglia/package - name: tar xvf ganglia-3.6.0.tar.gz - require: - file: ganglia-3.6.0# Configure itconfigure-ganglia: cmd.run: - name: ./configure --prefix=/usr/local/ganglia && make && make install - cwd: /home/tools/Ganglia/package/ganglia-3.6.0 - unless: test -d /usr/local/ganglia
This step is not detailed. It is similar to the previous step.
4. Configure gmond
/usr/local/ganglia/etc/gmond.conf: file.managed: - source: salt://ganglia/gmond.conf - makedirs: True - user: nobody - group: nobody - mode: 777/etc/init.d/gmond: file.managed: - source: salt://ganglia/gmond - user: nobody - group: nobody - mode: 777#add-chkconfig:# cmd.run:# - name: service gmond start && chkconfig --add gmond# - require:# - file: /usr/local/ganglia/etc/gmond.conf
Configuration file:
/Srv/salt/ganlia/gmond. conf
The Startup File is changed:
/Srv/salt/ganglia/gmond
The sls file is also:
/Srv/salt/ganglia
Run:
salt -E "^s1-3-*" state.sls ganglia.confuse_configure.slssalt -E "^s1-3-*" state.sls ganglia.ganglia_configure.slssalt -E "^s1-3-*" state.sls ganglia.gmond_configuration.sls
OK