[CONTENT] SUSE Repository Mirroring Tool (RMT) mirror schedule configuration

Content One: Configure the mirror schedule

1.1 Modify /etc/systemd/system/multi-user.target.wants/rmt-server-sync.timer file

# vi /etc/systemd/system/multi-user.target.wants/rmt-server-sync.timer

Modify all content as follows:

[Unit]
Description=RMT Sync timer

[Timer]
OnCalendar=*-*-01 01:00:00
RandomizedDelaySec=9h
Unit=rmt-server-sync.service

[Install]
WantedBy=multi-user.target

(Note: here is an example with setting the mirror schedule to the 1st of every month)

1.2 Apply the settings to make them take effect

# systemctl restart rmt-server-sync.timer
# systemctl restart rmt-server-mirror.timer

Content Two: Disable the mirror schedule

2.1 Disable the mirror schedule

# systemctl disable --now rmt-server-sync.timer
# systemctl disable --now rmt-server-mirror.timer
# systemctl daemon-reload

2.2 Manual Mirror

# rmt-cli sync
# rmt-cli mirror

Or:

# rmt-cli sync ; rmt-cli mirror

[工具] Shell 将本地网站文件、网站数据库和 SSL 证书恢复到本地的 LNMP + SSL

介绍

基本信息

作者:朱明宇
名称:将本地网站文件、网站数据库和证书恢复到本地的 LNMP + SSL
作用:将本地网站文件、网站数据库和证书恢复到本地的 LNMP + SSL

使用方法

1. 将网站文件、网站数据库、网站的 SSL 公钥、网站的 SSL 私钥,4 个文件放在此脚本中变量 tmppath 对应的目录里
2. 给此脚本添加执行权限
3. 执行此脚本

脚本分割线里的变量

tmppath=/bcache #本地存放网站的文件备份、网站的 SSL 公钥、网站的 SSL 私钥、网站的数据库备份的地方
midname=eternalcenter #网站的文件备份和网站的数据库备份的中间名
cmidname=fullchain #网站的 SSL 公钥的中间名
kmidname=privkey #网站的 SSL 私钥的中间名
webpath=/usr/share/nginx/html #网站文件在本地的正式存放位置
sslpath=/etc/nginx/ssl #网站网站的 SSL 公钥、网站的 SSL 私钥在本地的正式存放位置dbuser=ec #网站在数据库中的用户名
dbname=ec #网站在数据库中的的库名

注意

1. 本地需要已经搭建好 LNMP 平台
2. 必须以 root 的身份执行此脚本
3. 这里的网站的 SSL 公钥和网站的 SSL 私钥都是以 pem 后缀结尾,可以修改成真实对应的后缀
4. 脚本中类似 ”mysql -uroot -p’eternalcenter’ -e “drop database $dbname;”“ 中的 “eternalcenter“ 是指本地 MariaDB 数据库 root 用户的密码,需要修改成 MariaDB 数据库的 root 用户的真实密码
5. dbname=ec 网站在数据库中的的库名,每次执行此脚本时这个库里面以前的数据都会被清空

脚本

#!/bin/bash

####################### Separator ########################


tmppath=/bcache
midname=eternalcenter
cmidname=fullchain
kmidname=privkey

webpath=/usr/share/nginx/html
sslpath=/etc/nginx/ssl

dbuser=ec
dbname=ec


####################### Separator ########################

nowdirectory=`pwd`

#sudo systemctl stop nginx
#sudo systemctl stop php-fpm

cd $tmppath

sqlfile=`ls | grep $midname | grep -E \.sql$ | tail -1`
tarfile=`ls | grep $midname | grep -E \.tar | tail -1`
crtfile=`ls | grep $cmidname | grep -E \.pem$ | tail -1`
keyfile=`ls | grep $kmidname | grep -E \.pem$ | tail -1`


#sleep 300

