📜 ⬆️ ⬇️

Installing 1C Fresh from scratch using Linux and PostgreSQL

In this article with pictures, the Button will tell you how to deploy your own fresh Blackjack with PostgreSQL and Linux. We hope that it will help those who are trying to install 1C Fresh and drowned a bit in the volumes of official documentation. When deploying, we will make the most of free software.



What is 1C Fresh


1C Fresh is a technology for publishing solutions. That is, it is a service that allows you to publish access to various solutions based on 1C to a mass user, to link these solutions into a single system with general administration and maintenance.

The central element is the Service Manager, a control configuration that links the remaining elements. It stores all information about the components of the service, about the versions of configurations, about users, data areas, distributes commands to perform various operations.
')
The right hand of the Service Manager is the Service Agent, a service configuration that deals with the maintenance of application configurations. typical tasks of the Service Agent are:


These tasks are done by the Service Agent using the configurator. Until recently, it was the only service element requiring the Windows platform. But in the new version of the technology 1C Fresh 1.0.19, developers have eliminated this restriction, now the Service Agent can work on Linux.

Information databases are application configurations published through the Service Manager. Configurations that currently support service mode operation:


There is an opportunity to publish your own solutions, ITS has recommendations for improvement.

These elements listed above are basic and necessary for deployment. There are also others that provide additional functionality, but they are not necessary:


There are other components of the service, you can read about them on the site

Input data


Briefly describe the hosts and services that will work on them. The entire infrastructure will be deployed on a virtualization server, so we will spread services across different virtual machines. When using KORP licensing, you can also divide the functionality, for example, to transfer the processing of background jobs to a separate application server. In the minimum configuration, you can build on two hosts: place the database and the application server on Linux, and put the Agent of the Service under the control of Windows.

HostnameSoftware and functionalityVM resources
fresh-db.knopka.intDebian 9, PostgreSQL 9.6 DBMS4 core \ 10Gb
fresh-app-01.knopka.intDebian 9, 1C: Enterprise server, application configurations4-6 core \ 12-16Gb
fresh-app-02.knopka.intDebian 9, 1C: Enterprise Server, Service Manager4 core \ 8Gb
fresh-app-sa.knopka.intWindows 1C: Enterprise Server, Service Agent4 core \ 8Gb
fresh-app-sa.knopka.intDebian 9, Apache 2.4, 1C: Enterprise server, web module2 core \ 4Gb


Initial machine preparation


There will be databases: fresh-db.knopka.int


We use PostgreSQL as the database server. For convenience of updating we will connect PostgresPro repositories. 1C also provides the distribution, you can safely use it.

sh -c 'echo "deb http://1c.postgrespro.ru/deb/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/postgrespro-1c.list' wget --no-verbose -O - http://1c.postgrespro.ru/keys/GPG-KEY-POSTGRESPRO-1C | apt-key add - && apt-get update apt-get install postgresql-pro-1c-9.6 

For each database, we will create a cluster that will serve a separate PostgreSQL instance. This allows you to manage each database and replicate.

 pg_createcluster 9.6 <clustername> -d <dir> systemctl daemon-reload 

< clustername > is the name of our cluster, we will call it the same as the database serviced in the cluster;
< dir > is the directory in which the cluster will be created.

The next free port after 5432 will be used unless explicitly specified during creation. You can check the list of clusters like this:

 pg_lsclusters 

Connect to the cluster (specifying the port on which it works) and create a role (you need a superuser), under which the administration server will interact with the database:

 su postgres psql -p 5433 

 create role unoconnector with login superuser; alter role unoconnector with encrypted password 'password'; 

Be sure to perform the initial setup. Each cluster creates its own configuration files. For simplicity, you can use PgTune . Set the environment parameters and get the recommended settings at the output:



Immediately, we note that the recommended does not mean optimal, in the process of work you may need to make adjustments. In one of the previous articles we looked at PostgreSQL setup, you can learn something useful from there.

Here are the application servers on Linux: fresh-app- [01-02] .knopka.int


