mysqldump <source_db> <source_table> | gzip -9 |  ssh <target_server_IP> "gunzip - | mysql <target_db>"

via cron:

*/10 * * * * root mysqldump --defaults-extra-file="/root/.my.cnf" <source_db> <source_table> | gzip -9 |  ssh <target_server_IP> "gunzip - | mysql <target_db>"

example:

mysqldump testdb table1 | gzip -9 |  ssh 192.168.0.1 "gunzip - | mysql testdb2"

in /etc/crontab :

*/3 * * * * root /usr/local/bin/check_la.sh

------------------------------------------

/usr/local/bin/check_la.sh :

if [[ $(uptime | sed -e 's/.*average:\ \(.*\)\..*,.*,.*/\1/') -ge 16 ]]; then

/usr/local/bin/stat.sh > /var/tmp/stat-$(date "+%Y_%d_%m-%H:%M")

fi

-----------------------------------------

/usr/local/bin/stat.sh :

#!/bin/sh

make_stat() {
        echo -e "\n\n\n========================= processes ===================\n"
        ps wwaux
        echo -e "\n\n\n========================= http requests ===================\n"
        links -dump http://localhost/server-status
        echo -e "\n\n\n========================= mysql threads ==================="
        mysql -u root --exec "SHOW FULL PROCESSLIST"
        echo -e "\n\n\n========================= network connections ===================\n"
        netstat -ant
        echo -e "\n\n\n========================= memory ===================\n"
        free
        echo -e "\n\n###############################################\n\n"
}


if [ $(ps aux | grep apache | wc -l) -ge 2 -a  $(ps aux | grep mysql | grep -v grep | wc -l) -ge 0 ] ; then
        outfile=${1:-/dev/stdout}
        cat /dev/null > $outfile
        make_stat >> $outfile
fi

 

Original from http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade

upgrade 1.3.2(Ubuntu) to 2.4.2(Gentoo)

copy distrib redmine to new server and unpack to new folder

do not copy old configs

copy files folder

copy plugins folder

adjust database.yml according to manual

dump db with no parameters

# mysqldump redmine_database --result-file=/root/redmine_database.sql

create new database:

mysql> CREATE DATABASE `redmine_new_db` CHARACTER SET utf8 COLLATE utf8_general_ci;

restore db with no parameters

# mysql redmine_new_db < /root/redmine_database.sql

cd to new redmine folder (/var/lib/redmine)

# rake generate_secret_token

# rake db:migrate RAILS_ENV=production

if got error :

==  CreateChangesetParents: migrating =========================================
-- create_table(:changeset_parents, {:id=>false})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'changeset_parents' already exists: CREATE TABLE `changese'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

do

# mysql -e 'drop table `changeset_parents`' redmine2new

then migration ok

 

 

Проблема: В журнале постоянно сообщения вида:

Connection from UDP: [192.168.11.1]:11227->[192.168.11.64]:161
Received SNMP packet(s) from UDP: [192.168.11.1]:11227->[192.168.11.64]:161

Решение: Чтобы они не писались в /etc/rc.conf:

snmpd_flags="-a -LF 0-5 /var/log/snmpd.log"