Huawei Cloud Yaoyun Server L instance evaluation|Build an SSL certificate for the Domain Admin environment monitoring company website to implement expiration reminders

Insert image description here

This article is based on the scenario of Huawei Cloud Yaoyun Server L instance to experience the installation and deployment of the open source software Domain Admin to realize the expiration reminder of the SSL certificate.

1. Purchase Huawei Cloud Yao Cloud Server L instance

Open the Huawei Cloud Yao Cloud Server L instance purchase address

https://www.huaweicloud.com/product/hecs-light.html

Purchase steps:

  1. Click 购买the button to jump to the product purchase page of [Yunyao Cloud Server L Instance]

  2. Select specifications:

    • area华北-北京四
    • system imageCentOS 7.9
    • Instance specifications2核|2G
    • Purchase duration1个月
    • Purchase quantity1

At this point you can see the price: 配置费用:¥55.02, click 立即购买to jump to the [Order Configuration Confirmation] page

  1. Confirm purchase instance parameters
    • Check the agreement license

Click 去支付the button to jump to the [Purchase Yunyao Cloud Service] order payment page

  1. Pay order
    check华为云代金券

Click 去在线支付the button and choose the payment method that suits you. I actually paid 0.03RMB

2. Log in to the server

Go back to the console and find the server instance you just purchased.

2.1. Reset password

Considering that the web version of the control terminal is uncomfortable to operate, we use a local terminal to connect to the server.

Reset your password first. You can easily generate a random password through online tools.

https://mouday.github.io/tools/pages/password/index.html

2.2. Connect to the server

Use the ssh command to connect to the server through the public network address

ssh root@<服务器公网IP>

Welcome to Huawei Cloud Service

If the connection is correct, you can see the welcome message from Huawei Cloud

3. Install Domain Admin

Domain Admin is a domain name and SSL certificate monitoring platform based on Python + Vue3.js technology stack.

Used to solve the problem that SSL certificates for different business domain names are applied from different platforms and cannot be notified in time after expiration, resulting in abnormal online access and being scolded by the boss.

Domain Admin installation documentation

https://domain-admin.readthedocs.io/zh_CN/latest/manual/install.html

3.1. Check Python

$ python --version
Python 2.7.5

As you can see, Huawei Cloud Image CentOS 7.9is installed by default.Python 2.7.5

3.2. Check pip

Check pip installation

 pip -V
-bash: pip: 未找到命令

It was found that pip was not installed, so next we need to install pip

In order to facilitate management, the software we installed is placed /optin a folder.

cd /opt

Install pip

# 下载get-pip
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py

# 安装
python get-pip.py

# 检查
pip -V
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)

3.3. Install Domain Admin

Install domain-adminandgunicorn

gunicorn, "Green Unicorn" is a Python WSGI HTTP server for UNIX that can be used as a server for domain-admin

# 使用清华源镜像
pip install gunicorn domain-admin

Since the pip mirror is not set, the download speed is slow and you need to wait for a while.

If the speed is too slow, you can also use domestic mirroring to speed up

# 使用清华源镜像
pip install gunicorn domain-admin -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

## 当然也可以选择华为云镜像
pip install fabric -i https://repo.huaweicloud.com/repository/pypi/simple --trusted-host https://repo.huaweicloud.com

3.4. Start

You can have the service listen on port 80

gunicorn --bind '0.0.0.0:80' 'domain_admin.main:app'

3.5. Open port

Check the security group and find that only port 22 is open. We also need to open it 80端口for web access.

4. Use Domain Admin

You can access it through the public IP, enter the default account and password to log in (account: admin / password: 123456), and add the domain name that needs to be monitored.

For more help, please refer to his documentation:

  • https://github.com/mouday/domain-admin
    Insert image description here
    In this way, you can sleep peacefully on the weekends, and you no longer have to worry about low-level exceptions on the weekends causing bonuses to be deducted.

5. Problems encountered

Due to version compatibility issues, we will inevitably encounter some strange problems

First of all, don’t panic when you encounter a problem. Read the error log. You can troubleshoot the problem based on the log, and then prescribe the right medicine to effectively solve the problem.

First of all, it is clear that domain-amdin is compatible with both Python2.7 and Python3. Therefore, the problem of domain-amdin can be eliminated.

5.1、No matching distribution found for invoke>=2.0

When installing domain-admin, I found an installation error that relied on the fabric package.