Install the necessary packages:

 apt-get install libperl5.24 libxslt1.1 libicu57 tcl8.5 libpython3.5 libpython2.7 libssl-dev krb5-multidev ssl-cert libssl-dev libgsf-1-114 imagemagick libgsf-1-dev ttf-mscorefonts-installer 

Activate the fonts and overload the server:

 fc-cache -fv reboot 

Download the archive with the 1C: Enterprise server packages and unpack it into a separate directory, then install:

 dpkg -i 1c-enterprise83-common_*_amd64.deb 1c-enterprise83-server_*_amd64.deb 1c-enterprise83-ws_*_amd64.deb 1c-enterprise83-common-nls_*_amd64.deb 1c-enterprise83-server-nls_*_amd64.deb 1c-enterprise83-ws-nls_*_amd64.deb 

We grant usr1cv8 rights to the / opt / 1C directory:

 chown -R usr1cv8:grp1cv8 /opt/1C 

We will set up a technological journal, at the installation stage it will be useful if something goes wrong. We will collect exceptional events that may not be processed, but will also cause the application to crash, as well as write server requests and responses. Bonus will store dumps. To do this, create a directory:

 mkdir -p /opt/1C/v8.3/x86_64/conf 

And put the logcfg.xml file there with the following content:

 <?xml version="1.0"?> <config xmlns="http://v8.1c.ru/v8/tech-log"> <log location="/var/log/1c/excp" history="24"> <event> <eq property="name" value="excp"/> </event> <property name="all"/> </log> <log location="/var/log/1c/vrs" history="24"> <event> <eq property="name" value="vrsrequest"/> </event> <event> <eq property="name" value="vrsresponse"/> </event> <property name="all"/> </log> <dump location="/var/log/1c/dumps" create="1" type="3"/> </config> 

Create directories for logs and dumps, and give rights to the user usr1cv8:

 mkdir -p /var/log/1c/excp /var/log/1c/vrs /var/log/1c/dumps chown -R usr1cv8:grp1cv8 /var/log/1c 

Run:

 /etc/init.d/srv1cv83 start 

Make a unit to start the remote administration server (ras). Create the file /etc/systemd/system/ras.service with the content:

 [Unit] Description=RAS After=syslog.target After=network.target [Service] Type=forking WorkingDirectory=/opt/1C/v8.3/x86_64 User=usr1cv8 Group=grp1cv8 OOMScoreAdjust=-100 ExecStart=/opt/1C/v8.3/x86_64/ras cluster --daemon -p 1545 ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID TimeoutSec=300 Restart=always [Install] WantedBy=multi-user.target 


Activate our unit and start the service:

 systemctl daemon-reload systemctl enable ras systemctl start ras 

There will be an application server on Windows: fresh-app-sa.knopka.int


To update the service agent will need to run the Configurator. We have already written that in the new version the restriction on the use of Linux has been removed, but for example we will use Windows, so that it is clear how the work in this environment happens.

To start the administration server (ras) you need to register it as a service. Create a reg-ras.bat file with the following content:

 @echo off rem %1 -    1: set SrvUserName=< > set SrvUserPwd=< > set CtrlPort=1540 set AgentName=localhost set RASPort=1454 set SrvcName="1C:Enterprise 8.3 Remote Server" set BinPath="\"C:\Program Files\1cv8\%1\bin\ras.exe\" cluster --service --port=%RASPort% %AgentName%:%CtrlPort%" set Description="  1: 8.3" sc stop %SrvcName% sc delete %SrvcName% sc create %SrvcName% binPath= %BinPath% start= auto obj= %SrvUserName% password= %SrvUserPwd% displayname= %Description% 

We change the username and password to those from which the service will run. If Description is in Russian, do not forget to create a file in the desired encoding. Let's run the file execution, transfer the platform version as a parameter:

 reg-ras.bat 8.3.11.2899 

Then we start the service.

There will be a web-server of publications: fapache.knopka.int


