ASNMTAP

 view release on metacpan or  search on metacpan

lib/ASNMTAP/Asnmtap/Applications.pod  view on Meta::CPAN

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 stop() {
   # Stop daemons
   echo "Stop: '$AMNAME' ..."
   /etc/init.d/root-display stop
   /etc/init.d/root-collector stop
   /etc/init.d/root-importDataThroughCatalog stop
 }

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 # See how we were called.
 case "$1" in
   start)
 #            start
            ;;
   stop)
 #            stop
            ;;
   *)
            echo "Usage: '$AMNAME' {start|stop}"
            exit 1
 esac

 exit 0

 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 ln -s /opt/asnmtap.sh /etc/init.d/asnmtap

 /etc/rc3.d/S99asnmtap /etc/init.d/asnmtap
 /etc/rc3.d/K99asnmtap /etc/init.d/asnmtap
 /etc/rc0.d/S99asnmtap /etc/init.d/asnmtap
 /etc/rc0.d/K99asnmtap /etc/init.d/asnmtap

=back

=back

=back

=back

=head1 PROGRAMS

=over 4

=item located at /opt/asnmtap/applications

=over 4

=item archive.pl

the Archiver. 

 This perl program
 - create automatically new comments and events archive tables when needed.
 - archiving the comments and events to the correspondending archiving tables
 - removes the old unused cgisess files
 - make backups and zips the csv, sql error, week, debug and report files
 - removes the old zipped csv, sql error, week, debug and report files

=item archive.sh

=over 4

=item Central ASNMTAP

 archive.pl -A ArchiveCT -c F -r T -d T

=item Central Apache

 archive.pl -c T -r F -d F

=item Distributed ASNMTAP

 archive.pl -A ArchiveCT -c T -r T -d F

=back

Shell script to run archive.pl with the default command line options

 cd /opt/asnmtap/applications/
 cp archive.sh-orig archive.sh
 chmod 755 archive.sh

 crontab -e
  0  1 * * * /opt/asnmtap/applications/archive.sh > /dev/null

 cd /opt/asnmtap/applications/
 mv archive.sh-orig archive-apache.sh
 chmod 755 archive-apache.sh
 chown <apache>:<apache> archive-apache.sh

 su - <apache>
 crontab -e
  0  1 * * * /opt/asnmtap/applications/archive-apache.sh > /dev/null

=back

=item located at /opt/asnmtap/applications/bin

=over 4

=item generateCollectorDaemonSchedulingReports.pl

this program generating automatically Collector Daemon Scheduling Reports in PDF format

 Located at URL: http://asnmtap.citap.be/results/_ASNMTAP/reports/

=item generateCollectorDaemonSchedulingReports.sh

Shell script to run generateCollectorDaemonSchedulingReports.pl with the default command line options

 cd /opt/asnmtap/applications/bin
 mv generateCollectorDaemonSchedulingReports.sh-orig generateCollectorDaemonSchedulingReports.sh
 chmod 755 generateCollectorDaemonSchedulingReports.sh

 crontab -e
  0  0 * * * /opt/asnmtap/applications/bin/generateCollectorDaemonSchedulingReports.sh > /dev/null

lib/ASNMTAP/Asnmtap/Applications.pod  view on Meta::CPAN


   server-id=1
   log-bin=asnmtap
   log-slave-updates
   binlog-ignore-db=mysql
   replicate-ignore-db=mysql
   report-host=slave-server.citap.com
   auto_increment_increment = 2
   auto_increment_offset = 1

 [mysql.server]
   user=mysql
   basedir=/var/lib

 [safe_mysqld]
   err-log=/var/log/mysqld.log
   pid-file=/var/run/mysqld/mysqld.pid

 # If those options are not present, add them and restart the server.

 mysql -u root -p
 mysql> SHOW MASTER STATUS;
 # +---------------+----------+--------------+------------------+
 # |      File     | Position | Binlog_Do_DB | Binlog_Ignore_DB |
 # +---------------+----------+--------------+------------------+
 # | mysql-bin.001 | 73       | checklist    | mysql            |
 # +---------------+----------+--------------+------------------+
 mysql> QUIT;

 Write down the parrameters from SHOW MASTER STATUS, when master didn't exists befire!!!

 The File column shows the name of the log, while Position shows the offset. In the above example, the binary log value is mysql-bin.001 and the offset is 73. Record the values. You will need to use them later when you are setting up the slave. Once ...

