Thursday, April 24, 2014

free web host cloud introduct - openshift

this is git address:

ssh://52c6d36f5973ca9404XXXXXX@{app name}-{other name}.rhcloud.com/~/git/php.git/

NOW, mysql 5.5 address:

5359c033500446ffxxxxxxxx-pkrss.rhcloud.com:57866

Database Name: {app name}
Password: xxxxxxxxxx

Username: xxxxxxxxx

 

1.setup rhc client on my windows worker.
1.1 install cygwin,with ruby

download ruby gem http://old.stevenharman.net/blog/archive/2008/11/12/installing-rubygems-in-cygwin.aspx

 

ruby setup.rb install

gem update --system

 

for linux:

sudo yum install rubygems git

 

1.2.Installing OpenShift RHC Client Tools

 

gem install rhc

rhc setup

// typed in your account and passwords

 

3.clear old data
rhc app force-stop -a {app name}
rhc app-tidy -a {app name}
rhc app restart -a {app name}

4.add multiple account

rhc setup -l {openshift email account}

5.port forward // this command can bind remote mysql ip and port to 127.0.0.1:xxxxx port
rhc port-forward -a {app name}

This is output:

Service Local OpenShift

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

haproxy 127.0.0.1:8080 => 127.10.85.2:8080

haproxy 127.0.0.1:8081 => 127.10.85.3:8080

httpd 127.0.0.1:8082 => 127.10.85.1:8080

mysql 127.0.0.1:57866 => 55359c033500446ffxxxxxxxx-pkrss.rhcloud.com:57866

 

Press CTRL-C to terminate port forwarding

 

 

6.create cron service

\> rhc app cartridge add -a {app name}-c cron

\> vi ~/app-root/repo/.openshift/cron/daily/cleanup-old-logs

rm -rf ~/app-root/logs/*

rm -rf ~/haproxy/logs/*

# cd $OPENSHIFT_PHP_LOG_DIR

# find . -type f \( -name access_log-\* , -name error_log-\* \) -mtime +3 -exec rm {} \; # Add this to the above command to backup as a gzipped tarball: | xargs tar -czvf backup-logs-$(date +%Y%m%d).tar.gz

# Add this to the above command to delete 'em: -exec rm {} \; or | xargs rm)

 

\> ~/app-root/repo/.openshift/cron/hourly/test1

/usr/bin/curl http://127.0.0.1/i can used this to do some other my hourly work.

 

7.fixed default mysql 5.1 file is out of quota 100%,and it cannot start(delete old,add new cartridge)

problem message: openshift MySQL 5.1 is using 100.0% of disk quota
\> rhc app cartridge remove -a {app name} -c mysql-5.1

\> rhc app cartridge add -a {app name} -c mysql-5.5

 

after that,your can not used default $_SERVER['OPENSHIFT_MYSQL_DB_HOST'] code to get mysql profile,now your need input your new right value to php mysql connection string.
8 remove unused files

rm -rf ~/git/{app name}.git/objects/pack/*

rm -rf ~/app-deployments/{year}-{monty}-{day}_{hour}-{day}-{second}.{microsecond}/repo/*

rm -rf ~/app-root/logs/* # (above cron is also clean this logs)
rm -rf ~/haproxy/logs/*

 

x.other commands

see directory size: du -sh *

delete logs files: rm -rf ~/php/logs/*

No comments: