2012 5月9日

MySQL5.5のインストール

MANPでMySQL使えるんだけど、mroongaを(ローカルテストでも)使いたいので別にMySQLをインストールする。

ただしMySQLのバージョンは5.5をインストールしたいのでコマンドはこんな感じに。
mysql5 +server としてしまうとMySQL5.1.6が入ります。

MacBook:~ clicktx$ sudo port install mysql55 +server
Password:
--->  Deactivating mysql55 @5.5.23_0
--->  Cleaning mysql55
--->  Uninstalling mysql55 @5.5.23_0
--->  Cleaning mysql55
MacBook:~ clicktx$ sudo port install mysql55 +server
--->  Computing dependencies for mysql55
--->  Fetching archive for mysql55
--->  Attempting to fetch mysql55-5.5.23_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/mysql55
--->  Fetching mysql55
--->  Verifying checksum(s) for mysql55
--->  Extracting mysql55
--->  Applying patches to mysql55
--->  Configuring mysql55
--->  Building mysql55
--->  Staging mysql55 into destroot
--->  Installing mysql55 @5.5.23_0
The mysql55 client has been installed.
To install the mysql55 server, install the mysql55-server port.
--->  Activating mysql55 @5.5.23_0
--->  Cleaning mysql55

MySQLの初期化

  • mac OSXの場合はmysqlユーザーは作成済みなので改めて作成する必要はない。
  • 実際は_mysql?mysqlでユーザー指定しても_mysqlで処理される。
MacBook:~ clicktx$ sudo -u mysql /opt/local/lib/mysql55/scripts/mysql_install_db
Password:
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/local/lib/mysql55/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql55/bin/mysqladmin -u root -h MacBook.local password 'new-password'

Alternatively you can run:
/opt/local/lib/mysql55/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql55/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql55/bin/mysqlbug script!

MySQLを起動する

MacBook:~ clicktx$ sudo /opt/local/share/mysql55/support-files/mysql.server start
Starting MySQL
... ERROR! The server quit without updating PID file (/opt/local/var/db/mysql55/MacBook.local.pid).

そのまま起動すると上記のようにエラーとなってしまう(自分の環境だけ?)

デフォルトでは /opt/local/var/run/mysql55 以下にソケットファイルを作成するらしく、フォルダが無いので作成する。アクセス権も777を与える。

MacBook:~ clicktx$ sudo mkdir -m 777 -p /opt/local/var/run/mysql55

改めてMySQLを起動。

MacBook:~ clicktx$ sudo /opt/local/share/mysql55/support-files/mysql.server start
Starting MySQL
.. SUCCESS! 

成功

