Erlang mochiweb mnesia 集群部署
想在MochiWeb中用mnesia,并且让mnesia按集群部署。
Erlang mochiweb 部署
环境:
2台centos系统的机器,在同一网段。
设置host
ip:192.168.2.126
more /etc/sysconfig/network
NETWORKING=yesHOSTNAME=centos-126GATEWAY=192.168.0.1
127.0.0.1 centos-126 localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.2.127 www.centos127.com
NETWORKING=yesHOSTNAME=centos-127GATEWAY=192.168.0.1
127.0.0.1 centos-127 localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.2.126 www.centos126.com
[root@centos-126 /]# erl -name "a@www.centos-126.com" -setcookie abc[root@centos-127 /]# erl -name "b@www.centos127.com" -setcookie abc
(b@www.centos127.com)1> net_adm:ping(a@www.centos126.com).pong(a@www.centos126.com)1> net_adm:ping(b@www.centos127.com).pong
127.0.0.1 centos126192.168.2.127 centos127
NETWORKING=yesHOSTNAME=centos127GATEWAY=192.168.0.1
127.0.0.1 centos127192.168.2.126 centos126
#!/bin/sh# NOTE: mustache templates need \ because they are not awesome.exec erl +P 500000 -pa ebin edit deps/*/ebin -boot start_sasl \ -setcookie abc \ -sname im_dev \ -s im \ -s reloader \ -mnesia dir '"/ide/erlang/im/db/online"'
-record(im_monitor, {pid, user_name } ).%% save user_name, pid, type is bag-record(im_chat, {user_name, pid } ).init() -> mnesia:create_table(im_monitor, [{ram_copies, [im_dev@centos126,im_dev@centos127]}, {type, set}, {attributes, record_info(fields, im_monitor)}]), mnesia:create_table(im_chat, [{ram_copies, [im_dev@centos126,im_dev@centos127]}, {type, bag}, {attributes, record_info(fields, im_chat)}]).