ReBirth部署问题

在服务器上部署re-birth的过程中碰到了一些问题,以下是部署的流程:
1.部署CITA测试链
这一步是根据文档使用Docker部署的。
出块正常,rpc正常
2.部署microscope
根据文档 Development 部分,使用yarn start启动。
可以正常访问,访问之后默认显示的是官方测试链的信息
3.部署re-birth
根据文档使用的是 Docker 部署的。
re-birth运行在http://ip:8888

遇到的问题是:我在microscope中无法访问re-birth,想请教一下这种情况一般是什么地方出了问题,自己感觉是re-birth的配置可能有问题,也有可能是端口的问题?但是尝试了很多次,还是不对。

运行 curl -v http://ip:8888 看看是否正常响应

没有响应,以下是返回信息:

#  curl -v http://104.215.248.50:8888
* Rebuilt URL to: http://104.215.248.50:8888/
*   Trying 104.215.248.50...
* TCP_NODELAY set
* Connection failed
* connect to 104.215.248.50 port 8888 failed: Connection refused
* Failed to connect to 104.215.248.50 port 8888: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 104.215.248.50 port 8888: Connection refused

make start 启动的时候有什么信息输出么,在服务器本地访问 curl -v http://127.0.0.1:8888 也不行么

之前一直是使用make up启动的,刚才使用make start启动之后可以响应到curl -v http://104.215.248.50:8888

下面是make start启动时输出的错误信息

db_1_514020fdf505 | 2019-02-25 09:58:19.105 UTC [28] FATAL:  database "re-birth_production" does not exist
sync_1_a6ba45147b86 | /usr/local/bundle/gems/activerecord-5.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:696:in `rescue in connect': FATAL:  database "re-birth_production" does not exist (ActiveRecord::NoDatabaseError)
...
...
sync_1_a6ba45147b86 | production_sync: process with pid 39 started.
sync_1_a6ba45147b86 | tail: cannot open '/app/log/production_sync.log' for reading: No such file or directory
sync_1_a6ba45147b86 | tail: no files remaining
re-birth_sync_1_a6ba45147b86 exited with code 1

是数据库没创建吧 README 参照这里运行 make setup 来创建数据库

@classicalliu

哦,是的,刚才重新部署的时候忘记执行make setup了,但是我现在执行之后还是会报错

app_1_8a89b3f7fdff | [1] * Listening on tcp://0.0.0.0:3000
app_1_8a89b3f7fdff | [1] ! WARNING: Detected 1 Thread(s) started in app boot:
app_1_8a89b3f7fdff | [1] ! #<Thread:0x00005585397eb558@/usr/local/bundle/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:299 sleep> - /usr/local/bundle/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:301:in `sleep'
app_1_8a89b3f7fdff | [1] Use Ctrl-C to stop
app_1_8a89b3f7fdff | [1] - Worker 0 (pid: 16) booted, phase: 0
sync_1_fb1cbb553895 | production_sync: process with pid 39 started.
sync_1_fb1cbb553895 | tail: cannot open '/app/log/production_sync.log' for reading: No such file or directory
sync_1_fb1cbb553895 | tail: no files remaining
re-birth_sync_1_fb1cbb553895 exited with code 1

还有想请教一下,下面这个错误是什么原因
PG::ConnectionBad (could not translate host name “db” to address: Temporary failure in name resolution
):

怎么看起来是 docker-compose 没有正确处理容器之间的通信…

make setup 是执行成功的是么,重新执行 make start 如果不行的话贴一下错误信息,就 PG::ConnectionBad 这段

是的,make setup是执行成功的
执行make start之后,打印如下信息:

$make start
docker-compose up
Starting re-birth_redis_1_ddab3a98fa22 ... done
Starting re-birth_db_1_3bd1b6e69662    ... done
Starting re-birth_sidekiq_1_63f42d08ffb8 ... done
Starting re-birth_sync_1_fb1cbb553895    ... done
Starting re-birth_app_1_8a89b3f7fdff     ... done
Starting re-birth_web_1_303823e1e8a3     ... done
Attaching to re-birth_redis_1_ddab3a98fa22, re-birth_db_1_3bd1b6e69662, re-birth_sidekiq_1_63f42d08ffb8, re-birth_sync_1_fb1cbb553895, re-birth_app_1_8a89b3f7fdff, re-birth_web_1_303823e1e8a3
redis_1_ddab3a98fa22 | 1:C 25 Feb 2019 10:35:50.936 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1_ddab3a98fa22 | 1:C 25 Feb 2019 10:35:50.936 # Redis version=5.0.1, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1_ddab3a98fa22 | 1:C 25 Feb 2019 10:35:50.936 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:35:50.942 * Running mode=standalone, port=6379.
db_1_3bd1b6e69662 | 2019-02-25 10:35:52.025 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1_3bd1b6e69662 | 2019-02-25 10:35:52.025 UTC [1] LOG:  listening on IPv6 address "::", port 5432
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:35:50.943 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:35:50.943 # Server initialized
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:35:50.943 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:35:50.943 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
db_1_3bd1b6e69662 | 2019-02-25 10:35:52.049 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:35:50.943 * DB loaded from disk: 0.000 seconds
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:35:50.943 * Ready to accept connections
db_1_3bd1b6e69662 | 2019-02-25 10:35:52.116 UTC [21] LOG:  database system was shut down at 2019-02-25 10:35:43 UTC
db_1_3bd1b6e69662 | 2019-02-25 10:35:52.158 UTC [1] LOG:  database system is ready to accept connections
app_1_8a89b3f7fdff | [1] Puma starting in cluster mode...
app_1_8a89b3f7fdff | [1] * Version 3.12.0 (ruby 2.5.3-p105), codename: Llamas in Pajamas
app_1_8a89b3f7fdff | [1] * Min threads: 5, max threads: 5
app_1_8a89b3f7fdff | [1] * Environment: production
app_1_8a89b3f7fdff | [1] * Process workers: 1
app_1_8a89b3f7fdff | [1] * Preloading application
app_1_8a89b3f7fdff | [1] * Listening on tcp://0.0.0.0:3000
app_1_8a89b3f7fdff | [1] ! WARNING: Detected 1 Thread(s) started in app boot:
app_1_8a89b3f7fdff | [1] ! #<Thread:0x0000559fab341458@/usr/local/bundle/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:299 sleep> - /usr/local/bundle/gems/activerecord-5.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:301:in `sleep'
app_1_8a89b3f7fdff | [1] Use Ctrl-C to stop
app_1_8a89b3f7fdff | [1] - Worker 0 (pid: 16) booted, phase: 0
sync_1_fb1cbb553895 | production_sync: process with pid 33 started.
sync_1_fb1cbb553895 | tail: cannot open '/app/log/production_sync.log' for reading: No such file or directory
sync_1_fb1cbb553895 | tail: no files remaining
re-birth_sync_1_fb1cbb553895 exited with code 1

redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:40:51.058 * 100 changes in 300 seconds. Saving...
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:40:51.059 * Background saving started by pid 15
redis_1_ddab3a98fa22 | 15:C 25 Feb 2019 10:40:51.075 * DB saved on disk
redis_1_ddab3a98fa22 | 15:C 25 Feb 2019 10:40:51.076 * RDB: 4 MB of memory used by copy-on-write
redis_1_ddab3a98fa22 | 1:M 25 Feb 2019 10:40:51.159 * Background saving terminated with success

PG::ConnectionBad (could not translate host name “db” to address: Temporary failure in name resolution): 这个信息是我之前在执行rails db:setup的时候打印的。

你这个看起来一切正常啊,还是不能访问么

不能的话,把执行 rails db:setup 的命令重新运行然后看看打印出的错误信息,不然我以为你是 make start 的时候给的错误信息,上下文连不起来…

而且为什么 make setup 都成功了 rails db:setup 会打印一个错误信息?

@classicalliu 你好,还是不能访问

执行rails db:setup会报下面的错:

$rails db:setup
could not translate host name "db" to address: Temporary failure in name resolution
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "host"=>"db", "port"=>5432, "pool"=>5, "username"=>"postgres", "password"=>"postgres", "database"=>"re-birth_development"}
rails aborted!
PG::ConnectionBad: could not translate host name "db" to address: Temporary failure in name resolution

但是执行make setup是成功的,但是之后执行make start,又会输出下面的日志:

sync_1_e28d3b07f01c | 2019-02-26 04:02:21 +0000
sync_1_e28d3b07f01c | No such file or directory @ rb_sysopen - /app/tmp/pids/production_sync_monitor.pid
sync_1_e28d3b07f01c | ["/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/pidfile.rb:92:in `initialize'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/pidfile.rb:92:in `open'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/pidfile.rb:92:in `pid='",
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/monitor.rb:66:in `block in start_with_pidfile'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/monitor.rb:62:in `fork'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/monitor.rb:62:in `start_with_pidfile'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/monitor.rb:93:in `start'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/application_group.rb:150:in `create_monitor'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/application.rb:288:in `start'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/controller.rb:56:in `run'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons.rb:197:in `block in run_proc'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons/cmdline.rb:92:in `catch_exceptions'", 
                        "/usr/local/bundle/gems/daemons-1.2.6/lib/daemons.rb:196:in `run_proc'", 
                        "/app/lib/sync_control.rb:14:in `<main>'"]

你这么一说我就知道你这个 PG 的错误哪里来的了,你用 docker 跑就直接执行 make setup 就行了,他会在容器里面执行 rails db:setup,不要在 shell 里面单独跑这个命令

我在空目录上重新 clone 代码执行是可以响应的,不过确实有个问题是没有在监听
docker-compose.yml 照这么改一下就行了

建议删掉这个目录重新 clone 代码,然后执行 make setupmake start
上面这个问题我会尽快修复,另外可以告知下当前代码的版本么

好的,谢谢,我现在去试一下,当前使用的 re-birth 版本是 0.2.0

:joy: 不要用 0.2.0 了,很久都没有发版本了,需要整理一下,现在 master 分支也有点问题还没合并进去,建议直接使用 develop 分支。

好的,我看最新的发布版本是0.2.0所以就用了 :joy:

问题解决了么?我也遇到类似的问题:
链启动出块正常,Microscope运行正常,rebirth启动也正常,
但是Microscope浏览器,仍然报“缓存服务不可用”error,
Microscope的".env"文件CHAIN_SERVERS设置为"CHAIN_SERVERS=http://127.0.0.1:8888"

当时是解决了,你再检查一下re-birth服务调用JSON-RPC接口是否能正常返回数据,我当时这里也有点问题


这个应该是正常的吧

http://ip:8888/api/blocks

看看能不能正常返回区块数据