参考:

  • Mac OS X に MacPorts で MySQL をインストールする – make world
  • MacPortsを使ってMySQL 5をインストールする – めも帖
  • mroongaのインストール

    2. インストールガイド — mroonga v2.02 documentation

    2.11.3. 前提条件
    MySQLおよびgroongaが既にインストールされている必要があります。
    またmroongaをビルドするためにはMySQLのソースコードも必要です。

    先日groongaはインストール済み。

    先程MacPortsでインストールしたMySQLのでソースは
    /opt/local/var/macports/distfiles/mysql55/mysql-5.5.23.tar.gz
    かな?

    作業スペースを~/src にする。
    まずは作業スペースとなるsrcフォルダを作成。

    MacBook:~ clicktx$ mkdir ~/src

    MySQLのソースファイルを ~/src にコピーして解凍する

    MacBook:~ clicktx$ cp /opt/local/var/macports/distfiles/mysql55/mysql-5.5.23.tar.gz ~/src/mysql-5.5.23.tar.gz
    MacBook:~ clicktx$ cd src/
    MacBook:~ clicktx$ tar xzvf mysql-5.5.23.tar.gz

    mroongaをダウンロード&解凍

    MacBook:src clicktx$ wget http://cloud.github.com/downloads/mroonga/mroonga/mroonga-2.02.tar.gz
    MacBook:src clicktx$ tar xzvf mroonga-2.02.tar.gz
    

    mroongaをビルドする

    MacBook:src clicktx$ cd mroonga-2.02
    MacBook:mroonga-2.02 clicktx$ ./configure PKG_CONFIG_PATH=/opt/local/lib/pkgconfig --with-mysql-source=$HOME/src/mysql-5.5.23 --with-mysql-config=/opt/local/lib/mysql55/bin/mysql_config
    MacBook:mroonga-2.02 clicktx$ make

    makeでコケる…
    googleで漁っているとこんなの発見。
    installing mroonga on Mac OS X Lion — Gist
    早速試してみる。

    MacBook:~ clicktx$ cd ~/src/mysql-5.5.23/include
    MacBook:include clicktx$ ln -s probes_mysql_nodtrace.h probes_mysql_dtrace.h
    MacBook:include clicktx$ cd ~/src/mroonga-2.02
    MacBook:mroonga-2.02 clicktx$ aclocal -I /opt/local/share/aclocal
    MacBook:mroonga-2.02 clicktx$ automake -a
    MacBook:mroonga-2.02 clicktx$ autoconf
    MacBook:mroonga-2.02 clicktx$ autoheader
    MacBook:mroonga-2.02 clicktx$ automake -a
    MacBook:mroonga-2.02 clicktx$ ./configure PKG_CONFIG_PATH=/opt/local/lib/pkgconfig --with-mysql-source=$HOME/src/mysql-5.5.23 --with-mysql-config=/opt/local/lib/mysql55/bin/mysql_config --with-mecab
    MacBook:mroonga-2.02 clicktx$ make

    コケる…

    mroongaをMac OSXでビルドするためのアドホックなパッチを書いてみた « いわぶろ(ろてん)
    ココらへんに解決策?もう神頼み。
    https://gist.github.com/1015079 を参考に、~/src/mroonga-2.02/ha_mroonga.cpp っていうファイルの560行目付近に

    static_cast(static_cast
    (pthread_self())),

    っていう箇所があるから、

    static_cast(static_cast
    ((unsigned long int)pthread_self())),

    に修正。
    pthread_self で検索すると修正箇所がすぐ分かる。

    修正した後にmakeしたら見事成功。

    MacBook:mroonga-2.02 clicktx$ sudo make install
    .....
    libtool: install: ranlib /opt/local/lib/mysql55/plugin/ha_groonga.a

    インストールできたぽい。

    公式ガイドに

    その後、mysqldを起動し、mysqlクライアントで接続して”INSTALL PLUGIN”コマンドでインストールします。

    とあるので、MySQL起動してインストール&確認。

    MacBook:~ clicktx$ sudo /opt/local/share/mysql55/support-files/mysql.server start
    MacBook:~ clicktx$ /opt/local/lib/mysql55/bin/mysql -u root
    mysql> INSTALL PLUGIN mroonga SONAME 'ha_mroonga.so';
    Query OK, 0 rows affected (0.48 sec)
    
    mysql> SHOW ENGINES;
    +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
    | Engine             | Support | Comment                                                    | Transactions | XA   | Savepoints |
    +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
    | CSV                | YES     | CSV storage engine                                         | NO           | NO   | NO         |
    | PERFORMANCE_SCHEMA | YES     | Performance Schema                                         | NO           | NO   | NO         |
    | InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
    | MyISAM             | YES     | MyISAM storage engine                                      | NO           | NO   | NO         |
    | MRG_MYISAM         | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |
    | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
    | mroonga            | YES     | CJK-ready fulltext search, column store                    | NO           | NO   | NO         |
    +--------------------+---------+------------------------------------------------------------+--------------+------+------------+
    7 rows in set (0.00 sec)

    なんとか入ったみたい。
    苦労した…。

    なお参考ブログに

    なお,MySQLへの組み込み後の動作については,何も確認を行っていないのであしからず,です.(影響があるとしても,ログ出力部分だけ?)

    とあるように、とりあえずmake出来て、インストールまでこぎつけたってシロモノです。









    2012 5月7日

    BlogMail
    スパムボット対策とかでメールアドレスを掲載したくないっ!、って方にうってつけのブログパーツですが、黒背景とかのブログに設置すると入力欄と文字色が同じになってしまって書いている文章が見えないってご意見を頂きました。

    テキストボックスにCSSを適用させる事でこの問題を回避できます。

    BlogMailを設置するには

    Selec All Code:
    <!-- ここから -->
    <script>
        var ClicktxBlogMail={};
        ClicktxBlogMail.UID='作成されたユーザー固有ID';
        (function(){var p=(("https:"==document.location.protocol)?"https://":"http://");
        document.write('<scri'+'pt src="'+p+'tools.clicktx.jp/blogmail/js/blogMail.pack.js" charset="UTF-8"></scri'+'pt>');})();
    </script>
    <!-- ここまで -->

    こんな感じのコードを挿入するのですが、このコードのすぐ後に

    Selec All Code:
    <style><!--
    #ClicktxBlogMail input, #ClicktxBlogMail textarea{ background-color:#FFF; }
    #ClicktxBlogMail input.button{ color:#333; }
    --></style>

    こんなコードを挿入すればテキストボックスの背景が白に、文字色が濃いグレーになります。
    黒系背景でBlogMailが使えない!ってお悩みの方は是非試してみてください!









    2012 5月5日

    MacPorts導入しているので

    sudo port install groonga

    で一発!…のはずが、

    macbook:~ clicktx$ sudo port install groonga
    Password:
    Warning: port definitions are more than two weeks old, consider using selfupdate
    Error: Port groonga not found
    To report a bug, see <http://guide.macports.org/#project.tickets>

    どうやらMacPortsが古いからupdateしろや、こら!らしいのでupdateする。

    macbook:~ clicktx$ sudo port selfupdate
    --->  Updating MacPorts base sources using rsync
    MacPorts base version 2.0.3 installed,
    MacPorts base version 2.0.4 downloaded.
    --->  Updating the ports tree
    ...

    2.0.3から2.0.4に無事アップデート完了。

    気を取り直して再度挑戦。

    macbook:~ clicktx$ sudo port install groonga
    --->  Fetching archive for expat
    --->  Attempting to fetch expat-2.1.0_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/expat
    ...
    Error: Unable to execute port: Can't install mecab-utf8 because conflicting ports are installed: mecab
    To report a bug, see <http://guide.macports.org/#project.tickets>

    groongaをインストールする時にmecabもインストールするらしく、以前インストールしたmecabがコンフリクトしてるみたい。とりあえずmecabをアンインストール。

    macbook:~ clicktx$ port uninstall mecab*

    続いて再々挑戦。

    macbook:~ clicktx$ sudo port install groonga
    --->  Computing dependencies for groonga
    --->  Dependencies to be installed: libevent mecab-utf8 mecab-base mecab-ipadic-utf8 msgpack zmq
    --->  Fetching archive for libevent
    --->  Attempting to fetch libevent-2.0.18_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/libevent
    --->  Attempting to fetch libevent-2.0.18_0.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/libevent
    --->  Installing libevent @2.0.18_0
    --->  Activating libevent @2.0.18_0
    --->  Cleaning libevent
    --->  Fetching archive for mecab-base
    --->  Attempting to fetch mecab-base-0.993_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/mecab-base
    --->  Attempting to fetch mecab-base-0.993_0.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/mecab-base
    --->  Installing mecab-base @0.993_0
    --->  Activating mecab-base @0.993_0
    --->  Cleaning mecab-base
    --->  Fetching archive for mecab-ipadic-utf8
    --->  Attempting to fetch mecab-ipadic-utf8-2.7.0-20070801_0.darwin_10.noarch.tbz2 from http://packages.macports.org/mecab-ipadic-utf8
    --->  Fetching mecab-ipadic-utf8
    --->  Verifying checksum(s) for mecab-ipadic-utf8
    --->  Extracting mecab-ipadic-utf8
    --->  Configuring mecab-ipadic-utf8
    --->  Building mecab-ipadic-utf8
    --->  Staging mecab-ipadic-utf8 into destroot
    --->  Installing mecab-ipadic-utf8 @2.7.0-20070801_0
    --->  Activating mecab-ipadic-utf8 @2.7.0-20070801_0
    --->  Cleaning mecab-ipadic-utf8
    --->  Fetching archive for mecab-utf8
    --->  Attempting to fetch mecab-utf8-0.993_0+ipadic.darwin_10.noarch.tbz2 from http://packages.macports.org/mecab-utf8
    --->  Fetching mecab-utf8
    --->  Verifying checksum(s) for mecab-utf8
    --->  Extracting mecab-utf8
    --->  Configuring mecab-utf8
    --->  Building mecab-utf8
    --->  Staging mecab-utf8 into destroot
    --->  Installing mecab-utf8 @0.993_0+ipadic
    --->  Activating mecab-utf8 @0.993_0+ipadic
    --->  Cleaning mecab-utf8
    --->  Fetching archive for msgpack
    --->  Attempting to fetch msgpack-0.5.7_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/msgpack
    --->  Fetching msgpack
    --->  Attempting to fetch msgpack-0.5.7.tar.gz from http://msgpack.org/releases/cpp/
    --->  Verifying checksum(s) for msgpack
    --->  Extracting msgpack
    --->  Configuring msgpack
    --->  Building msgpack
    --->  Staging msgpack into destroot
    --->  Installing msgpack @0.5.7_0
    --->  Activating msgpack @0.5.7_0
    --->  Cleaning msgpack
    --->  Fetching archive for zmq
    --->  Attempting to fetch zmq-2.2.0_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/zmq
    --->  Attempting to fetch zmq-2.2.0_0.darwin_10.x86_64.tbz2.rmd160 from http://packages.macports.org/zmq
    --->  Installing zmq @2.2.0_0
    --->  Activating zmq @2.2.0_0
    --->  Cleaning zmq
    --->  Fetching archive for groonga
    --->  Attempting to fetch groonga-2.0.2_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/groonga
    --->  Fetching groonga
    --->  Attempting to fetch groonga-2.0.2.tar.gz from http://packages.groonga.org/source/groonga/
    --->  Verifying checksum(s) for groonga
    --->  Extracting groonga
    --->  Configuring groonga
    --->  Building groonga
    --->  Staging groonga into destroot
    --->  Installing groonga @2.0.2_0
    --->  Activating groonga @2.0.2_0
    --->  Cleaning groonga

    無事 groongaインストール完了。バージョンは2.0.2のようです。
    さて、何しようかな。









    2012 5月3日

    120503-0001
    https://twitter.com/#!/javascript_j/status/197743453881380865
    ココらへんのツイートからふとやってみようかと。
    もともとのツイートはこのあたり

    SublimeLinter

    Kronuz/SublimeLinter – github
    リアルタイムで構文チェックを行なってくれる。
    JavaScriptの他にも下記の言語に対応している(みたい)

    • CoffeeScript
    • CSS
    • java
    • Javascript
    • Objective-J
    • perl
    • php
    • python
    • ruby

    Sublime Package Controlをインストール

    SublimeLinterをインストールするには Sublime Package Control をインストール必要がある。
    Sublime Package Control – a Sublime Text 2 Package Manager by wbond

    SublimeLinterのインストール

    Sublime Package Control をインストールすると メニューに preference> Package Control が追加されるので選択する。
    メニュー

    Install Package を選択。
    sublime text2 Package Control

    テキストボックスに「SublimeLinter」を入力する。一部でも可。
    選択すれば自動でインストール開始する。
    Package Control: install package

    Node.jsとnpmをインストール

    node.js site
    JavaScriptでJSHintやJSLintを使うにはNode.jsが必要。
    普通にmac用のインストーラー(node-v0.6.16.pkg )をダウンロードしてインストール。

    Node was installed at
    
       /usr/local/bin/node
    
    npm was installed at
    
       /usr/local/bin/npm
    
    Make sure that /usr/local/bin is in your $PATH.

    JSHintのインストール

    uipoet/sublime-jshint

    • JSHintはJSLintのフォーク。
    • JSLintを作った人はJavaScript Good Partsの著者らしい
      • JSLintはC言語並みにチェックが厳しいみたいなのでJSHintを使う
    macbook:~ clicktx$ sudo npm install -g jshint
    Password:
    npm http GET https://registry.npmjs.org/jshint
    npm http 304 https://registry.npmjs.org/jshint
    npm http GET https://registry.npmjs.org/argsparser
    npm http GET https://registry.npmjs.org/minimatch
    npm http 200 https://registry.npmjs.org/argsparser
    npm http GET https://registry.npmjs.org/argsparser/-/argsparser-0.0.6.tgz
    npm http 200 https://registry.npmjs.org/minimatch
    npm http GET https://registry.npmjs.org/minimatch/-/minimatch-0.0.5.tgz
    npm http 200 https://registry.npmjs.org/argsparser/-/argsparser-0.0.6.tgz
    npm http 200 https://registry.npmjs.org/minimatch/-/minimatch-0.0.5.tgz
    npm http GET https://registry.npmjs.org/lru-cache
    npm http 200 https://registry.npmjs.org/lru-cache
    npm http GET https://registry.npmjs.org/lru-cache/-/lru-cache-1.0.6.tgz
    npm http 200 https://registry.npmjs.org/lru-cache/-/lru-cache-1.0.6.tgz
    /usr/local/bin/jshint -> /usr/local/lib/node_modules/jshint/bin/hint
    jshint@0.6.3 /usr/local/lib/node_modules/jshint
    ├── argsparser@0.0.6
    └── minimatch@0.0.5 (lru-cache@1.0.6)
    

    動作確認

    Preferences->Package Settings->SublimeLinter->Settings – Default から下記の場所を false->trueに変えるとより強調される。

        // If true, lines with errors or warnings will have a gutter mark.
        "sublimelinter_gutter_marks": false,
    
        // If true, the find next/previous error commands will wrap.
        "sublimelinter_wrap_find": false,
    

    SublimeLinterの動作

    エラーがあるところは強調や下線等してくれる。
    ただ、jQueryのコードとかになるとエラーばっかりになってしまうのが…。
    手動モードにしたほうがいいのかも。

    ちなみにちょっと頑張ったんだけど、Perlの構文チェックを有効にする方法が分かりませんでした…。









    2012 4月6日

    参考:Mac(Leopard) に DBD::SQLite をいれる時には注意 | Supernova

    参考ブログの手順だと

    Please use ‘o conf commit’ to make the config permanent!

    と怒られるのでちょと修正。

    Selec All Code:
    sudo cpan
    cpan[1]> o conf commit makepl_arg USE_LOCAL_SQLITE=true
    commit: wrote '/Users/clicktx/.cpan/CPAN/MyConfig.pm'
    cpan[2]> install DBD::SQLite