Install apache:

 apt-get install apache2 

Download the archive with the server 1C: Enterprise and unpack into a separate directory, then install:

 dpkg -i 1c-enterprise83-common_*_amd64.deb 1c-enterprise83-server_*_amd64.deb 1c-enterprise83-ws_*_amd64.deb 1c-enterprise83-common-nls_*_amd64.deb 1c-enterprise83-server-nls_*_amd64.deb 1c-enterprise83-ws-nls_*_amd64.deb 

Create a configuration file to load the module at the start of apache and restart the service:

 echo "LoadModule _1cws_module \"/opt/1C/v8.3/x86_64/wsap24.so\"" > /etc/apache2/conf-available/1cws_module.conf ln -s /etc/apache2/conf-available/1cws_module.conf /etc/apache2/conf-enabled/1cws_module.conf /etc/init.d/apache2 restart 

We will set up a technological journal, for this we will create a directory:

 mkdir -p /opt/1C/v8.3/x86_64/conf 

And put the logcfg.xml file there with the following content:

 <?xml version="1.0"?> <config xmlns="http://v8.1c.ru/v8/tech-log"> <log location="/var/log/1c/excp" history="24"> <event> <eq property="name" value="excp"/> </event> <property name="all"/> </log> <log location="/var/log/1c/vrs" history="24"> <event> <eq property="name" value="vrsrequest"/> </event> <event> <eq property="name" value="vrsresponse"/> </event> <property name="all"/> </log> <dump location="/var/log/1c/dumps" create="1" type="3"/> </config> 

Create directories for logs and dumps, and give rights so that apache can write there:

 mkdir -p /var/log/1c/excp /var/log/1c/vrs /var/log/1c/dumps chown -R www-data:www-data /var/log/1c 

Creating a symbolic link to platform directories


New versions of the platform are installed in new directories containing a version number, for example,

C: \ Program Files \ 1cv8 \ 8.3.11.2899 \. To automate the update process a bit, create a SetCurrent1CVersion.cmd script that we will run when updating so that the symbolic link it creates is relevant:

 @echo off if /%1 == / goto help pushd "C:\Program Files\1cv8" if exist current\ rmdir current mklink /j current %1 popd goto end :help echo Usage: SetCurrent1CVersion.cmd <version> :end 

In our case, execute:

 SetCurrent1CVersion.cmd 8.3.11.2899 

Thus, we will always have a permanent path to the current version of C: \ Program Files \ 1cv8 \ current \

Adding a cluster and production servers in the administration console


We start the administration console of the 1C: Enterprise server and add a new central server. For authorized access, we add the central server administrator:



In the same way we add the cluster administrator:



Service Manager Setup


Expand base


First of all, we will prepare a cluster for the database using pg_createcluster, we will get the unoconnector user in it.

In the server administration snap-in, we will create a database for the service manager. Connecting to a non-standard port is carried out with the line fresh-app-02.knopka.int port = 5433.



After creating the database, go to the configurator, fill the configuration of the service manager. Then we enter the service manager under the Administrator login without a password. When you first start, it will set default values ​​and create predefined users.



Include password complexity:



Set logging logging details:



Set passwords for service users other than Anonymous (ProtectedUser, RemoteAccess, Administrator, Operator), set the parameters:



Create a publication


Now you need to publish the service manager so that you can access it via web services or a web client.

On the fapache.knopka.int server, put the sm.conf file with the following contents in the / etc / apache2 / sites-available directory:

 # sm   Alias /ext/sm /var/www/1cfresh/ext/sm <Directory /var/www/1cfresh/ext/sm/> AllowOverride All Options None Order allow,deny Allow from all SetHandler 1c-application ManagedApplicationDescriptor /var/www/1cfresh/ext/sm/default.vrd </Directory> # sm   Alias /int/sm /var/www/1cfresh/int/sm <Directory /var/www/1cfresh/int/sm/> AllowOverride All Options None Order allow,deny Allow from all SetHandler 1c-application ManagedApplicationDescriptor /var/www/1cfresh/int/sm/default.vrd </Directory> 

