Matrix 是一个新的开放式联邦化的即时通信和 VoIP 生态系统。其包含服务端、客户端和桥接工具,可以连接到已有的通信解决方案如IRC。
Arch Linux 的官方 Matrix 频道位于#archlinux:archlinux.org,一些国际社区有其自己的 Matrix 房间,请参阅国际社区以了解详细信息。
对于客户端,请参阅应用程序列表/互联网#Matrix 客户端。
您可以使用已有的 Matrix 服务器如 https://matrix.org 或按照下文创建您自己的 Synapse 服务器。
安装
Matrix 的服务端实现 Synapse 由 matrix-synapse包 提供,其会创建一个 synapse 用户。
配置
安装完成后需要生成一个配置文件,synapse 用户应当能够读取该文件:
# generate_config --server-name my.domain.name \ --config-dir /etc/synapse \ --data-dir /var/lib/synapse \ --report-stats yes \ --generate-secrets \ --output-file /etc/synapse/homeserver.yaml # generate_log_config -o /etc/synapse/my.domain.name.log.config \ -f /var/log/synapse/homeserver.log # generate_signing_key --output_file /etc/synapse/my.domain.name.signing.key # chown -R synapse:synapse /etc/synapse \ /var/log/synapse
请注意这会为指定的服务器名称生成相应的 SSL 和自签名证书,若您更改了服务器名称,则应重新生成。
若您的 Synapse 服务器可通过互联网访问,那么非常建议您为其设置反向代理。
数据库
Synapse 仅用 SQLite 测试服务器,操作时使用 Postgres。
要使用 Postgres,请安装 python-psycopg2包。
您可在官方网站上读到更多有关安装和配置的信息:Using Postgres
服务
matrix-synapse包 包含 systemd 服务 synapse.service
,其会按照配置文件 /etc/synapse/homeserver.yaml
以用户 synapse 启动 Synapse 服务端。
用户管理
您的新 synapse 服务器需要至少一个用户,可以执行以下命令创建您的默认非 root 用户:
[synapse]$ register_new_matrix_user -c /etc/synapse/homeserver.yaml http://127.0.0.1:8008
也可以使用一个 matrix 客户端,例如 element-desktop包,或 libpurple包 的 purple-matrix-gitAUR 插件。
Spider Webcrawler
To enable the webcrawler, for server generated link previews, the additional packages python-lxml包 and python-netaddr包 have to be installed. After that, the option url_preview_enabled: True
can be set in your homeserver.yaml
. To prevent the synapse server from issuing arbitrary GET requests to internal hosts, the url_preview_ip_range_blacklist:
has to be set.
There are some examples that can be uncommented. Add your local IP ranges to that list to prevent the synapse server from trying to crawl them. After changing the homeserver.yaml
, the service has to be restarted.
Interesting channels
KDE community has a wide variety of matrix rooms for specific applications, languages, events and etc. See https://community.kde.org/Matrix for details.
The GNOME Community also has a Matrix instance for its instant communications with a wide variety of matrix rooms. See https://wiki.gnome.org/GettingInTouch/Matrix for details.
Troubleshooting
Read-only file system
By default, synapse can only write to the working-directory (/var/lib/synapse
) set in its service file. A write-error may occur if synapse writes to a different path (e.g. your media-store is in /var/lib/matrix-synapse/media
).
You can allow access to other directories by creating a replacement unit file for synapse.service
and by adding ReadWritePaths=your_paths
to the [Service]
section.
High memory consumption
The memory consumption of Synapse can be significantly reduced[1] by installing jemalloc包. To enable it, the environment variable LD_PRELOAD
must be set accordingly. This can be done by creating /etc/default/synapse
, which will be applied by the systemd unit file.[2]
/etc/default/synapse
LD_PRELOAD=/usr/lib/libjemalloc.so
After enabling jemalloc, the memory footprint can be reduced further by tuning cache settings: [3]
/etc/synapse/homeserver.yaml
caches: cache_autotuning: max_cache_memory_usage: 1024M target_cache_memory_usage: 758M min_cache_ttl: 5m
The configuration options under cache_autotuning
will not work unless jemalloc is enabled.