=item onto the slave server:

 Make sure there are NO update queries on the slave server at this point!!!

 mysql -u root -p
 mysql> STOP SLAVE;                                     <-- if replication was running
 mysql> QUIT;

 when master is in production before the slave exist:

   mysql -u root -p
   mysql> CREATE DATABASE asnmtap;
   mysql> QUIT;
   mysql -u root -p asnmtap < asnmtap.sql
   mysql -u root -p
 or
   make sure mysqld is dead!!!
   copy and untar mysql-snapshot.tar created earlier

 mysql -u root -p
 mysql> GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, CREATE, CREATE TEMPORARY TABLES, DROP ON asnmtap.* TO 'asnmtap'@'localhost' IDENTIFIED BY 'passwd'; 
 mysql> GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, CREATE, CREATE TEMPORARY TABLES, DROP ON asnmtap.* TO 'asnmtap'@'hostname-master-server' IDENTIFIED BY 'passwd'; 
 mysql> GRANT SELECT ON asnmtap.* TO 'asnmtapro'@'hostname-slave-server' IDENTIFIED BY 'passwd-ro';
 mysql> GRANT SELECT, SUPER, REPLICATION CLIENT, REPLICATION SLAVE, RELOAD ON asnmtap.* TO 'replication'@'hostname-master-server' IDENTIFIED BY 'passwd-replication';
 mysql> FLUSH TABLES WITH READ LOCK;
 mysql> QUIT;

 Stop the server that is to be used as a slave server and add the following to its `my.cnf' file. The slave_id value, like the master_id value, must be an integer value from 1 to 2^32 - 1. In addition, it is very important that the ID of the slave be...

 vi /etc/my.cnf
 [mysqld]
   datadir=/var/lib/mysql
   socket=/var/lib/mysql/mysql.sock
   port=3306

   server-id=2
   log-bin=asnmtap
   log-slave-updates
   binlog-ignore-db=mysql
   replicate-ignore-db=mysql
   report-host=master-server.citap.com
   auto_increment_increment = 2
   auto_increment_offset = 2

 [mysql.server]
   user=mysql
   basedir=/var/lib

 [safe_mysqld]
   err-log=/var/log/mysqld.log
   pid-file=/var/run/mysqld/mysqld.pid

 Start the slave server. If it has been replicating previously, start the slave server with the --skip-slave-start option. You also may want to start the slave server with the --log-warnings option. That way, you will get more messages about problems...

 Execute the following command on the slave, replacing the values within <> with the actual values relevant to your system:

       This is where you put the values you got earlier from SHOW MASTER STATUS from 2)

 mysql> CHANGE MASTER TO
          MASTER_HOST='<master hostname>',
          MASTER_USER='<replication username>',
          MASTER_PASSWORD='<replication password>',
          MASTER_LOG_FILE='<recorded log file name>',   <-- replace with the value show 'SHOW MASTER STATUS' on the master server
          MASTER_LOG_POS=<recorded log offset>;         <-- replace with the value show 'SHOW MASTER STATUS' on the master server

 mysql> START SLAVE;                                    <-- if you want to restart replication

 mysql> SHOW MASTER STATUS;
        write down the values

 mysql> QUIT;

 At this point you got master -> slave replication

=item onto the master server, part II:

 copy the slave server *.bin.* (binary logs), put it in the master server mysql data dir

 mysql> STOP SLAVE;                                     <-- if replication was running
        This is where you put the values you got earlier from SHOW MASTER STATUS from 3)

 mysql> CHANGE MASTER TO
          MASTER_HOST='<slave hostname>',
          MASTER_USER='<replication username>',
          MASTER_PASSWORD='<replication password>',
          MASTER_LOG_FILE='<recorded log file name>',   <-- replace with the value show 'SHOW MASTER STATUS' on the master server
          MASTER_LOG_POS=<recorded log offset>;         <-- replace with the value show 'SHOW MASTER STATUS' on the master server

 mysql> START SLAVE;                                    <-- if you want to restart replication

 At this point you got master -> slave -> master replication

 You can now execute any query on any of them, and it will appear on both. 

 We will do it always onto the master server, unless the master server is down then we uses the slave server!!!

=back

=item Update your ASNMTAP configuration

 vi /opt/asnmtap/Asnmtap.cnf

 Here you can modify all the varibales used by the ASNMTAP package !!!

 vi /opt/asnmtap/applications/Applications.cnf

 URL: http://asnmtap.citap.be/asnmtap/cgi-bin/sadmin/index.pl

 regarding the server administrator, the default username: `sadmin` and password: `a1A`

 Now you can build your config !!!

=back

lib/ASNMTAP/Asnmtap/Applications.pod  view on Meta::CPAN

 openssl x509 -in server-ca.crt -text -noout

=item Step 2: Make a key and a certificate for the web server:

 openssl genrsa -des3 -out citap-server.key 1024
 openssl req -new -key citap-server.key -out citap-server.csr
   ...
   Common Name (eg, your name or your server's hostname) []:secure.citap.com <=== This must be the real FQDN of your server!!!
 openssl rsa -in citap-server.key -out citap-server-nopass.key
 openssl x509 -req -in citap-server.csr -out citap-server.crt -sha1 -CA server-ca.crt -CAkey server-ca.key -CAcreateserial -days 3650
 openssl x509 -in citap-server.crt -text -noout

=item Step 3: Creating Client Certificates for Authentication 

 openssl genrsa -des3 -out alex-peeters.key 1024
 openssl req -new -key alex-peeters.key -out alex-peeters.csr
 openssl x509 -req -in alex-peeters.csr -out alex-peeters.crt -sha1 -CA server-ca.crt -CAkey server-ca.key -CAcreateserial -days 3650
 openssl pkcs12 -export -in alex-peeters.crt -inkey alex-peeters.key -name "Alex Peeters" -out alex-peeters.p12
 openssl pkcs12 -in alex-peeters.p12 -clcerts -nokeys -info

 when:
   [error] Re-negotiation handshake failed: Not accepted by client!?
   [error] Certificate Verification: Error (20): unable to get local issuer certificate

 vi /etc/httpd/cond.d/ssl.conf
   SSLCertificateFile /etc/httpd/conf/ssl.crt/citap-server.crt
   SSLCertificateKeyFile /etc/httpd/conf/ssl.key/citap-server.key
   SSLCertificateChainFile /etc/httpd/conf/ssl.crt/server-ca.crt
   SSLCACertificateFile /etc/httpd/conf/ssl.crt/server-ca.crt

=back

=back

=item MySQL

=over 4

=item A -> B -> C -> A replication

MySQL Reference Manual                  http://mysqld.active-venture.com/

It is safe to connect servers in a circular master/slave relationship with log-slave-updates enabled. Note, however, that many queries will not work correctly in this kind of setup unless your client code is written to take care of the potential prob...

A -> B -> C -> A

Server IDs are encoded in the binary log events. A will know when an event it reads had originally been created by A, so A will not execute it and there will be no infinite loop. But this circular setup will work only if you only if you perform no co...

=over 4

=item PURGE MASTER LOGS

PURGE {MASTER|BINARY} LOGS TO 'log_name'

PURGE {MASTER|BINARY} LOGS BEFORE 'date'

Deletes all the binary logs listed in the log index that are strictly prior to the specified log or date. The logs also are removed from this list recorded in the log index file, so that the given log now becomes the first.

If you have an active slave that is currently reading one of the logs you are trying to delete, this command does nothing and fails with an error. However, if you have a dormant slave, and happen to purge one of the logs it wants to read, the slave w...

You must first check all the slaves with SHOW SLAVE STATUS to see which log they are reading, then do a listing of the logs on the master with SHOW MASTER LOGS, find the earliest log among all the slaves (if all the slaves are up to date, this will b...

=item RESET MASTER

Deletes all binary logs listed in the index file, resetting the binlog index file to be empty

=item RESET SLAVE

Makes the slave forget its replication position in the master's binlogs. This statement is meant to be used for a clean start: it deletes the `master.info' and `relay-log.info' files, all the relay logs, and starts a new relay log. 