and enable the use of this site:

 a2ensite sm 

Now we need to create directories in which we place the default.vrd files:

 mkdir -p /var/www/1cfresh/ext/sm /var/www/1cfresh/int/sm 

default.vrd for external publishing:

 <?xml version="1.0" encoding="UTF-8"?> <point xmlns="http://v8.1c.ru/8.2/virtual-resource-system" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base="/ext/sm" ib="Srvr=fresh-app-02.knopka.int;Ref=sm;" enableStandardOData="true"> </point> 

default.vrd for internal publishing:

 <?xml version="1.0" encoding="UTF-8"?> <point xmlns="http://v8.1c.ru/8.2/virtual-resource-system" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base="/int/sm" ib="Srvr=fresh-app-02.knopka.int;Ref=sm;" enableStandardOData="true"> <ws /> </point> 

Rereading apache settings:

 systemctl reload apache2 

Let's check how the publication works. In the web client in the address bar enter fapache.knopka.int/ext/sm

If everything is done correctly, the user authentication window will appear in the window. Go to the Administrator user and see the admin desktop:



Description of the service structure


For the service to function properly, its structure must be described.

Access settings


On the “Administration” tab, open “Configuration Settings” → “Access Settings”, register the external and internal addresses of the service manager and password for the RemoteAccess user.

The external address will be fapache.knopka.int/ext/sm
As an internal fapache.knopka.int/int/sm

To start, this will be enough; we’ll return to the settings of the other fields later.



Service segments


On the “Administration” tab, open the “Service Segments” and create a new segment. Let's call it "Local Area Network".

Registration of versions of the 1C: Enterprise platform


The service allows the use of multiple server clusters using different platforms. Each version of the platform must be registered in the service manager.
“Administration” → “Versions of 1C: Enterprise platform”

Administration Server Registration (ras)


“Administration” → “Administration Servers (ras)”. Add all servers where ras is raised, for example:



Registration of working servers


"Administration" → "Working servers". Add all of our working servers and a working server administrator account:



Registering a server cluster


"Administration → Clusters". Add clusters and a cluster administrator account:



Service Manager Registration


"Administration → Configurations". We create a new configuration, the type of configuration for the service manager is “Managing”. The configuration name must exactly match the configuration name in the Configurator.



In the same window in the left part, select "Configuration Versions" and create a new entry by selecting "Enter version information manually." Now you can not add the configuration file, it is only needed to update the configuration for this version. The remaining fields are filled with:



Now you need to register the information database of the service manager: “Administration → Information databases”. Fill in the screenshot, do not forget to put a tick "on support."



Next, go to "Administration → Service Managers" and add an entry:



Returning to “Administration”, open “Configuration Settings” → “Access Settings” and select our service manager in the “This Service Manager” field.



At the moment, the description of the structure of the service can be completed, we will return to the additional settings of web servers and their groups later when the application gateway will function.

Configure the service agent


Unwrap


The process of creating and adding a service agent is similar to adding a service manager. We prepare a cluster for the new database on the database server fresh-db.knopka.int for a new database with the help of pg_createcluster, we get a user to connect.

In the 1C server administration console, we add the server fresh-app-sa.knopka.int, create the fresh-app-sa cluster of the same name, add the central server and cluster administrators, create the sa database with the connection parameters fresh-db.knopka.int port = 5434 .

Go to the Configurator and load the configuration of the service agent. After loading the configuration, run the interactive launch. If everything is correct, then we will see this window:



Go to “Configuration and Administration” → “Launch the Configurator” and set the path. Recall that current is a symbolic link to the current platform version.



Publish


Let's publish our service agent on the web-publications server fapache.knopka.int.
In the directory / etc / apache2 / sites-available put the file sa.conf with the following content:

 # sa   Alias /int/sa /var/www/1cfresh/int/sa <Directory /var/www/1cfresh/int/sa/> AllowOverride All Options None Order allow,deny Allow from all SetHandler 1c-application ManagedApplicationDescriptor /var/www/1cfresh/int/sa/default.vrd </Directory> 

