如何升级非常旧的 Discourse 站点?

1. 最简单的方法是什么,能让系统重新正常运行?
2. 如果我已有 S3 备份,那是否涵盖了所有相关数据,包括图片、元数据等?

虽然我找到了这篇文章,但它已经五年没有更新了:

因此,在今天我继续做无谓的折腾之前,我想看看是否有人能提供一些有用的建议。也许我可以请某人喝一杯虚拟啤酒,或者在 GitHub - shakacode/react_on_rails: Integration of React + Webpack + Rails including server-side rendering of React, enabling a better developer experience and faster client performance. · GitHub 上提供些免费咨询,或者其他任何帮助?

是否有人有时间和我一起结对编程,而我则负责记录整个过程?

以下是我所了解的情况:

  1. 我的 Discourse 目录是 /var/docker,而不是 /var/discourse
  2. 我在 S3 上有一个最近的备份。
  3. 我尝试了 [将 “templates/postgres.template.yml” 更改为 “templates/postgres.9.5.template.yml”](http://Change “templates/postgres.template.yml” TO “templates/postgres.9.5.template.yml”)
  4. 然后发现数据库不兼容:
2020-04-04 20:53:42.164 UTC [1601] FATAL:  database files are incompatible with server
2020-04-04 20:53:42.164 UTC [1601] DETAIL:  The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.5.21.

相关日志

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-148-generic x86_64)
  System load:  0.08               Processes:              137
  Usage of /:   69.3% of 29.40GB   Users logged in:        0
  Memory usage: 77%                IP address for eth0:    192.241.224.165
  Swap usage:   24%                IP address for docker0: 172.17.0.1
187 packages can be updated.
19 updates are security updates.

*** System restart required ***

root@forum:~# cd /var/docker/
root@forum:/var/docker# git pull

Updating 67f34b8..b0c92ba

I, [2020-04-04T20:34:13.023086 #1]  INFO -- : > apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
E: Unable to locate package postgresql-client-9.3
E: Couldn't find any package by glob 'postgresql-client-9.3'
E: Couldn't find any package by regex 'postgresql-client-9.3'
E: Unable to locate package postgresql-contrib-9.3
E: Couldn't find any package by glob 'postgresql-contrib-9.3'
E: Couldn't find any package by regex 'postgresql-contrib-9.3'
I, [2020-04-04T20:34:17.590352 #1]  INFO -- : Hit:1 http://deb.debian.org/debian buster InRelease

FAILED
--------------------
Pups::ExecError: apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 failed with return #<Process::Status: pid 18 exit 100>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3"
159a5389071c2e398c9f426ae0853f11f662503190b648f0390fdb14dd9a057e

WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
5fd4cef4498a5ad12efb2f27373e3950e83b106d8ab7095177862511b10a0366

Total reclaimed space: 1.494GB
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: local_discourse/app:latest

Total reclaimed space: 9.848GB
root@forum:/var/docker# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            477M     0  477M   0% /dev
tmpfs           100M   11M   89M  11% /run
/dev/vda1        30G  9.6G   19G  35% /
tmpfs           497M     0  497M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           497M     0  497M   0% /sys/fs/cgroup
cgmfs           100K     0  100K   0% /run/cgmanager/fs
tmpfs           100M     0  100M   0% /run/user/0

LOG:  skipping missing configuration file "/shared/postgres_data/postgresql.auto.conf"
2020-04-04 20:53:42.164 UTC [1601] FATAL:  database files are incompatible with server
2020-04-04 20:53:42.164 UTC [1601] DETAIL:  The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.5.21

FAILED
--------------------
Pups::ExecError: su postgres -c 'psql discourse -c "alter schema public owner to discourse;"' failed with return #<Process::Status: pid 1627 exit 2>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "su postgres -c 'psql $db_name -c \"alter schema public owner to $db_user;\"'"
e5ea7eeecd58ef02a19254a299700fe2146b447c6eda637a4fe64df373348953
3 个赞

嗨,Justin!很高兴再次见到你。鉴于你使用 Discourse 已经非常非常久了,作为一份心意,我很乐意支付费用请 @pfaffman 来帮你。:hugs:

只需让他联系我安排付款即可。

6 个赞

嘿,@justin_gordon。网站现在能访问了吗?如果不能,能给我 S3 的信息吗?

你可以通过 Redirecting… 相对安全地发给我。

我相信这不是紧急情况,周一开始处理可以吗?如果很紧急,请在消息中说明,我会尽量提前开始。

你也可以在这里给我发私信,附上你的邮箱地址。

5 个赞

天哪 @codinghorror,你让我今天太开心了!

@pfaffman,是的,不着急。我升级是为了回应一个关于“你是如何让 talksurf.com 的标题做得这么漂亮的”的请求。

一旦 talksurf.com 恢复运行,我一定会在这里添加一些对其他人有帮助的说明。

7 个赞

Justin,我现在感到有点内疚 :slightly_frowning_face:
使用 Discourse 才三天,我就已经惹出麻烦了!

4 个赞

你好 @Paul-Reed@codinghorror

@pfaffman 帮我恢复了运行……他做得太棒了!网站焕然一新,Discourse 也表现卓越,因为所有需要的数据都在备份中!

Discourse 的技术真是太厉害了!

@pfaffman 向我分享了以下信息:

  1. 一种双容器安装方案 详见此处
  2. 对于非常古老的安装版本,从备份恢复到全新安装似乎是最省力的路径。
  3. 实际上,备份之外只有一文件有用,那就是 /var/discourse/containers/app.yml 文件。而且我应该每天备份,而不是每 7 天一次!

一个我本应牢记的关键教训:

你以为某件事只需 10 分钟,但有时并非如此。我之所以介入这次更新,只是想确保能给 @Paul-Reed 一些关于标题栏的好建议。哎呀!这不仅仅是我学到了这一点,我们常常也会忘记。我的专长是通过我的咨询公司 https://www.shakacode.com 和我的开源项目 https://github.com/shakacode/react_on_rails,帮助使用 React 和 Ruby on Rails 构建的网站运行得更好。

Docker 类型的 DevOps 操作我虽然能做,但这会占用大量时间,影响我真正想完成的事情!

因此,我在考虑请 @pfaffman 帮我更新 https://forum.shakacode.com/ 的主页。

所以,对 @codinghorror@pfaffman 提供的所有帮助表示衷心的感谢!


如果你感兴趣,以下是引发我这次旧 Discourse 站点更新的自定义标题修复方案。

自定义标题栏

首先,与其在这里浪费时间(yak shaving),我建议直接联系 @pfaffman,访问 https://support.literatecomputing.com/。事实上,如果我想在这个区域创建更美观的内容,我会请 @pfaffman 帮忙!

但如果你是想自己动手(DIY),我认为所有有用的部分都在这里:

据我所知,其他部分都是空白的。

CSS

#top-navbar-container {
    background: black;
    height: 25px;
}

#top-navbar-links .spacer {
    display: inline-block;
    margin-left: 12px;
    margin-right: 12px;
}


