迁移 Discuz 站点时导入脚本错误


(freemangl) #1

在执行导入脚本的过程中出现错误提示:
freeman@ubuntu:~/discourse$ bundle exec ruby script/import_scripts/discuz_x.rb bbcode-to-md
loading existing groups…
loading existing users…
loading existing categories…
loading existing posts…
loading existing topics…

creating users
script/import_scripts/discuz_x.rb:101:in block in import_users': undefined local variable or methodusers’ for #ImportScripts::DiscuzX:0x00559942839a10 (NameError)
from /home/freeman/discourse/script/import_scripts/base.rb:702:in block in batches' from /home/freeman/discourse/script/import_scripts/base.rb:701:inloop’
from /home/freeman/discourse/script/import_scripts/base.rb:701:in batches' from script/import_scripts/discuz_x.rb:84:inimport_users’
from script/import_scripts/discuz_x.rb:40:in execute' from /home/freeman/discourse/script/import_scripts/base.rb:45:inperform’
from script/import_scripts/discuz_x.rb:640:in `'
freeman@ubuntu:~/discourse$

应该如何进行?


另外我的dz论坛的pm_messages表有10张(估计是dz为了性能优化做了分表?)
| pre_ucenter_pm_messages_0 |
| pre_ucenter_pm_messages_1 |
| pre_ucenter_pm_messages_2 |
| pre_ucenter_pm_messages_3 |
| pre_ucenter_pm_messages_4 |
| pre_ucenter_pm_messages_5 |
| pre_ucenter_pm_messages_6 |
| pre_ucenter_pm_messages_7 |
| pre_ucenter_pm_messages_8 |
| pre_ucenter_pm_messages_9 |

是否需要对导入脚本做相应的修改?


现在对discuz导入有什么更新么
从 Discuz! X 迁移到 Discourse
Discourse从安装到Discuz成功迁移,一步一步来的详细指南(面向新手,Discuz迁移到Discourse)
(southwolf) #2

似乎是没有找到 users 表?看看是不是表名不对


(southwolf) #3

表名不对吧 看脚本里头 user_table = table_name 'common_member'
但这个表不存在啊


(神楽坂玲奈) #4

users 那个变量改成 results

pm message 不需要修改


(freemangl) #5

请问具体是如何修改?改哪一行?


(神楽坂玲奈) #6

就报错那行,script/import_scripts/discuz_x.rb:101
把变量名 users 改成 results

顺便这东西问题好多,我也在导入一个论坛,在魔改那个导入脚本中。。

freemangl info@discoursecn.org于2016年1月9日周六 上午11:19写道:


(freemangl) #7

这行有2个users,是改第二个吗?
next if all_records_exist? :users, users.map {|u| u[“id”].to_i}

你也分享一下你导入过程中的经验和需要修改的地方吧。:slight_smile:

edit:
刚改好了,这一步通过了,在下面载入的时候又停止退出了:

  • Process memory map:

1e6ddc6f000-1e6ddd00000 —p 00000000 00:00 0
1e6ddd00000-1e6ddd05000 rw-p 00000000 00:00 0
1e6ddd05000-1e6ddd06000 —p 00000000 00:00 0
1e6ddd06000-1e6ddd07000 rwxp 00000000 00:00 0
1e6ddd07000-1e6dde00000 —p 00000000 00:00 0
1e6dde00000-1e6dde05000 rw-p 00000000 00:00 0


7f4afad66000-7f4afad67000 rw-p 00000000 00:00 0
7ffdc6efb000-7ffdc76fb000 rw-p 00000000 00:00 0
7ffdc76fe000-7ffdc7700000 r–p 00000000 00:00 0 [vvar]
7ffdc7700000-7ffdc7702000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)

你遇到这个问题了吗?


(神楽坂玲奈) #8

可以把 mysql_query 那个函数里面 cache_rows: false 去掉,也可以把 mysql2 gem 的版本换成
0.3.5,然后 mysql_query
函数最后结果加个 to_a

我这折腾完了再一起提交 pull request 了…

freemangl info@discoursecn.org于2016年1月9日周六 上午11:56写道:


(神楽坂玲奈) #9

现在我遇到的最麻烦的问题是 extremely slow,不知道要哪辈子才能跑完。。

神楽坂玲奈 zh99998@gmail.com于2016年1月9日周六 上午11:58写道:


(freemangl) #10

是单纯的删掉吗?最终像这样?还是改为true?
def mysql_query(sql)
@client.query(sql, cache_rows: true)
end


(神楽坂玲奈) #11

都可以,这参数默认就是 true,你去掉那个参数或者改成 true效果相同的


(freemangl) #12

都转换了7000多个用户突然又报错了:
svgo worker: didn't get version of svgo ? at /usr/local/bin/svgo; please provide proper binary or disable this worker (--no-svgo argument or `:svgo => false` through options) 7676 / 10327 ( 74.3%) WARN: gifsicle 1.78 at /usr/bin/gifsicle (< 1.85) does not support removing extension blocks svgo worker: didn't get version of svgo ? at /usr/local/bin/svgo; please provide proper binary or disable this worker (--no-svgo argument or `:svgo => false` through options) 7691 / 10327 ( 74.5%) script/import_scripts/discuz_x.rb:126:in `block (3 levels) in import_users': undefined method `persisted?' for nil:NilClass (NoMethodError) from /home/freeman/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/core_ext/object/try.rb:77:in `call' from /home/freeman/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/core_ext/object/try.rb:77:in `public_send' from /home/freeman/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/core_ext/object/try.rb:77:in `try!' from /home/freeman/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/core_ext/object/try.rb:63:in `try' from /home/freeman/discourse/script/import_scripts/base.rb:333:in `create_user' from /home/freeman/discourse/script/import_scripts/base.rb:240:in `block in create_users' from /home/freeman/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-mini-profiler-0.9.7/lib/patches/db/mysql2.rb:6:in `each' from /home/freeman/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-mini-profiler-0.9.7/lib/patches/db/mysql2.rb:6:in `each' from /home/freeman/discourse/script/import_scripts/base.rb:228:in `create_users' from script/import_scripts/discuz_x.rb:103:in `block in import_users' from /home/freeman/discourse/script/import_scripts/base.rb:702:in `block in batches' from /home/freeman/discourse/script/import_scripts/base.rb:701:in `loop' from /home/freeman/discourse/script/import_scripts/base.rb:701:in `batches' from script/import_scripts/discuz_x.rb:84:in `import_users' from script/import_scripts/discuz_x.rb:40:in `execute' from /home/freeman/discourse/script/import_scripts/base.rb:45:in `perform' from script/import_scripts/discuz_x.rb:640:in `<main>'