For a service agent, you only need an internal publication. We include the use of this site:

 a2ensite sa 

Now you need to create a directory in which we place the default.vrd files.

 mkdir -p /var/www/1cfresh/int/sa 

default.vrd:

 <?xml version="1.0" encoding="UTF-8"?> <point xmlns="http://v8.1c.ru/8.2/virtual-resource-system" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base="/int/sa" ib="Srvr=fresh-app-sa.knopka.int;Ref=sa;" enableStandardOData="true"> <ws /> </point> 

Restart apache and check in the browser the address:

fapache.knopka.int/int/sa/ws/InterfaceVersion?wsdl

If everything is done correctly, a WSDL description of the web service provided by the service agent database will appear.

We will register


To begin, register the configuration and its version. In the service manager, open “Administration” → “Configurations” and create a new entry. The name is the same as the configuration name in the Configurator, the type is “Service”:



Go to the "Configuration Version", add a new entry manually.



We register information base. Open “Administration” → “Information databases” and create a new entry with the name “Service Agent”. Immediately check the connection to the database.



Next, “Administration → Service Agents”, add an entry:



Everything, the agent of service is ready to use.

Configuring the information base of the application solution on the example of "Enterprise Accounting"


Unwrap


And again, the familiar process of creating a base. We deploy a cluster on a database server. In the administration console, we connect the server fresh-app-01.knopka.int, create the ea_01 database on fresh-db.knopka.int port = 5435.

We load the configuration of Enterprise Accounting 3.0.52.42, we perform an interactive launch.
Create an Administrator user, set a password for him, forbid him to change and display the login in the selection list. When saving, we agree to enter the user in the Administrators group:



Set constants


In the official documentation, the installation of constants is described only for information bases of applied solutions, but they must also be installed in the service manager. Enable the option "All functions":
Main menu → Tools → Options → Display the "All Functions" command.
and set the following values ​​to the constants:

Detail the update of information security in the log on
Use offline work in service model On
Use data sync On
Use data sync in local off mode
Use data synchronization in service model On
Use data synchronization in the service model with the local program Off
Use data synchronization in the service model with the application on the Internet On

You also need to create a RemoteAccess user; we do this in the Configurator, having previously included the complexity of password checking in the information base parameters. We set the password, prohibit it from changing, remove the display in the selection list.

We assign the following roles to the RemoteAccess user:


At this time we finish with the Configurator and close it.

Publish


Create a /etc/apache2/sites-available/ea_01.conf configuration file on the fapache.knopka.int server:

 # ea_01   Alias /ext/ea_01 /var/www/1cfresh/ext/ea_01 <Directory /var/www/1cfresh/ext/ea_01/> AllowOverride All Options None Order allow,deny Allow from all SetHandler 1c-application ManagedApplicationDescriptor /var/www/1cfresh/ext/ea_01/default.vrd </Directory> # ea_01   Alias /int/ea_01 /var/www/1cfresh/int/ea_01 <Directory /var/www/1cfresh/int/ea_01/> AllowOverride All Options None Order allow,deny Allow from all SetHandler 1c-application ManagedApplicationDescriptor /var/www/1cfresh/int/ea_01/default.vrd </Directory> 

and enable the use of this site:

 a2ensite ea_01 

Now we need to create directories in which we place the default.vrd files:

 mkdir -p /var/www/1cfresh/ext/ea_01 /var/www/1cfresh/int/ea_01 

default.vrd for external publishing:

 <?xml version="1.0" encoding="UTF-8"?> <point xmlns="http://v8.1c.ru/8.2/virtual-resource-system" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base="/ext/ea_01" ib="Srvr=fresh-app-01.knopka.int;Ref=ea_01;" enableStandardOData="true"> <zones> <zone specify="false" safe="true"/> <zone specify="true" safe="true"/> </zones> <ws pointEnableCommon="false"> <point name="Exchange" alias="exchange.1cws" enable="true"/> <point name="Exchange_2_0_1_6" alias="exchange_2_0_1_6.1cws" enable="true"/> <point name="InterfaceVersion" alias="InterfaceVersion.1cws" enable="true"/> </ws> </point> 

