Solutions to problems encountered in the deployment of CentOS 7.4 deployment automation OpsManage

Keywords: Python Celery pip Django

 

Install Python

Because I installed centos7, I don't need to install python2.7. Just follow the steps below.

yum install zlib zlib-devel readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel libdbi-devel ncurses-libs kernel-devel libxslt-devel libffi-devel python-devel zlib-devel  sshpass gcc git -y
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python 
 vi /usr/bin/yum

 

Install easy? Install

wget --no-check-certificate  https://pypi.python.org/packages/f7/94/eee867605a99ac113c4108534ad7c292ed48bf1d06dfe7b63daa51e49987/setuptools-28.0.0.tar.gz#md5=9b23df90e1510c7353a5cf07873dcd22
tar -xzvf setuptools-28.0.0.tar.gz
cd setuptools-28.0.0
python  setup.py  install

Errors may occur when executing python setup.py install, as shown in the following figure:

Q: why do I still report an error when I have implemented the definition above?

Solution:

This problem may be caused by some system reasons, but it can be solved well, as long as the mv in front of input is changed to python2.6.6.

Install pip

tar -xzvf pip-1.5.5.tar.gz
cd pip-1.5.5/
python setup.py install
python2.6.6 setup.py install
pip install -U pip

Installation module

cd /mnt/
git clone https://github.com/welliamcao/OpsManage.git
cd /mnt/OpsManage/
pip install -r requirements.txt
easy_install paramiko==2.4.1

It is possible to report the following errors when executing pip install -r requirements.txt:

Error 1:

Solution:

Upgrade pip.

pip install --upgrade pip

Question 2:

Solution:

Execute the following statement to solve the problem

yum install python-devel mysql-devel

Install redis

slightly

Install MySQL

Add the following information

[mysqld]
character_set_server = utf8

Create database

mysql> create database opsmanage DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

This problem may occur when installing mysql scripts

Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at scripts/mysql_install_db line 42

Just execute this command

yum install 'perl(Data::Dumper)'

Configure OpsManage

#######Line 23 Where modified###########
''' celery config '''
djcelery.setup_loader()
BROKER_URL = 'redis://127.0.0.1:6379 / 4 '-- change to your own redis address and redis Library

###########Line 60 of modification#########
REDSI_KWARGS_LPUSH = {"host":'127.0.0.1','port':6379,'db':4}  #Change to the corresponding redis address and Library

###########Line 75 Where modified#########
CHANNEL_LAYERS = {
    "default": {
       "BACKEND": "asgi_redis.RedisChannelLayer",  # use redis backend
       "CONFIG": {
            "hosts": [("127.0.0.1", 6379)],  #No password mode
            "channel_capacity": {
                                   "http.request": 1000,
                                   "websocket.send*": 10000,
                                },
            "capacity": 10000,           
           },
       "ROUTING": "OpsManage.routing.channel_routing",  # load routing from our routing.py file
       },
}

########Line 136 of amendment##########
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ["/alidata/OpsManage/OpsManage/static/",'/alidata/OpsManage/OpsManage/templates/'],
        'APP_DIRS': True,     #Change to the corresponding directory path
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]


############Line 159 where modified######
DATABASES = {
    'default': {
        'ENGINE':'django.db.backends.mysql',
        'NAME':'opsmanage',  #Database name
        'USER':'root',        #Database users
        'PASSWORD':'123456',  #Database password
        'HOST':'127.0.0.1',    #Database address
        'port':'3306'		#To add mysql port, it is not available by default. You need to add


#######Line 183 Where modified#########
STATIC_URL = '/static/'
STATICFILES_DIRS = (
     '/alidata/OpsManage/OpsManage/static/',  #Change to corresponding path address
    )


####Modify line 191##########
SFTP_CONF = {
             'port':22,
             'username':'root',
             'password':'123456',
             'timeout':30
             }  #Modify to an account that can sftp log in to OpsManage

Generate data table and administrator account

# cd /alidata/OpsManage/
# python manage.py makemigrations OpsManage
# python manage.py makemigrations wiki
# python manage.py makemigrations orders
# python manage.py makemigrations filemanage
# python manage.py migrate
# python manage.py createsuperuser

Configure certificate authentication

# ssh-keygen -t  rsa
# ssh-copy-id -i ~/.ssh/id_rsa.pub  root@ipaddress

Configure the Celery asynchronous task system

# echo_supervisord_conf > /etc/supervisord.conf
# export PYTHONOPTIMIZE=1
# vim /etc/supervisord.conf

Add the following to the last line

[program:celery-worker-default]
command=/usr/bin/python manage.py celery worker --loglevel=info -E -Q default
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-worker-default.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1

[program:celery-worker-ansible]
command=/usr/bin/python manage.py celery worker --loglevel=info -E -Q ansible
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-worker-ansible.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1


[program:celery-beat]
command=/usr/bin/python manage.py celery beat
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-beat.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1

[program:celery-cam]
command=/usr/bin/python manage.py celerycam
directory=/mnt/OpsManage
stdout_logfile=/var/log/celery-celerycam.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
numprocs=1

Start celery

# /usr/local/bin/supervisord -c /etc/supervisord.conf
# supervisorctl status #To check whether they are all running

Launch deployment platform

# cd /alidata/OpsManage/
# python manage.py runserver 0.0.0.0:8000

Visit and log in

Posted by dannydefreak on Wed, 01 Jan 2020 07:44:27 -0800