Sometimes when you deploy with Capistrano you have just one server that acts in many roles (web, app, database all in one). When I have a client that has a single server for a single app I'll often setup an SVN repo to be accessed via svn+ssh. This causes a little bit of a hickup when you try to deploy with Capistrano because you need to tell the server to checkout the code from itself, but that isn't the same access pattern you need when you are committing things to the svn as a developer. Of course you could deploy_via :copy but that takes a bit longer, an easier route is to have one SVN access pattern for the server to checkout the code, and a different one for yourself as a remote machine. Here is how:
Here is an example deploy.rb file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
require 'mongrel_cluster/recipes' # setup vars used later in the script set :application, "yourdomain_com" set :user, "brian" set :runner, user set :main_server, "www.yourdomain.com" # source code repository set :local_repository, "svn+urdomainssh://www.yourdomain.com/repository/#{application}/trunk" set :repository, "file:////repository/yourdomain_com/trunk" # ssh port is 29361 set :port, 29361 # set the location for the app on the server set :deploy_to, "/var/www/apps/#{application}" set :deploy_via, :checkout # setup servers set :domain, main_server role :app, main_server role :web, main_server role :db, main_server, :primary => true # post deploy tasks desc "Link in the production symlinks" task :after_update_code do # link the database.yml file run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" end #end after_update_code after "deploy", "deploy:cleanup" |
Notice the directives :local_repository and :repository, the first tells Capistrano how to access the source code repository from your local machine (the one you are deploying code from). The second tells it how to access the repository from the server. We use a local file checkout on the server since we don't want to have to mess with private keys, and self referential connections on the server.
Have you ever had a table where you wanted to drop all the information and reset the id field? Say you have the auto_increment value at 1024 and you want to drop all the data and make all new rows start from 1. Or maybe you have the auto_increment value at 1024 and you want to jump it to have all new rows start from 10024. Here is how
1 2 |
ALTER TABLE {table_name} AUTO_INCREMENT = {new_value};
|
Thats it.
By default MySQL only permits connections from the server on which it resides.
Using SSH you need to connect to your server, then need to edit the my.cnf file, generally located in /etc/mysql/my.cnf on Debian/Ubuntu
Under the [mysqld] section alter the “bind-address” line to bind to the public IP address of the server instead of the loop back IP.
1 2 3 4 5 |
[mysqld] datadir=/var/lib/mysql socket=/var/run/mysqld/mysqld.socket bind-address=127.0.0.1 |
Save the file then restart the MySQL service (# /etc/init.d/mysqld restart)
Now using the MySQL admin tool of your choice create your user accounts but specify the host that they will be connecting from. For example if you are creating a user that connects from the IP address 80.65.35.43 the username will be in this format: username@80.65.35.43
Under OS X one of the tools I couldn’t live without is Quicksliver. If your making the switch to Linux there is a comparable app called Katapult that works in much the same way. It is designed for KDE but doesn’t seem to have trouble running under Gnome and others as well.
If your on Ubuntu or another Debian based distro you can install with:
1 2 |
sudo apt-get install katapult |
I was doing some work where I needed to run some heavy queries on a database using the production data. Naturally I made a backup of the database and the plan was to restore it to my local MySQL instance on my development box and then run my tests. I hit a couple snags, and in an effort to document everything that I run into that requires some gumshoeing here is how I fixed it.
I read a bunch of people saying you could use –max_allowed_packet=100M in the command line but I had no luck with this. I also found some people who said you could edit my.cnf to put the setting there but the location and existence of this file appears to be different per the platform and installation method for MySQL. The end result is to update the setting directly at the mysql prompt. So:
1 2 |
mysql> SET GLOBAL max_allowed_packet = 16 * 1024 * 1024; |