XConf-Server - Установка, настройка

RDK XConf Server

Официальный ресурс, документация: https://wiki.rdkcentral.com/display/RDK/XConf+Server

Git: https://github.com/rdkcentral/xconfserver

Apache Cassandra

https://cassandra.apache.org/_/index.html

https://archive.apache.org/dist/cassandra/

Хорошая мурзилка по командам: https://docs.datastax.com/en/cql-oss/3.3/cql/cql_using/useAboutCQL.html

Source code repository

Xconf consists of 2 web applications - Xconf dataservice and Xconf admin. Xconf DataService is the app that the STBs talk to. Xconf Admin allows humans to enter all the information necessary for Xconf to provide the correct information to STBs.

This repo contains the source code for both the applications - https://github.com/rdkcentral/xconfserver

Software Requirements (Reference setup)

Component	Recomendation
System/OS	Ubuntu 18.04.1 LTS 64bit or higher
Disk space	> 5GB
GIT	>= 2.17.1
Java/JDK	>= 1.8.0_352
Maven	>= 3.6.0
Python	2.7x

Installation of dependencies

1. Install Java JDK

Java JDK version should be 8. Get the supported version from Oracle or use the OpenJDK packages.

Steps to install Open JDK:

sudo apt-get update sudo apt-get install openjdk-8-jdk

Check your installation using the command:

java -version

2. Install Maven

Maven version should be 3 +.

To install maven follow these steps:

sudo apt update sudo apt install maven

Check the installation using:

mvn -version

3. Download xconf server code

We can download the latest xconfserver code from https://github.com/rdkcentral/xconfserver. The latest version of the code is available in main branch.

Create a folder

cd /opt sudo mkdir xconf sudo chmod -R 757 xconf

Step into the folder & clone the repo

cd xconf/ git clone https://github.com/rdkcentral/xconfserver.git -b main

To clone a particular tagged release:

You will get the name and details of each tag here in this page -https://github.com/rdkcentral/xconfserver/tags git clone –depth 1 –branch <tag-name> https://github.com/rdkcentral/xconfserver.git

eg:

git clone --depth 1 --branch v1.3.36 https://github.com/rdkcentral/xconfserver.git

4. Install and setup Cassandra (Version 4.1.0)

Install Cassandra

To install Cassandra , follow the below steps:

wget -c https://archive.apache.org/dist/cassandra/4.1.0/apache-cassandra-4.1.0-bin.tar.gz tar -xzf apache-cassandra-4.1.0-bin.tar.gz cd apache-cassandra-4.1.0

To start Cassandra, run the following command:

bin/cassandra

To verify that Cassandra is up and running, enter the following command:

bin/nodetool status

Configure Cassandra

Note: For the next step, make sure that python is installed. Because cqlsh is python based command line tool. If python is not installed , use this command: sudo apt install python2.7

schema.cql file is available in xconf-angular-admin/src/test/resources/schema.cql. We can use this cql file to create a corresponding schema . Open another terminal , step into apache-cassandra-4.1.0 folder and run the following command:

bin/cqlsh -f {path-to-the-schem.cql file}

eg:

bin/cqlsh -f /opt/xconf/xconfserver/xconf-angular-admin/src/test/resources/schema.cql

To check if tables are created successfully, we can use cqlsh. To start cqlsh, step into cassandra folder and enter the command:

bin/cqlsh

It gives cassandra cqlsh prompt as output. To check if all the tables are present enter the following commands in cqlsh prompt:

cqlsh> USE "demo"; cqlsh> DESCRIBE KEYSPACE;

To exit from cqlsh prompt:

cqlsh> quit

Production Installation

The production installation should be similar to the local installation, except that Cassandra will be installed to multiple hosts. Please see the Apache Cassandra documentation for more information.

Configuration and Service startup

1. Start Cassandra Service

To start an Xconf application, start the Cassandra server by executing the following commands:

cd apache-cassandra-4.1.0 bin/cassandra

Status of xconf server can be verified by using the command:

bin/nodetool status

You will get an output like this:

2. Configure and Start Application Services

Build and run steps mentioned below is based on these steps - https://github.com/rdkcentral/xconfserver#run-application.

