Installation and configuration¶
Installation¶
Important
First need to do setting up the environment. All commands are executed only from superuser.
Mode superuser:
sudo -i
Important
Installation is performed on the control node.
Save the list of previously installed packages before starting the installation, this will allow to painlessly restore the system in case of damage. Run the following commands to do this:
mkdir -p /tmp/rollback/scheduler pip3 freeze > /tmp/rollback/scheduler/pip_before.txt
After that, the directory
/tmp/rollback/scheduler
will contain the filepip_before.txt
with a list of installed applications.Also save migration versions:
django-admin showmigrations --settings=scheduler.settings.django_settings > /tmp/rollback/scheduler/migrations.txt
Where:
/tmp/rollback/scheduler/
is file directory;migrations.txt
is name of file with migration versions.
Install the Scheduler package:
from Python package repository:
pip3 install scheduler
Save the list of installed packages after installation to be able to roll back changes:
pip3 freeze > /tmp/rollback/scheduler/pip_after.txt
Note
To install Scheduler on Astra Linux (Smolensk) do following:
Connect the provided repository with AccentOS packages.
Install the package with the command:
sudo apt install -y aos-scheduler
Installation on two or more controllers¶
It is need when installing Scheduler on two or more controllers:
- to replicate database for each of controllers;
- to replicate message broker for each of controllers;
- to install a module with the same parameters for each of controllers.
Note
Deleting and diagnostics of the module on each controller is performed in the same way as in the case of one controller.
Configuration¶
Perform the initial configuration of the module:
openstack aos configure -n scheduler client
Configure message broker RabbitMQ Server:
rabbitmqctl add_user aos password rabbitmqctl add_vhost aos rabbitmqctl set_permissions -p aos aos ".*" ".*" ".*" rabbitmqctl set_permissions aos ".*" ".*" ".*"
Create directory for logs with the required permissions:
mkdir -p /var/log/aos/scheduler chown -R aos:aos /var/log/aos/scheduler
Copy the sample configuration file, if using non-standard parameters, edit them (for details, see Configuration file):
cp /etc/aos/aos.conf.example /etc/aos/aos.conf cp /etc/aos/scheduler.conf.example /etc/aos/scheduler.conf
Create database using MySQL as an example, configure rights, database type and other parameters:
# Login to the database using the root password mysql -uroot -p # Create scheduler database CREATE DATABASE scheduler; # Give permission to read, edit, perform any actions on all tables in scheduler database GRANT ALL PRIVILEGES ON scheduler.* TO 'aos'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON scheduler.* TO 'aos'@'%' IDENTIFIED BY 'password'; # Exit the database
Edit section
[database]
of the configuration fileetc/aos/scheduler.conf
, for example:[database] url = mysql+pymysql://aos:password@tst.stand.loc:3306/scheduler?charset=utf8
Migrate databases:
openstack aos db migrate -n scheduler
Enable and start services systemd:
systemctl daemon-reload systemctl enable aos-scheduler-api.service systemctl start aos-scheduler-api.service systemctl enable aos-scheduler-beat.service systemctl start aos-scheduler-beat.service systemctl enable aos-scheduler-worker.service systemctl start aos-scheduler-worker.service
Create Scheduler API service:
openstack service create --name scheduler --description "Scheduler Service" scheduler
Create endpoints:
openstack endpoint create --region RegionOne scheduler internal http://controller:10001 openstack endpoint create --region RegionOne scheduler admin http://controller:10001 openstack endpoint create --region RegionOne scheduler public http://controller:10001
Configuration file¶
Note
Config file allows to override sections and parameters of common file aos.conf
for specific module.
Note
There are no lines with the level logging by default in the file scheduler.conf.example
, it is specified if necessary. Level logging is set by default in the general configuration file. More information about the configuration files can be found in the corresponding section.
Configuration file is presented in ini
format and consists of the following sections and parameters:
Section | Parameter | Description | Default value |
---|---|---|---|
DEFAULT | task_locale | Local naming of tasks collected by endpoints. For example, en. | en |
DEFAULT | time_zone | Time zone for logging process events Celery. | Europe/Moscow |
api | host | Scheduler api service host. | 0.0.0.0 |
api | logfile | Path to log file of aos-scheduler-api service. | |
api | num_workers | Scheduler api service num gunicorn workers. | 3 |
api | port | Scheduler api service port. | 10001 |
api | threads | Scheduler api service num gunicorn threads. | 10 |
beat | logfile | Path to log file of aos-scheduler-beat service. | |
beat | max_loop_interval | Interval between schedule checks. | 30 |
beat | sync_every | The number of completed tasks before the next synchronization. | 60 |
database | url | Setting up a connection to database. | mysql://aos:pas sword@localhost :3306/scheduler |
Important
When changing the parameters of the configuration file, to make them take effect, it is need to perform the procedure described in the section «Updating the configuration file».
Recovery plan¶
Roll back if the Scheduler plug-in installation or update fails:
Compare versions of migrations in file
/tmp/rollback/scheduler/migrations.txt
with current. If there are any differences, migrate to the previous version for each of the applications. Migration example:django-admin showmigrations --settings=scheduler.settings.django_settings openstack aos db migrate -n scheduler --migration "timetable 0017_auto_20161206_1023"
Revert to the previous state of the packages:
cd /tmp/rollback/scheduler diff --changed-group-format='%>' --unchanged-group-format='' pip_before.txt pip_after.txt > pip_uninstall.txt diff --changed-group-format='%<' --unchanged-group-format='' pip_before.txt pip_after.txt > pip_install.txt pip3 uninstall -r pip_uninstall.txt pip3 install -r pip_install.txt