2014/08/18

mysqldumpでwhen using LOCK TABLESというエラーが出る

MySQLはダンプする前にテーブルにLockをかけるらしいのだが、そのLockをかけることができないようだ。
そこで、ダンプ時に誰も使っていない事が確認できたので(INSERTすることがない)、「--skip-lock-tables」というオプションを使ってダンプを行ったところ無事に完了した。
==>だれがつかったね。。

==> single-transaction
このオプションだとテーブルをロックせず、トランザクションの範囲でバックアップしてくれるとのことだった。

ruby on rails

bundle install
==>Install the modules include in the gemfile.
Unless you specify a version number to the gem command, Bundler will automatically install the latest version of the gem.
bundle update===>update!!


・deployの準備
bundle install --without production
group :production do
    gem 'pg'
    gem 'rails_12factor'
end

・@なになに。。
Once the @users variable is defined, the controller calls the view (Step 6), shown in Listing 2.6. Variables that start with the @ sign, called instance variables, are automatically available in the view;

・rails new sample_app --skip-test-unit
===>not to create test directory

・rails generate controller StaticPages home help --no-test-framework
===>「home help」MVCセットで2つ作る

・rails generate rspec:install
bundle exec rspec spec/requests/..rb==>実行、red->green->refactor

・JetBrains:
==>alt+ctr+s =->editerのところでline番号を表示する。

・<% provide(:title, 'Home') %>
Rails should call the provide function and associate the string ’Home’ with the label :title.
<%= yield(:title) %>
    yield==->自分で定義したブロック付きメソッドでブロックを呼び出すときに使います

・application.html.erb:
<%= yield %>
==>This code is responsible for inserting the contents of each page into the layout. It’s not important to know exactly how this works; what matters is that using this layout ensures that, for example, visiting the page /static_pages/home converts the contents of home.html.erb to HTML and then inserts it in place of <%= yield %>.


・first_name + " " + last_name
===
"#{first_name} #{last_name}"

・# Single-quoted strings don't allow interpolation

・Note that Ruby functions have an implicit return
meaning they return the last statement evaluated

・a = [42, 8, 17]
a[-1]==>17
a.sort
a.sort!===>a!
a.push(6)
a << 7
a << "foo" << "bar"

a.split--->array になる
array.join-->stringになる


(0..9).to_a
a[0..2]


・|i|
==>The vertical bars around the variable name in |i| are Ruby syntax for a block variable

mysql crash

★MySQL のクラッシュの多くは、インデックスファイルやデータファイルの破壊が原因です
-flush を指定して mysqld を開始することによって、各 SQL コマンド実行後、強制的にすべてをディスクと同期させることができます。
 つまり、以下のことがなければ、通常は破壊されたテーブルを得ることはありません。

    誰かまたは何かが、更新中に mysqld またはマシンを強制終了した。

    更新中に mysqld が死ぬようなバグを見つけた。

    テーブルを適切にロックしないで、mysqld 外でデータまたはインデックスフファイルを操作している。

    優れたファイルシステムロック(通常、lockd デーモンによって処理される)をサポートしていないシステム上で、同じデータに対して、多くの mysqld サーバを実行しているか、--skip-external-locking で複数サーバを実行している。

    mysqld を混乱させるような不正なデータを含んだ、破損したインデックスまたはデータファイルがある。

    データストレージのコードにバグを発見した。これはおそらくあり得ないことだが、可能性としてはある。この場合、修正されたテーブルのコピーに対して ALTER TABLE を使用して、ファイルタイプを別のデータストレージエンジンに変更することができる。

★クラッシュの原因を見つけるのは非常に難しいので、まず、他で動作しているものが自分の環境でクラッシュするかどうかを確認してください。
mysqld --log を使用して、ログの情報から、特定のクエリがサーバを終了させるかどうかを判断する。バグの 95% が特定のクエリに関係している。

mysqldump view only

 mysql -u username INFORMATION_SCHEMA
  --skip-column-names --batch
  -e "select table_name from tables where table_type = 'VIEW'
      and table_schema = 'database'"
  | xargs mysqldump -u username database
  > views.sql
===>テーブルを分けるbackupする際、これがあればべんり。

--skip-column-names:
 結果にカラム名を記述しません===>列名がないこと?
--batch
ブとして、カラムセパレータを使用することで、各行が新しいライン上に配置されるように、結果をプリントします。

2014/08/09

window commandline sleep hibernate

Sleep Computer
Rundll32.exe powrprof.dll,SetSuspendState Sleep
If it hibernates instead of Sleep: Hibernate must be OFF

■休止状態機能の有効・無効を切り替える方法

コマンドプロンプトを管理者として実行し、次のコマンドを入力する。
  • 有効にする場合
    > powercfg /hibernate on
  • 無効にする場合
    > powercfg /hibernate off
  • 現在の設定を確認する場合
    > powercfg /a