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 服務端。
User management
You need at least one user on your fresh synapse server. You may create one as your normal non-root user with the command
[synapse]$ register_new_matrix_user -c /etc/synapse/homeserver.yaml http://127.0.0.1:8008
or using one of the matrix clients, for example element-desktop包, or the purple-matrix-gitAUR plug-in for libpurple包.
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.