#top-navbar-links, #top-navbar-links a:visited, #top-navbar-links a {
    color: white;
}

header.d-header {
    background: black;
    background-image: url(/uploads/default/63/873a733a013f8208.jpg);
    padding-top: 0;
    box-shadow: none;
    top: 25px;
    height: 63px;
}

.ember-view > #main-outlet {
    padding-top: 97px;
}

header > .container {
    background-image: url(/uploads/default/63/873a733a013f8208.jpg);
    max-width: 1200px;
    padding-right: 50px;
}

header.d-header > .container > .contents {
    margin: 0;
}

header.d-header #site-logo, header.d-header .logo-small {
    max-height: 53px;
}

body #main .extra-info > a.star {
    color: #A5ACDD;
}

header .extra-info-wrapper h1 {
    margin-top: 18px;    
}

@media screen and (min-width: 1140px)  {
    header .extra-info-wrapper {
        max-width: 780px;
    }
}

@media screen and (min-width: 967px) and (max-width: 1139px)  {
    header .extra-info-wrapper {
        max-width: 647px;
    }
}

#user-notifications, #search-button, #site-map  {
    color: #AAA; 
}

@media screen and (max-width: 966px) {
    .extra-info-wrapper {
        max-width: 620px;
    }
}

header .current-username .username > a {
    color: white;
}

header.d-header .icons .icon:hover {
    background-color: #000000;
}

标题栏 HTML

<div id="top-navbar-container" class="d-header">
<div id="top-navbar" class="wrap">
<span id="top-navbar-links" style="height:20px;">
  <a href="http://forum.talksurf.com">首页</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/category/surfing/doug-silva">Doug Silva</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/category/surfing">冲浪</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/category/kitesurfing">风筝冲浪</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/category/standup-paddling">桨板冲浪</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/category/windsurfing">帆板冲浪</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/t/pros-instructors-equipment-travel/264">专业人士</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/t/what-is-talksurf-com/265">关于我们</a><span class="spacer"> | </span>
  <a href="http://forum.talksurf.com/faq">常见问题</a>
</span>
</div>
</div>
5 个赞

是的,我在这里见过,但我不清楚代码中是在哪里包含 talksurf 图像的。

我能看到背景图像的出处,但左侧悬浮在背景图像上方的“talksurf”图像却找不到来源。

在“设置 > 品牌 > Logo”中将“talksurf”添加为图像后,得到的图像要小得多,因为 Discourse 将其原始高度 120px 缩小到了仅 31px。而 Talksurf 的高度远不止 31px。

@Paul-Reed 也许你可以考虑聘请 @pfaffman 来帮忙?我从未设置过这个,所以完全不清楚。

1 个赞

你可以通过一点 CSS 让标题栏变高。我可以帮你,但我建议你新建一个 Support 主题,因为在这里提这个问题有点偏离主题。

我几天前已经创建了一个现有主题 - Image not filling header container
在那里继续讨论可以吗?

1 个赞