default.vrd for internal publishing:

 <?xml version="1.0" encoding="UTF-8"?> <point xmlns="http://v8.1c.ru/8.2/virtual-resource-system" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base="/int/ea_01" ib="Srvr=fresh-app-01.knopka.int;Ref=ea_01;" enableStandardOData="true"> <ws /> </point> 

Rereading apache settings:

 systemctl reload apache2 

We will register


Go to the service manager and register the new configuration in “Administration” → “Configurations”. This time the name will be “Accounting Enterprise”, and the type will be “Applied”.



In the “Configuration Versions” section, we create a new entry in which we indicate the current version, the release version type, and the current platform version.

Open “Administration” → “Information databases” and register information database:



Now for this information base you need to register an administration account. This is necessary for the service agent so that it can connect to the database with administrator rights, update and manage it. This is done here, in the infobase window in the “Administrative Accounts” section.



In the application information base we will create data areas. To do this, in the main section of the information database window, go to the "Advanced" tab, check the "Add new areas" box and remove the "Fill in the areas with initial data". We did not prepare the initial data, so they simply do not exist.



Messages are used to exchange information between the agent, the service manager, and the application information databases. For example, you can see the list in the service manager in the section “Administration” → “Messaging”. We will not dwell on the messages in detail; information on working with them can be found in the official documentation of 1C Fresh.

You can monitor the readiness of preparing areas in the “Desktop” → “Applications” window. Uncheck the “Only used” box and see three areas with the “New” status. As soon as all the operations on the preparation of the region are finished, she will change the state to “Finish”.

Service user and subscriber user


In order to be able to use the application in the service model, it is necessary to register the service user, grant him the right to work in his data area. The service-subscriber scheme itself is the following: The user is registered in the service, a subscriber is created for him, the subscribers of this subscriber, who are also users of the service, are added to the subscriber.

User registration requires setting up an email account to send an activation code. You can configure it in the service manager in the section “Administration” → “E-mail accounts”.We will not dwell on this in detail, since each has its own settings and everything is intuitively understandable. You can do without it and get the activation code in another way, we will tell about it below.

We go to the service manager on behalf of the user Anonymous without a password, after successful login click "Register" and enter data on the new user of the service. The e-mail address must be valid:



When you click the "Register" button, a window appears asking about the readiness to go through the activation of the created user, to which we will respond positively.

Next, we will need to enter the activation code sent to the e-mail specified during registration, but we will take it in the section “Service” → “Requests for registration”. Open the request and copy the request code of the form 0414fb84-cf59-11e7-f094-00155d003608 from there, this is the activation code we need.

After creating the service user, the service manager will also automatically create the subscriber and add the user's rights to the subscriber to the user. He can manage his applications, invite new users to work with them in the subscriber's applications.

Adding an application to the subscriber


Let's enter the service manager using the login sharikov.p:



Press the “Add” button and add the application “Enterprise Accounting”. It is enough to select only the type of application and wait until the “Used” column is in the “Availability” column.



When you click the "Login to application" button, the browser opens the address fapache.knopka.int/ext/ea_01/1 , where the last unit is the area number. In other areas, the user has no rights and can not log in.

From now on, we have a minimum running service 1C Fresh As you can see, deploying it is quite simple.

Conclusion


This is not all the functionality. You can configure the planned configuration updates, data synchronization in the service. Adding an application gateway ensures the scalability of the service instance by adding new information databases to it and keeping a single external address for similar information databases. The website and the service forum, monitoring inaccessibility and others can be easily commissioned in conjunction with the 1C Fresh service, which gives flexibility in the choice of functionality depending on your needs.

Source: https://habr.com/ru/post/345692/


All Articles