AD:
ブラウザから確認
MongoDBをインストールした場合は、下記のURLにアクセスすると、MongoDBの状況が確認できるようです。
http://localhost:28017
ちなみに、上記の機能は–norestオプションで無効化できるらしいです。
コマンドから確認
ちなみに、コマンドでMongoの状況確認は下記の要します。
|
$ mongostat connected to: 127.0.0.1 insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time 0 0 0 0 0 1 0 0m 102m 23m 0 local:0.0% 0 0|0 0|0 62b 1k 1 05:26:35 0 0 0 0 0 1 0 0m 102m 23m 0 local:0.0% 0 0|0 0|0 62b 1k 1 05:26:36 |
その他
他にもいろいろな管理ツールがあるようです。
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
このページを参考にUbuntuにMongoDBを入れようと思ったらうまくいかなかったのでメモしておきます。
やっていることは、GnuPGへキーを登録して、MongoDB用のパッケージ管理システムを登録して、インストールの流れです。
|
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 $ sudo sh -c 'echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list' deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen $ sudo apt-get -y update $ sudo apt-get -y install mongodb-10gen |
操作関係
|
$ sudo service mongodb start mongodb start/running, process 19200 $ sudo service mongodb stop mongodb stop/waiting $ sudo service mongodb restart mongodb stop/waiting mongodb start/running, process 19224 |
データの登録、検索
MongoDBは、JavascriptのエンジンであるSpiderMonkeyを拡張した、Javascriptシェル?です。
なんで、JavaScriptの記述でデータのが取得が可能です。
|
$ mongo MongoDB shell version: 2.2.3 connecting to: test > show dbs local (empty) test (empty) > use test switched to db test > db.test.save( { a: 1 } ) > db.test.find() { "_id" : ObjectId("51285b019fc2311ea475b159"), "a" : 1 } |
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
過去のサイトで、Lessを使用しているものがあったので、lessをインストール
|
$ gem install less $ less --version less 444 Copyright (C) 1984-2009 Mark Nudelman |
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
In AppFog, when you connect Database you will use tunnel but I could not access today.
|
$ af tunnel 1: database_name Which service to tunnel to?: 1 Deploying tunnel application 'caldecott-ap-aws'. <span style="color:red;">Error 600: Not enough memory capacity, you're allowed: 2048</span> |
So I searched why and then I found out the problem.
How I fix
When using af tunnel, it uses 64MB that why error was “Not enough memory capacity“.
I just went to Console Page in AppFog and then reduced memory from one of App.
|
$ af tunnel 1: database_name Which service to tunnel to?: 1 Getting tunnel connection info: OK |
Done
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
I set up Rails Env with ruby 1.9.3p374 & Rails 3.2.11
I tried to use consolce and I got this massage…
Error
|
$ rails c /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError) from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1/irb/completion.rb:9:in `<top>' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `require' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `<top>' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:38:in `require' from /home/vagrant/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:38:in `<top>' from script/rails:6:in `require' from script/rails:6:in `<main>' </main></top></top></top> |
Add re-readline
|
$ vi Gemfile gem 'rb-readline' $ bundle install |
Done
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 1 | Total: 1 | Feedly: 0
AD:
設定方法
|
$ vi config/application.rb module YourAppName class Application <h3>環境ごとに変更したい場合</h3> <pre> vi config/environments/development.rb config.site_name = "サイト名" config.site_url = "localhost:3000" |
参照方法
|
<h1></h1> @url = YourAppName::Application.config.site_url |
Done
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
I want to setup contry code for my Rails app so I searched by google there are some Gem but I just want to make Tables & Model.
I used data from here
Make migratiton file
|
$ rails g model country name:string alpha_2:string alpha_3:string invoke active_record create db/migrate/20130206044924_create_countries.rb create app/models/country.rb invoke rspec create spec/models/country_spec.rb |
Add SQL from here
|
$ vi db/migrate/20130206044924_create_countries.rb #add data from http://stefangabos.ro/other-projects/list-of-world-countries-with-national-flags/ execute " INSERT INTO `countries` (`name`, `alpha_2`, `alpha_3`) VALUES ('Afghanistan', 'af', 'afg'), ('Aland Islands', 'ax', 'ala'), ('Albania', 'al', 'alb'), more... ('Zimbabwe', 'zw', 'zwe')" |
and then
Done.
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
Thanks Appfog /tmp folder
|
$_SERVER['DOCUMENT_ROOT'].'/../tmp' |
My wp-config.php for WordPress
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
/** Setup for AppFog **/ $services = getenv("VCAP_SERVICES"); if($services !== false){ $services_json = json_decode($services,true); $mysql_config = $services_json["mysql-5.1"][0]["credentials"]; define('DB_NAME', $mysql_config["name"]); define('DB_USER', $mysql_config["user"]); define('DB_PASSWORD', $mysql_config["password"]); define('DB_HOST', $mysql_config["hostname"]); define('DB_PORT', $mysql_config["port"]); define('TMP_FOLDER', realpath($_SERVER['DOCUMENT_ROOT'].'/../tmp')); #local setting }else{ define('DB_NAME', 'DatabaseName'); define('DB_USER', 'UserName'); define('DB_PASSWORD', 'Password!'); define('DB_HOST', 'localhost'); define('TMP_FOLDER', '/tmp'); } |
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0
AD:
Set up ruby first
Before install Vagrant needs set up ruby. I use rbenv for setting Ruby environment
|
$ sudo apt-get update $ sudo apt-get install build-essential zlib1g-dev curl git-core sqlite3 libsqlite3-dev $ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile $ source .bash_profile $ git clone git://github.com/sstephenson/ruby-build.git $ cd ~/ruby-build/gr $ sudo ./install.sh $ rbenv install 1.9.3-p374 $ rbenv global 1.9.3-p374 $ gem install bundler $ rbenv rehash $ ruby -v ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux] |
Install Vagrant
|
$ apt-get install virtualbox-ose $ apt-get install rubygems $ gem install vagrant $ vagrant box add ubuntu12.10.64 https://s3-sa-east-1.amazonaws.com/willian-boxes/Ubuntu-Server-12.10-amd64-Minimal.box $ vagrant up ubuntu12.10.64 |
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 1 | Pocket: 0 | Total: 1 | Feedly: 0
AD:
Just delete ~/.pagodarc or edite it.
|
$ rm ~/.pagodarc or $ vi ~/.pagodarc :u: username :p: password |
Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0