a. Build Project

Go to the xconf-server folder and run the following command to download all dependencies.

cd /opt/xconf/xconfserver

Run the following command from the xconfserver folder

mvn clean install

Or you can run this command with unit tests skipped

mvn clean install -DskipTests=true

b. Configure Angular Admin UI

For first time application deployment, create a “service.properties” file under the path xconfserver/xconf-angular-admin/src/main/resources/service.properties with the following contents.

The sample service.properties file will be available in xconf-angular-admin/src/test/resources/service.properties, the below content is copied from the sample with a modification in cassandra port you can use this.

cassandra.keyspaceName=demo cassandra.contactPoints=127.0.0.1 cassandra.username= cassandra.password= cassandra.port=9042 cassandra.authKey= dataaccess.cache.tickDuration=60000 dataaccess.cache.retryCountUntilFullRefresh=10 dataaccess.cache.changedKeysTimeWindowSize=900000 dataaccess.cache.reloadCacheEntries=false dataaccess.cache.reloadCacheEntriesTimeout=1 dataaccess.cache.reloadCacheEntriesTimeUnit=DAYS dataaccess.cache.numberOfEntriesToProcessSequentially=10000 dataaccess.cache.keysetChunkSizeForMassCacheLoad=500 dataaccess.cache.changedKeysCfName=XconfChangedKeys4

Go to xconf-angular-admin folder

cd /opt/xconf/xconfserver/xconf-angular-admin

Run the following command from xconf-angular-admin folder

mvn jetty:run -DappConfig=${path-to-service-properties} -f pom.xml

For first time run only, we need to specify the path to service.properties. For the subsequent runs execute the below command in the folder xconfserver/xconf-angular-admin:

mvn jetty:run

To run the admin UI launch it as http://XCONF-SERVER-IP:19093/admin/ in any browser. Default port is set as 19093, it can be changed by using the option -Djetty.port=[port number]. This will redirect to the login page.

To launch in localhost: http://127.0.0.1:19093/admin

If the user wants both read and write permissions ,then enter username and password for the login as admin and admin respectively

If the user wants only read permissions ,then enter username and password for the login as user and user respectively.

Active Profile Option (for development purpose):

If xconf-angular-admin is run with -Dspring.profiles.active=dev UI will use not compiled .js and .css files but the source files. See xconf-angular-admin/src/main/webapp/WEB-INF/jsp/xconfindex.jsp for details. That can be useful for local development purpose, to update UI it is just needed to reload page with cache refresh option.

c. Configure DataService

For first time application deployment, create a service.properties file under the path xconfserver/xconf-dataservice/src/main/resources/service.properties with the following contents. The sample service.properties file will be available in xconf-dataservice/src/test/resources/sample-service.properties (There are some mistakes in that sample file - 1. cassandra.keyspaceName=demo 2. dataaccess.cache.changedKeysCfName=XconfChangedKeys4 that is rectified below. You can also edit that file with the changes 1 and 2. Then rename it to be used here), the below content is taken from there and modified with change in cassandra port.

cassandra.keyspaceName=demo cassandra.contactPoints=127.0.0.1 cassandra.username= cassandra.password= cassandra.port=9042 cassandra.authKey= dataaccess.cache.tickDuration=60000 dataaccess.cache.retryCountUntilFullRefresh=10 dataaccess.cache.changedKeysTimeWindowSize=900000 dataaccess.cache.reloadCacheEntries=false dataaccess.cache.reloadCacheEntriesTimeout=1 dataaccess.cache.reloadCacheEntriesTimeUnit=DAYS dataaccess.cache.numberOfEntriesToProcessSequentially=10000 dataaccess.cache.keysetChunkSizeForMassCacheLoad=500 dataaccess.cache.changedKeysCfName=XconfChangedKeys4

Step into xconf-dataservice folder

cd /opt/xconf/xconfserver/xconf-dataservice

Run the following command from xconf-dataservice folder

mvn jetty:run -DappConfig=${path-to-service-properties} -f pom.xml

For first time run only, we need to specify the path to service.properties. For the subsequent runs execute the below command in the folder xconfserver/xconf-dataservice:

mvn jetty:run

To launch the application go to http://<XCONF-SERVER-IP>:19092/queries/environments (Default port is set as 19092, it can be changed by using the option -Djetty.port=[port number]) . To verify, add an entry in the environments tab of the Xconf admin application and check whether the same is updated here in data service.

To launch in localhost : http://127.0.0.1:19092/queries/environments

NOTE: To run the Admin UI and data service applications in background start jetty server as follows: nohup mvn jetty:run &

Разное (Заметки Админа)

Для запуска всей этой кухни в рамках текущей сборки можно использовать скрипт (например: run-xconf.sh):

Don't run apache cassandra and xconf-server with root permission!

#!/bin/bash cd /opt/xconf/apache-cassandra-4.1.0/ bin/cassandra & sleep 20 cd /opt/xconf/xconfserver/xconf-angular-admin/ nohup mvn jetty:run & sleep 10 cd /opt/xconf/xconfserver/xconf-dataservice/ nohup mvn jetty:run &

Для запуска после перезагрузки системы можно добавить в cron:

@reboot /opt/xconf/run-xconf.sh

Admin UI login/password

Пароль для Админки можно изменить в файле xconfserver/xconf-angular-admin/src/main/java/com/comcast/xconf/admin/service/login/LoginService.java

private static final String ADMIN = "admin"; private static final String USER = "user";

Значения ADMIN и USER можно менять. Права останутся неизменными. Значения ADMIN и USER определяют так же и пароль. Т.е. login=password

Cassandra DB Security

По умолчанию, в данной сборке, безопасность Cassandra DB отключена. В конфигурационном файле apache-cassandra-4.1.0/conf/cassandra.yaml включены директивы authenticator: AllowAllAuthenticator и authorizer: AllowAllAuthorizer.

Для включения авторизации и отключения “беспарольного” доступа с правами “суперпользователя”, необходимо эти директивы заменить на след. значения:

authenticator: PasswordAuthenticator authorizer: CassandraAuthorizer

Перезапустить Cassandra DB

ps -fax kill -9 {process_number} cd apache-cassandra-4.1.0/ bin/cassandra

После этого зайти в базу можно с учетной записью cassandra (Дефолтная учетная запись. Для безопасности ее необходимо отключить. см. ниже)

cd apache-cassandra-4.1.0/ bin/cqlsh -u cassandra -p cassandra

Coздать нового пользователя с правами “superuser”

CREATE ROLE 'your_username' WITH SUPERUSER = TRUE AND LOGIN = TRUE AND PASSWORD = 'your_password';

Зайти в базу под новым пользователем. Отключить учетную запись cassandra

cd apache-cassandra-4.1.0/ bin/cqlsh -u <your_username> -p <your_password> DROP ROLE cassandra;

Для xconf-angular-admin cоздать пользователя базы demo с полным доступом без прав суперпользователя:

CREATE ROLE 'xconf-angular-admin-user' WITH SUPERUSER = FALSE AND LOGIN = TRUE AND PASSWORD = 'xconf-angular-admin-password'; GRANT ALL PERMISSIONS ON KEYSPACE demo TO 'xconf-angular-admin-user'; REVOKE AUThorize ON KEYSPACE demo FROM 'xconf-angular-admin-user'; LIST ALL PERMISSIONS ON KEYSPACE demo OF 'xconf-angular-admin-user';

Для xconf-dataservice cоздать пользователя базы demo с полным доступом без прав суперпользователя:

CREATE ROLE 'xconf-dataservice-user' WITH SUPERUSER = FALSE AND LOGIN = TRUE AND PASSWORD = 'xconf-dataservice-user-password'; GRANT ALL PERMISSIONS ON KEYSPACE demo TO 'xconf-dataservice-user'; REVOKE AUThorize ON KEYSPACE demo FROM 'xconf-dataservice-user'; LIST ALL PERMISSIONS ON KEYSPACE demo OF 'xconf-dataservice-user';

Внесите соответствующие данные авторизации для Cassandra в xconfserver/xconf-angular-admin/src/main/resources/service.properties и xconfserver/xconf-dataservice/src/main/resources/service.properties