(神楽坂玲奈) #13

我没有遇到过这个…跟进去调试吧…


(freemangl) #14

我也不是很懂怎么办,出错的就是这里:
7691 / 10327 ( 74.5%) script/import_scripts/discuz_x.rb:126:in block (3 levels) in import_users’: undefined methodpersisted?’ for nil:NilClass (NoMethodError)

帮忙指点一二?


(神楽坂玲奈) #15

把 .persisted? 去掉试试看…
我不太清楚 upload 成功的判断条件,看现有那个脚本里各个地方判定标准都不一致的

我新加的部分写的就直接是 if upload


(freemangl) #16

把.persisted?去掉转换成功了,瞅瞅看:http://116.52.144.226:3000/
但目前遇到了用户无法登陆的情况,提示密码不对。似乎dz的用户密码加密不止是MD5?


(神楽坂玲奈) #17

恩,只能重置密码了。

或者再做个插件,对于导入的用户,请求登录的时候先拿 UC 算法验一遍密码,通过了的话把以用户密码置成这次登录的时候输入的那个。应该不难,不过我不会 (笑


(freemangl) #18

重置密码?!上万个用户…这几乎是不可能的事情啊…对用户体验也非常不好。这几乎就完全不可能啊,请@fantasticfears 帮忙协助下,能否修改下discourse的密码加密方式?

另外我发现很多有附件的帖子似乎附件并没有转换过来:
http://www.infinity-game.com/bbs/forum.php?mod=viewthread&tid=6589
http://116.52.144.226:3000/t/topic/5991
这2个是相同的帖子。


(神楽坂玲奈) #19

附件那个我在弄了。不仅仅是附件,fanta 那个脚本差的东西非常多。
我改了三天了。。


(神楽坂玲奈) #20

顺便你导入 post 的时候多少个每分钟?