Note: All relay logs are deleted, even if they had not been totally executed by the slave SQL thread. (This is a condition likely to exist on a replication slave that is highly loaded, or if you have issued a STOP SLAVE statement.) Connection informa...

=item How do I configure a slave if the master is already running and I do not want to stop it?

There are several options. If you have taken a backup of the master at some point and recorded the binlog name and offset ( from the output of SHOW MASTER STATUS ) corresponding to the snapshot, do the following:

Make sure the slave is assigned a unique server ID. 

Execute the following statement on the slave, filling in appropriate values for each parameter: 

 mysql> CHANGE MASTER TO
   ->     MASTER_HOST='master_host-name',
   ->     MASTER_USER='master_user_name',
   ->     MASTER_PASSWORD='master_pass',
   ->     MASTER_LOG_FILE='recorded_log_name',
   ->     MASTER_LOG_POS=recorded_log_pos;

Execute START SLAVE on the slave. 

If you do not have a backup of the master already, here is a quick way to do it consistently:

 FLUSH TABLES WITH READ LOCK 
 gtar zcf /tmp/backup.tar.gz /var/lib/mysql (or a variation of this) 
 SHOW MASTER STATUS - make sure to record the output - you will need it later 
 UNLOCK TABLES 

An alternative is taking an SQL dump of the master instead of a binary copy like above; for this you can use mysqldump --master-data on your master and later run this SQL dump into your slave. However, this is slower than makeing a binary copy.

