`
langzhe
  • 浏览: 286876 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Erlang应用部署与热代码替换--理解2

阅读更多

在Erlang应用部署与热代码替换--理解1这我提出了三个问题,后来fengyu老师推荐我看一下litaocheng的blog

erlang otp 应用发布指南(一) tiny-1.0非真正OTP

erlang otp 应用发布指南(二) tiny-2.0 (supervisor)

 

erlang otp 应用发布指南(三) tiny-3.0

 

 

我找到后才发现我以前看过一眼,因为查找的时候用的是code_change.

昨晚仔细研究了一下,开始一切都顺利。最后一步升级 第三个版本的时候总是出现一下错误

 

提示“cannot find top supervisor for application tiny app”..."cannot find top supervisor for application sasl ...""cannot find top supervisor for application kernel.."

fengyu老师告诉我是版本问题,最新的版本supervisor有bug。又是版本问题,我遇到两次了,前一次是两个电脑的版本不一致,这次是版本太超前。害的我昨晚没睡好,今天早上还迟到了。

初次安装

11>
target_system:create("ch_rel-1").                     
Reading file: "ch_rel-1.rel" ...
** exception error: no match of right hand side value
                    {error,{7,erl_scan,{string,34,"}]\n}.\n"}}}
     in function  target_system:create/1
12> target_system:create("ch_rel-1").
Reading file: "ch_rel-1.rel" ...
** exception error: no match of right hand side value
                    {error,{7,erl_scan,{string,34,"}]\n}.\n"}}}
     in function  target_system:create/1
13> target_system:create("ch_rel-1").
Reading file: "ch_rel-1.rel" ...
Creating file: "plain.rel" from "ch_rel-1.rel" ...
Making "plain.script" and "plain.boot" files ...
Making "ch_rel-1.script" and "ch_rel-1.boot" files ...
Creating tar file "ch_rel-1.tar.gz" ...
Creating directory "tmp" ...
Extracting "ch_rel-1.tar.gz" into directory "tmp" ...
Deleting "erl" and "start" in directory "tmp/erts-5.7.4/bin" ...
Creating temporary directory "tmp/bin" ...
Copying file "plain.boot" to "tmp/bin/start.boot" ...
Copying files "epmd", "run_erl" and "to_erl" from
"tmp/erts-5.7.4/bin" to "tmp/bin" ...
Creating "tmp/releases/start_erl.data" ...
Recreating tar file "ch_rel-1.tar.gz" from contents in directory "tmp" ...
Removing directory "tmp" ...
ok
14> target_system:install("ch_rel-1","/opt/target").
Extracting ch_rel-1.tar.gz ...
Substituting in erl.src, start.src and start_erl.src to
form erl, start and start_erl ...
Creating the RELEASES file ...
ok



asl                      sasl_report               sasl_report_tty_h        
sets                      shell                     standard_error           
string                    supervisor                supervisor_bridge        
sys                       unicode                   user_drv                 
user_sup                  zlib                     
1> ch3:alloc().
** exception error: undefined function ch3:alloc/0
2>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
a
langzhe@langzhe-desktop:/usr/local/target/bin$ ls
epmd  erl  run_erl  start  start.boot  start_erl  to_erl
langzhe@langzhe-desktop:/usr/local/target/bin$ cd ..
langzhe@langzhe-desktop:/usr/local/target$ ls
bin  erts-5.7.5  lib  releases
langzhe@langzhe-desktop:/usr/local/target$ cd releases/
langzhe@langzhe-desktop:/usr/local/target/releases$ ls
A  ch_rel-1.rel  RELEASES  start_erl.data
langzhe@langzhe-desktop:/usr/local/target/releases$ cd A
langzhe@langzhe-desktop:/usr/local/target/releases/A$ ls
start.boot
langzhe@langzhe-desktop:/usr/local/target/releases/A$ erl -boot start
{"init terminating in do_boot",{'cannot load',error_handler,get_file}}
init terminating in do_boot ()
langzhe@langzhe-desktop:/usr/local/target/releases/A$ erl -boot start_sasl start
(no error logger present) error: "Error in process <0.2.0> with exit value: {badarg,[{erlang,list_to_atom,[[<<10 bytes>>,<<5 bytes>>,46,98,111,111,116]]},{init,get_boot,2},{init,do_boot,3}]}
"
{"init terminating in do_boot",{badarg,[{erlang,list_to_atom,[[<<10 bytes>>,<<5 bytes>>,46,98,111,111,116]]},{init,get_boot,2},{init,do_boot,3}]}}
init terminating in do_boot ()
langzhe@langzhe-desktop:/usr/local/target/releases/A$ ca
bash: ca: command not found
langzhe@langzhe-desktop:/usr/local/target/releases/A$ cd
langzhe@langzhe-desktop:~$ ls
application       Examples    otp_src_R13B04         release
Desktop           id_rsa.pub  otp_src_R13B04.tar.gz  Templates
Documents         Music       Pictures               tiny_app.appup
erlips-read-only  optc        Public                 Videos
langzhe@langzhe-desktop:~$ /opt/target/bin/erl
/opt/target/erts-5.7.5/bin/erlexec: 1: Syntax error: "(" unexpected
langzhe@langzhe-desktop:~$ /opt/target/bin/
bash: /opt/target/bin/: is a directory
langzhe@langzhe-desktop:~$ /opt/target/bin/erl
/opt/target/erts-5.7.5/bin/erlexec: 1: Syntax error: "(" unexpected
langzhe@langzhe-desktop:~$ /opt/target/bin/erl
Erlang R13B03 (erts-5.7.4) [source] [rq:1] [async-threads:0] [kernel-poll:false]

Eshell V5.7.4  (abort with ^G)
1>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
a
langzhe@langzhe-desktop:~$ /opt/target/bin/erl -boot /opt/target/releases/A/start
Erlang R13B03 (erts-5.7.4) [source] [rq:1] [async-threads:0] [kernel-poll:false]


=PROGRESS REPORT==== 2-Jun-2010::17:08:02 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.36.0>},
                       {name,alarm_handler},
                       {mfa,{alarm_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:08:02 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.37.0>},
                       {name,overload},
                       {mfa,{overload,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:08:02 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.35.0>},
                       {name,sasl_safe_sup},
                       {mfa,
                           {supervisor,start_link,
                               [{local,sasl_safe_sup},sasl,safe]}},
                       {restart_type,permanent},
                       {shutdown,infinity},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 2-Jun-2010::17:08:02 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.38.0>},
                       {name,release_handler},
                       {mfa,{release_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:08:02 ===
         application: sasl
          started_at: nonode@nohost

=PROGRESS REPORT==== 2-Jun-2010::17:08:02 ===
          supervisor: {<0.43.0>,ch_sup}
             started: [{pid,<0.44.0>},
                       {name,ch3},
                       {mfa,{ch3,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,brutal_kill},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:08:02 ===
         application: ch_app
          started_at: nonode@nohost
Eshell V5.7.4  (abort with ^G)
1> ch3:alloc().
1
2> ch3:alloc().
2
3> ch3:alloc().
3
4> ch3:alloc().
4
5> ch3:alloc().
5
6> ch3:alloc().
6
7> ch3:alloc().
7
8> ch3:alloc().
8
9> ch3:alloc().
9
10> ch3:alloc().
10
11> ch3:alloc().
11
12> ch3:alloc().
12
13> ch3:alloc().
13
14>
14>
14>
14>
14>
14>
14>
14>
14>
14>
14>
14>
14>
14>
14>
14> ch3:alloc().
14
15> ch3:alloc().
15
16>
16>
16>
16>
16>
16> e
edlin                 edlin_expand          erl_distribution     
erl_eval              erl_internal          erl_lint             
erl_parse             erl_prim_loader       erl_scan             
erlang                error_handler         error_logger         
error_logger_tty_h    ets                  
16> release_handler:unpack_release("ch_rel-2").    出现下面错误的原因 是因为没有权限 ,切换root用户解决此问题
{error,{enoent,"/opt/target/releases/ch_rel-2.rel"}}  
17> release_handler:unpack_release("ch_rel-2sss").
{error,{no_such_file,"/opt/target/releases/ch_rel-2sss.tar.gz"}}
18> release_handler:unpack_release("ch_rel-2").  
{error,{enoent,"/opt/target/releases/ch_rel-2.rel"}}
19> release_handler:unpack_release("ch_rel-2").
{error,{enoent,"/opt/target/releases/ch_rel-2.rel"}}
20>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
a
langzhe@langzhe-desktop:~$ su root
Password:
su: Authentication failure
langzhe@langzhe-desktop:~$ su root
Password:
root@langzhe-desktop:/home/langzhe#  /opt/target/bin/erl -boot /opt/target/releases/A/start
Erlang R13B03 (erts-5.7.4) [source] [rq:1] [async-threads:0] [kernel-poll:false]


=PROGRESS REPORT==== 2-Jun-2010::17:15:43 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.36.0>},
                       {name,alarm_handler},
                       {mfa,{alarm_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:15:43 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.37.0>},
                       {name,overload},
                       {mfa,{overload,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:15:43 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.35.0>},
                       {name,sasl_safe_sup},
                       {mfa,
                           {supervisor,start_link,
                               [{local,sasl_safe_sup},sasl,safe]}},
                       {restart_type,permanent},
                       {shutdown,infinity},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 2-Jun-2010::17:15:43 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.38.0>},
                       {name,release_handler},
                       {mfa,{release_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:15:43 ===
         application: sasl
          started_at: nonode@nohost

=PROGRESS REPORT==== 2-Jun-2010::17:15:43 ===
          supervisor: {<0.43.0>,ch_sup}
             started: [{pid,<0.44.0>},
                       {name,ch3},
                       {mfa,{ch3,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,brutal_kill},
                       {child_type,worker}]

=PROGRESS REPORT==== 2-Jun-2010::17:15:43 ===
         application: ch_app
          started_at: nonode@nohost
Eshell V5.7.4  (abort with ^G)
1>
1>
1> ch3:alloc().
1
2> ch3:alloc().
2
3> ch3:alloc().
3
4> ch3:alloc().
4
5> ch3:alloc().
5
6> ch3:alloc().
6
7> ch3:alloc().
7
8> ch3:alloc().
8
9> ch3:alloc().
9
10> \
10> .
* 1: syntax error before: '\\'
10>  /opt/target/bin/erl -boot /opt/target/releases/A/start
10>  /opt/target/bin/erl -boot /opt/target/releases/A/startsdfsadfsadf.
* 1: syntax error before: '/'
10> .                                                                 
* 1: syntax error before: '.'
10> ch3:alloc().                                                      
10
11> ch3:alloc().
11
12> ch3:alloc().
12
13> ch3:alloc().
13
14> ch3:alloc().
14
15> ch3:alloc().
15
16> release_handler:unpack_release("ch_rel-2")
16> .
{ok,"B"}
17> release_handler:in
init/1             install_file/2     install_release/1  install_release/2 

17> .                              
* 1: syntax error before: '.'
17> release_handler:in                       
init/1             install_file/2     install_release/1  install_release/2 

17> release_handler:install_release("B").

=========none========================
{ok,"A",[]}
18> release_handler:install_release("A").

=========none========================
{ok,"A",[]}
19> ch3:alloc().                                                      
16
20> ch3:alloc().
17
21> ch3:alloc().
18
22> release_handler:install_release("B").

=========none========================
{ok,"A",[]}
23> ch3:alloc().                        
19
24> ch3:alloc().
20
25> ch3:alloc().
21
26> release_handler:install_release("A").

=========none========================
{ok,"A",[]}
27> ch3:alloc().                                                      
22
28> release_handler:install_release("A").
{error,{enoent,"/opt/target/releases/A/relup"}}
29> release_handler:make_permanent("A").
ok
30> release_handler:remove_release("B").
ok
31> release_handler:unpack_release("ch_rel-2")                        
31> .
{ok,"B"}
32> release_handler:install_release("B").    

=========none=====_OldVsn=207148400555736968023835684567001219333===================
{ok,"A",[]}
33> release_handler:install_release("A").

=========none=====_OldVsn={down,207148400555736968023835684567001219333}===================
{ok,"A",[]}
34> release_handler:install_release("B").

=========none=====_OldVsn=207148400555736968023835684567001219333===================
{ok,"A",[]}
35>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution

c
c
35>

疑问: 版本号 怎么是:_OldVsn=207148400555736968023835684567001219333
而不是A或B

----------------------------

litaocheng erlang otp 应用发布指南     学习完毕!他的版本号没有出现我上面的疑问,看来某个地方配置的问题,今天再不睡又要迟到了。明天检查一下。现在完全可以确定是erlang版本问题引起的昨天练习失败的原因。多亏fengyu老师的指导,在此表示感谢!

 

预览文章: Erlang应用部署与热代码替换--理解1

永久链接: http://langzhe.iteye.com/blog/681128

0
1
分享到:
评论
1 楼 langzhe 2010-06-03  
=========none=====_OldVsn=207148400555736968023835684567001219333===================《后台输出的结果》
出现上面问题的原因是 版本号自动生成造成的,需要在gen_server里面定义好就可以了。在此感谢 litaocheng的提醒。

相关推荐

    Erlang 中的Module级别热部署

    在Erlang编程环境中,模块级别的热部署是一项关键特性,它允许开发者在不中断系统运行的情况下更新或替换已加载的模块。这对于实时系统和高可用性服务尤其重要,因为它们需要持续提供服务而不能因为代码更新而停机。...

    erlang 深度分析

    - **应用场景**: 代码的热替换场景。 #### 21. Erlang消息监听器调试 - **工具**: `erl_snooper`。 - **功能**: 监听Erlang进程之间的消息传递。 - **应用场景**: 调试复杂的分布式系统。 #### 22. Erlang网络程序...

    erlang深度分析

    6. **热更新**:Erlang系统支持运行时代码替换,无需停止服务即可更新或升级系统,这对于保持服务连续性至关重要。 7. **OTP(Open Telecom Platform)**:OTP是Erlang的标准库,提供了一套用于构建可靠、可扩展、...

    erlang-23.3.4.11-1.el7.x86-64.zip

    4. **热代码替换**:Erlang支持在不中断服务的情况下更新运行中的代码,这是其高可用性的一个关键特性。这使得开发者可以在生产环境中修复bug或优化性能而无需停机。 5. **模式匹配**:Erlang的函数调用允许模式...

    erlang深度分析.pdf

    热部署和代码替换 热部署(hot code replacement)是Erlang的一大特色,使得在不停机的情况下更新系统成为可能。这对于维护和升级大规模运行的应用系统尤其重要。 #### 12. IO和并发 Erlang的IO系统与其它语言相比...

    Erlang程序设计中文版

    Erlang以其强大的错误恢复能力、热代码替换以及对大规模并发的支持而闻名,是构建高可用性、容错性强的系统的一个优秀选择。 在本书中,读者将了解到Erlang的核心概念和语法特性,包括: 1. **函数式编程基础**:...

    erlang_otp_win64_22.1.zip

    4. **热更新**:Erlang OTP提供了代码替换(Code Replacement)功能,允许程序在运行时升级代码而无需停机,这在维护大型系统时非常关键。 5. **模式匹配**:Erlang的函数调用支持模式匹配,使得代码更加简洁和易于...

    erlang 学习笔记1

    同时,Erlang社区提供了许多工具,如Rebar3和ERTS(Erlang Run-Time System),它们对于构建、测试和部署Erlang应用至关重要。 【压缩包子文件的文件名称列表】"rw_file"可能表示这个压缩包包含了一些关于读写文件...

    erlang 24.2安装包

    此外,Erlang还支持热代码替换,使得在不中断服务的情况下更新应用程序成为可能。 Erlang的BEAM虚拟机是其运行时系统的核心,负责管理内存、调度进程和执行代码。理解BEAM的工作原理对于编写高效、健壮的Erlang代码...

    RabbitMQ+Erlang.rar

    Erlang采用函数式编程范式,提供了轻量级进程、热代码替换和故障隔离等特性,使得在RabbitMQ这样的系统中处理大量并发连接和快速消息交换变得可能。 RabbitMQ的安装通常包括两个主要步骤:首先,你需要安装Erlang...

    RabbitMQ+Erlang.zip

    Erlang以其轻量级进程、热代码替换以及内置的分布式计算能力而著称,这些特性使其成为构建高可用性和容错性的网络应用的理想选择。`otp_win64_24.0.exe`是Erlang/OTP(Open Telecom Platform)的Windows 64位版本,...

    Erlang程序设计.pdf

    - **分布式编程**:Erlang内置了对分布式系统的支持,可以很容易地将进程部署到不同的节点上,并通过网络进行通信。 通过以上介绍,我们不难看出,Erlang作为一种专为高并发、容错性强的应用场景设计的语言,其核心...

    erlang+rabbit.rar

    2. **热代码升级**:开发者可以在运行时替换和更新代码,无需重启系统,这对于维护大规模服务至关重要。 3. **故障恢复**:Erlang的错误处理机制鼓励进程间隔离,一个进程的崩溃不会影响其他进程,增强了系统的健壮...

    erl-templates:Erlang 模块模板

    在实际开发中,结合版本控制系统(如 Git)和持续集成/持续部署(CI/CD)流程,Erlang 模块模板可以进一步提升开发效率和代码可维护性。开发者可以将模板与项目代码一起版本化,确保在项目的不同阶段都能保持代码...

    erlangsoft.rar

    Erlang以其强大的并发处理能力、轻量级进程、热代码替换以及高效错误恢复机制而闻名。在现代IT行业中,Erlang被广泛应用于实时系统、大规模并发服务、云计算平台以及分布式数据库等领域。 "erlangsoft.rar"是一个...

    erlci:用Erlang编写的CI服务器。 NSWIDY(不确定我在做什么)

    2. **热代码替换**:Erlang 支持运行时代码更新,无需停止整个系统,这对于CI服务器来说意味着可以在不影响服务的情况下进行升级和调试。 3. **分布式**:Erlang系统可以轻松地跨多台机器分布式部署,这对于构建...

    elixir中文入门文档

    - **Mix简介**:Mix是Elixir的官方构建工具,用于编译、打包、部署Elixir应用程序。 - **Mix常用命令**:如`mix new`用于创建新项目,`mix compile`用于编译项目等。 #### 十五、元编程 - **元编程概念**:元编程...

    卡祖·坎普

    3. **热代码替换**:Erlang支持在运行时更新代码,无需停机即可升级系统,这对于维护大型服务至关重要。 4. **简单错误处理**:Erlang使用模式匹配和异常处理机制,使得错误处理更加直观和简洁。 5. **OTP(Open ...

Global site tag (gtag.js) - Google Analytics