ERROR: Could not find a version that satisfies the requirement invoke>=2.0 
(from fabric) 
(from versions: 
0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.7.0, 0.8.0, 0.8.1, 0.8.2, 
0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.11.1, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.14.0, 
0.15.0, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.17.0, 0.18.0, 0.18.1, 0.19.0, 0.20.0,
0.20.1, 0.20.2, 0.20.3, 0.20.4, 0.21.0, 0.22.0, 0.22.1, 0.23.0, 1.0.0, 1.0.1, 
1.0.2, 1.1.0, 1.1.1, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 
1.7.0, 1.7.1, 1.7.2, 1.7.3)
ERROR: No matching distribution found for invoke>=2.0 (from fabric)

Through the release history and version compatibility on pypi, we found that the latest version fabric 3.2.2is no longer supported Python2.7.

https://pypi.org/project/fabric/2.7.1/

Therefore, we choose a supported Python2.7version and install it manually

pip install fabric==2.7.1

Execute the installation command again

pip install gunicorn domain-admin -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

Successful installation

5.2、ImportError: No module named abc

Executing the startup command found that flask_cors also had problems

    from flask_cors import CORS
  File "/usr/lib/python2.7/site-packages/flask_cors/__init__.py", line 11, in <module>
    from .decorator import cross_origin
  File "/usr/lib/python2.7/site-packages/flask_cors/decorator.py", line 16, in <module>
    from .core import get_cors_options, set_cors_headers, FLASK_CORS_EVALUATED
  File "/usr/lib/python2.7/site-packages/flask_cors/core.py", line 12, in <module>
    from collections.abc import Iterable
ImportError: No module named abc

The solution is to downgrade Flask-Cors and find a package compatible with python2.7 version

pip install Flask-Cors==3.0.10 --trusted-host repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple

5.3、AttributeError: ‘datetime.datetime’ object has no attribute ‘timestamp’

APScheduler also reported an error

   scheduler_service.init_scheduler()
  File "/usr/lib/python2.7/site-packages/domain_admin/service/scheduler_service.py", line 102, in init_scheduler
    scheduler.start()
  File "/usr/lib/python2.7/site-packages/apscheduler/schedulers/background.py", line 35, in start
    BaseScheduler.start(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/apscheduler/schedulers/base.py", line 167, in start
    self._real_add_job(job, jobstore_alias, replace_existing)
  File "/usr/lib/python2.7/site-packages/apscheduler/schedulers/base.py", line 863, in _real_add_job
    replacements['next_run_time'] = job.trigger.get_next_fire_time(None, now)
  File "/usr/lib/python2.7/site-packages/apscheduler/triggers/cron/__init__.py", line 179, in get_next_fire_time
    next_date, fieldnum = self._increment_field_value(next_date, fieldnum - 1)
  File "/usr/lib/python2.7/site-packages/apscheduler/triggers/cron/__init__.py", line 147, in _increment_field_value
    return normalize(dateval + difference), fieldnum
  File "/usr/lib/python2.7/site-packages/apscheduler/util.py", line 431, in normalize
    return datetime.fromtimestamp(dt.timestamp(), dt.tzinfo)
AttributeError: 'datetime.datetime' object has no attribute 'timestamp'

The solution is also to downgrade APScheduler

pip install APScheduler==3.8.1 --trusted-host repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple

6. Summary

By using Huawei Cloud Yaoyun Server L instance for actual evaluation, it meets the normal needs of enterprises. Python 2.7 is installed by default, making it easy to deploy third-party applications.
Domain Admin is just one application among many open source software, and many other applications can also be deployed on Huawei cloud servers. Although some problems were encountered during the installation process, they were quickly resolved. And these problems themselves are not problems with Huawei cloud servers. Servers from other companies will also encounter such problems. The root cause is the compatibility issue between the Python version and the pip package version. Knowing the root cause of the problem, it is easy to follow the clues and find a solution. Moreover, the image used this time is CentOS 7.9the image of Huawei cloud server, which is the same as the image of other cloud server manufacturers, so it is a CentOS problem.
At this point, I have purchased, logged in, installed and deployed third-party applications, and solved the problems encountered. I have completed the entire process. I have learned how to use Huawei Cloud Yaoyun Server L instances. I am also proud of the rise of China's cloud server providers. They provide cloud servers, making it easy for enterprises to use cloud resources, and simply purchase and configure them to achieve the functions their business needs. This is also the foundation of China’s Internet economy and provides the necessary infrastructure guarantee for the Internet’s take-off.

Guess you like

Origin blog.csdn.net/mouday/article/details/132944476