No matter which of the two methods you use, afterwards follow the instructions for the case when you have a snapshot and have recorded the log name and offset. You can use the same snapshot to set up several slaves. As long as the binary logs of the ...

You can also use LOAD DATA FROM MASTER. This is a convenient command that takes a snapshot, restores it to the slave, and adjusts the log name and offset on theslave all at once. In the future, LOAD DATA FROM MASTER will be the recommended way to set...

=back

=item Contrains

Foreign keys definitions are subject to the following conditions: 

Both tables must be InnoDB type!

In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order. 

In the referenced table, there must be an index where the referenced columns are listed as the first columns in the same order. 

Index prefixes on foreign key columns are not supported. One consequence of this is that BLOB and TEXT columns cannot be included in a foreign key, because indexes on those columns must always include a prefix length. 

 [CONSTRAINT symbol] FOREIGN KEY [id] (index_col_name, ...)
   REFERENCES tbl_name (index_col_name, ...)
   [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]
   [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT}]

 SET FOREIGN_KEY_CHECKS = 0; or SET FOREIGN_KEY_CHECKS = 1;

=item How to import a *.sql generated recovery file?

 mysql -u root -p
   -> USE asnmtap;

      If you use LOAD DATA INFILE ... the file must be on the server
   -> LOAD DATA LOW_PRIORITY INFILE '<filename>.sql' INTO TABLE events FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n';

      If you use LOAD DATA LOCAL INFILE ... the file is expected to be on the client.
      If you specify the keyword LOW_PRIORITY, execution of the LOAD DATA statement is delayed until no other clients are reading from the table. 
   -> LOAD DATA LOW_PRIORITY LOCAL INFILE '<filename>.sql' INTO TABLE events FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n';

=item How to import drop a InnoDB table that is referenced by a FOREIGN KEY constraint?

InnoDB does not allow you to drop a table that is referenced by a FOREIGN KEY constraint, unless you do SET FOREIGN_KEY_CHECKS=0. When you drop a table, the constraints that were defined in its create statement are also dropped. 

=back

=back

=head1 REQUIREMENTS

=over 4

=item Linux (Centos/Redhat EL3 and EL4)

 Staring from a core installation you need:

 rpm -i autoconf-2.60.noarch.rpm
 rpm -i automake-1.10.noarch.rpm



( run in 0.873 second using v1.01-cache-2.11-cpan-39bf76dae61 )