I have written a simple PHP file to do that for me and I run it every 1 minute using Cron-Job.
The script needs to run as PHP-CLI (cron or command prompt) as it runs system commands and would be blocked if run as Apache script.
Here is the code.
I have written a simple PHP file to do that for me and I run it every 1 minute using Cron-Job.
The script needs to run as PHP-CLI (cron or command prompt) as it runs system commands and would be blocked if run as Apache script.
Here is the code.
Following is the script to find any phrase and replace it with another.
for i in `grep –include=”*\.include” -rl ‘phrase to search’ /var/www/`; do
sed –in-place=bak -e ‘s/phrase to search/phrase to replace with/g’ “$i”
done
The above script searches folder /var/www and all of its sub folders with any file with extension .include for phrase “phrase to search” and will replace all the found phrases with phrase “phrase to replace with”
Following script monitors RMTP port, which indicates if Red5 is running or not
If SAFE MODE is on in PHP, the owner ID of the PHP file needs to be same to any folder or file it tries to access. So if you try to use sessions and if your PHP is configured to use /tmp folder for saving session data it can cause error shown in title of this blog post.
To fix it check following directive is set as follows
session.save_path = /tmp
If yes create folder
/var/lib/php5/session
change owner of the above folder to same as that of the web server, so for e.g. you would say
chown www-data:www-data /var/lib/php5/session
now change /etc/php.ini or /etc/php5/apache2/php.ini
to use following setting
session.save_path = /var/lib/php5/session
now reload web server e.g.
service apache2 reload
or
/etc/init.d/apache reload
This should fix the problem
http://www.softwareprojects.com/resources/programming/t-how-to-move-copy-a-live-mysql-database-and-what-1257.html
On Mysql Server
1. Turn binary logging on and add server id
CAUTION ! DO NOT USE “log-bin=/var/log/mysql/mysql-bin.log’
[mysqld]
log-bin=mysql-bin
server-id=1
2. Create replication account on the server
GRANT REPLICATION SLAVE ON *.* TO ‘repl’@’slave-ip-address’ IDENTIFIED BY ‘password-here’;
3. Keep the above mysql console open, start new terminal and connect to server via new terminal
cd /var/lib/mysql
now use dir, you should see all the database folders
4. Time to lock all the databases on server.
mysql> SET GLOBAL WAIT_TIMEOUT=600000; SET WAIT_TIMEOUT = 600000; FLUSH TABLES WITH READ LOCK;
now on the new console enter
root@server:/var/lib/mysql#tar -cvf /tmp/mysql-snapshot.tar ./ –exclude mysql &
enter following in mysql console, this will show the position of server in log file, keep this window open and note file and position column
SHOW MASTER STATUS;
now enter following in mysql console
UNLOCK TABLES;
5. Copy the tar file from master to slave server
scp -i permission-file.pem /tmp/mysql-snapshot.tar root@slave-server-ip:/root/
6. Extract the tar file on slave server
cd /var/lib/mysql
mv /root/mysql-snapshot.tar .
tar –extract –file=mysql-snapshot.tar
7. Change server id on slave mysql server, add following to config file /etc/my.cnf or /etc/mysql/my.cnf
[mysqld]
server-id=2
8. Start or restart Slave mysql server with
service mysql restart
9. Login to mysql console and enter
mysql>stop slave;
mysql> CHANGE MASTER TO
MASTER_HOST=’ip-of-master-server’,
MASTER_USER=’repl’,
MASTER_PASSWORD=’replication_password-from-step-2′,
MASTER_LOG_FILE=’recorded_log_file_name-from-step-4′,
MASTER_LOG_POS=recorded_log_position-from-step-4;
mysql>start slave;
If every thing is done correctly the slave should start replicating.
Once master has been set on and slave started on Slave, after restart the slave will auto start.
If something is not right on slave, login to slave mysql console
use following
stop slave;
reset slave;
now from the new bash console, reextract the tar file replacing existing file with following command
root@slave-server:/var/lib/mysql# tar –overwrite –extract –file=mysql-snapshot.tar
now repeat step 9.
Cron restart trigger command
@reboot cd /usr/local/red5/ ; ./red5.sh & >/dev/null 2>&1