echo $sqlfile
if [ -n "$sqlfile" ];then
    mysql -uroot -p'eternalcenter' -e "drop database $dbname;"
    mysql -uroot -p'eternalcenter' -e "create database $dbname;"
    mysql -uroot -p'eternalcenter' -e "grant all privileges on $dbuser.* to \"$dbuser\"@\"localhost\";"
    mysql -uroot -p'eternalcenter' $dbname < $sqlfile
    rm -rf $sqlfile
fi

echo $tarfile
if [ -n "$tarfile" ];then
    rm -rf $webpath/*
    tar -zxvf $tarfile -C $webpath/ &> /dev/null
    rm -rf $tarfile
    chcon -t httpd_sys_content_t -R $webpath/*
    chown -R php-fpm:php-fpm $webpath/
fi

echo $crtfile
if [ -n "$crtfile" ];then
    rm -rf $sslpath/$crtfile
    mkdir -p $sslpath &> /dev/null
    mv $crtfile $sslpath/
    chcon -t httpd_config_t $sslpath/*
fi

echo $keyfile
if [ -n "$keyfile" ];then
    rm -rf $sslpath/$keyfile
    mkdir -p $sslpath &> /dev/null
    mv $keyfile $sslpath/
    chcon -t httpd_config_t $sslpath/*
fi

chcon -t httpd_config_t $sslpath

sudo systemctl restart nginx
sudo systemctl restart php-fpm

cd $nowdirectory

[DEBUG] SUSE Repository Mirroring Tool (RMT) resolve client use SUSEConnect command output ‘Error: Registration server returned ‘Internal Server Error’ (500)’ or ‘SUSEConnect error: trying to send a keepalive from a system not yet registered. Register this system first’

Error Reporting Command

# SUSEConnect --url

or:

# SUSEConnect --de-register

Error Code

Error: Registration server returned 'Internal Server Error' (500)

or:

SUSEConnect error: trying to send a keepalive from a system not yet registered. Register this system first

Solution 1: Make sure the /tmp directory has enough space

Step One: Make sure the /tmp directory has enough space

# df -h

At this point, ensure that the directory occupancy is not 100% based on the output content.

Step Two: Restart rmt-server

# systemctl restart rmt-server

Solution 2: Change the cache directory

Step One: Make new cache directory

# mkdir /var/rmttmp

(Note: here is an example with making the new cache directory named /var/rmttmp)

Step Two: Change the owner of the new cache directory

# chown -R _rmt:nginx /var/rmttmp

(Note: here is an example with changing the owner of directory named /var/rmttmp)

Step Three: Change the

# systemctl edit rmt-server-mirror.service

Change partial content as follow:

[Service]
Environment=
Environment="LOG_TO_JOURNALD=1" "LANG=en" "TMPDIR=/var/rmttmp/"

(Note: here is an example with setting the new cache directory to /var/rmttmp/)

Step Four: Restart rmt-server-mirror.service

# systemctl daemon-reload
# systemctl restart rmt-server-mirror.service

Reference

https://support.scc.suse.com/s/kb/RMT-mirroring-fails-when-tmp-runs-out-of-disk-space?language=en_US

[内容] SUSE Repository Mirroring Tool (RMT) 服务端的设置 (软件源) (自定义软件源版)

正文:

内容一:显示自定义软件源

# rmt-cli repos custom list

内容二:启用自定义软件源

# rmt-cli repos custom add <URL> <Customize Name>

内容三:删除自定义软件源

# rmt-cli repos custom remove <Customize Name>

参考文献:

https://documentation.suse.com/sles/15-SP4/single-html/SLES-rmt/index.html#sec-rmt-tools-rmt-cli

[步骤] SSL 证书公钥从 cer 格式到 pfx 格式的转换

正文:

步骤一:将 SSL 证书公钥从 cer 格式转换到 pem 格式

# openssl x509 -in <public certificate>.cer -inform der -outform pem -out <public certificate>.pem

步骤二:将 SSL 证书公钥和私钥从 pem 格式转换成 pfx

# openssl pkcs12 -export -in <public certificate>.pem -inkey <private certificate>.key -out <certificate>.pfx

参考文献:

https://access.redhat.com/solutions/7005234