Category Archives: WinCC OA
WinCC OA history data replication (RDBSyncForward) HowTo…
It is possible to use the RDBSyncForward feature to replicate history data to a second Oracle database.
WinCC OA primarily writes the history data to the first database. Values are replicated from the first database to the second database by Oracle-Packages (part of WinCC OA). When the first database goes down then WinCC OA will continue to write history data to the second database. When the first database gets up and running again then WinCC OA will switch back to the first database and the history data which was written to the second database will be replicated from the second database to the first database.
The bi-directional replication is done asynchronously (periodically)! If one database crashes some history data may be lost.
Prepare two RDB configuration files
RDB_config_DB1.sql and RDB_config_DB2.sql.
Use RDB_config_template.sql: C:\Siemens\Automation\WinCC_OA\3.12\data\RDBSetup\ora\RDB_config_template.sql
Example configuration file with ASM is shown at the end.
The following lines are important for the data replication.
RDB_config_DB1.sql:
define whatpackage = 'fwd'
define connect_first = '&connect_identifier'
define connect_second = 'DB2'
define whatinstall = '3'
define syncjob_intval = 1
RDB_config_DB2.sql:
define whatpackage = 'fwd'
define connect_first = '&connect_identifier'
define connect_second = 'DB1'
define whatinstall = '3'
define syncjob_intval = 1
Prepare the TNSNAMES.ORA
It must contain both databases and must be deployed to the WinCC OA server(s) and to the database servers!
An TNSNAMES.ORA example you will find below.
Change to RDBSetup directory
C:\Siemens\Automation\WinCC_OA\3.12\data\RDBSetup\ora
Execute the RDB-Manager-Setup-Script for the first Oracle-Database.
> win_install.bat/unix_intall.sh _DB1
Execute the RDB-Manager-Setup-Scriptfor the second Oracle-Database.
> win_install.bat/unix_intall.sh _DB2
Change to sync subdirectory C:\Siemens\Automation\WinCC_OA\3.12\data\RDBSetup\ora\sync
Execute the sync setup for database 1
> sync_setup _DB1 ..\
Execute the sync setup for database 2
> sync_setup _DB2 ..\
Check arc_log table for (error)messages
select * from arc_log order by arc_log_id desc
Adapt WinCC OA config file
Important for the data replication is the following configuration:
[ValueArchiveRDB]
Db = “DB1,DB2”
RDB archive group configuration
In WinCC OA go to system management / database / RDB archive groups and set the check box “forwarding” for the archive groups you wanna sync.
WinCC OA config file
[general]
useRDBArchive = 1
useRDBGroups = 1
[ValueArchiveRDB]
DbUser = "RDBSYNC"
DbPass = "manager"
DbType = "ORACLE"
Db = "DB1,DB2"
writeWithBulk = 1
[ctrl]
queryRDBdirect = 1
CtrlDLL = "CtrlADO"
CtrlDLL = "CtrlRDBArchive"
CtrlDLL = "CtrlRDBCompr"
[ui]
queryRDBdirect = 1
CtrlDLL = "CtrlADO"
CtrlDLL = "CtrlRDBArchive"
CtrlDLL = "CtrlRDBCompr"
TNSNAMES.ORA
DB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Linux-DB-01)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = DB1))
)
DB2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Linux-DB-02)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = DB2))
)
RDB_config_DB1.sql
define connect_identifier = 'DB1'
define sysdba_user = 'SYS'
define yesno_newuser = 'yes'
define schema_user = 'RDBSYNC'
define app_user = 'RDBSYNCAPP'
define use_rman = 'rman'
define os_sys = 'unix'
define zip_backup = 'no'
define sequence_start = 100000
define sequence_maxvalue = 199999
define path_dbfile = '+DATA/WINCCOA/RDBSYNC/'
define path_tempdbfile = '+DATA/WINCCOA/RDBSYNC/'
define path_oraclebin = '/u01/app/oracle/product/12.1.0/dbhome_1/bin/'
define instance_name = 'DB1'
define host_name = 'linux-db-01'
define path_backup = '/u01/app/oracle/fast_recovery_area/DB1/winccoa/'
define path_alert = '+DATA/WINCCOA/RDBSYNC/'
define path_event = '+DATA/WINCCOA/RDBSYNC/'
define mytimezone = 'Europe/Vienna'
define asm_instance = '+ASM'
define service_name = 'DB1'
define number_db_storage = 1
define whatpackage = 'fwd'
define connect_first = '&connect_identifier'
define connect_second = 'DB2'
define whatinstall = '3'
define syncjob_intval = 1
RDB_config_DB2.sql
define connect_identifier = 'DB2'
define sysdba_user = 'SYS'
define yesno_newuser = 'yes'
define schema_user = 'RDBSYNC'
define app_user = 'RDBSYNCAPP'
define use_rman = 'rman'
define os_sys = 'unix'
define zip_backup = 'no'
define sequence_start = 100000
define sequence_maxvalue = 199999
define path_dbfile = '+DATA/WINCCOA/RDBSYNC/'
define path_tempdbfile = '+DATA/WINCCOA/RDBSYNC/'
define path_oraclebin = '/u01/app/oracle/product/12.1.0/dbhome_1/bin/'
define instance_name = 'DB2'
define host_name = 'linux-db-02'
define path_backup = '/u01/app/oracle/fast_recovery_area/DB1/winccoa/'
define path_alert = '+DATA/WINCCOA/RDBSYNC/'
define path_event = '+DATA/WINCCOA/RDBSYNC/'
define mytimezone = 'Europe/Vienna'
define asm_instance = '+ASM'
define service_name = 'DB2'
define number_db_storage = 1
define whatpackage = 'fwd'
define connect_first = '&connect_identifier'
define connect_second = 'DB1'
define whatinstall = '3'
define syncjob_intval = 1
WinCC OA pivot query to combine history values with same timestamp in one row…
This example combines the WinCC OA audit trail datapoint elements to a single row for one audit trail entry.
select “TS”,”TIME”,”USERNAME”,”UINUM”,”BATCHID”,”ITEM”,”ITEMTYPE”,”ACTION”,”OLDVAL”,”NEWVAL”,”REASON”,”HOST” from (
select h.ts, e.ELEMENT_NAME, NVL(to_char(h.VALUE_NUMBER),h.VALUE_STRING) val
from eventhistory h
join elements e on e.ELEMENT_ID = h.ELEMENT_ID
where e.ELEMENT_NAME in (
‘System1:_AuditTrail.time’,
‘System1:_AuditTrail.username’,
‘System1:_AuditTrail.uinum’,
‘System1:_AuditTrail.batchid’,
‘System1:_AuditTrail.item’,
‘System1:_AuditTrail.itemtype’,
‘System1:_AuditTrail.action’,
‘System1:_AuditTrail.oldval’,
‘System1:_AuditTrail.newval’,
‘System1:_AuditTrail.reason’,
‘System1:_AuditTrail.host’
)
) a
pivot (listagg(val) within group (order by element_name)
for element_name in (
‘System1:_AuditTrail.time’ as time,
‘System1:_AuditTrail.username’ as username,
‘System1:_AuditTrail.uinum’ as uinum,
‘System1:_AuditTrail.batchid’ as batchid,
‘System1:_AuditTrail.item’ as item,
‘System1:_AuditTrail.itemtype’ as itemtype,
‘System1:_AuditTrail.action’ as action,
‘System1:_AuditTrail.oldval’ as oldval,
‘System1:_AuditTrail.newval’ as newval,
‘System1:_AuditTrail.reason’ as reason,
‘System1:_AuditTrail.host’ as host
));
Simple Windows Phone App to get Push Notifications from WinCC OA…
WinCC OA read csv file…
A simple code how to read/import a CSV file into an array (dyn_dyn_string).
main()
{
string content;
fileToString(DATA_PATH+"/csvtest.txt", content); // read file into a string variable
dyn_dyn_string result;
dyn_string lines = strsplit(content, "\n"); // split the string into lines
for ( int i=1; i<=dynlen(lines); i++ ) {
result[i]=strsplit(lines[i], ";"); // delimiter ";"
}
DebugTN(result);
}
Limitations:
* Don’t do it in that way with very big files because it is read from the file into memory
* The delimiter “;” cannot be inside of a cell value
With oracle you can use external tables to access CSV files. After creating an external table it is possible to access the file by SQL:
select * from ext_tab
CREATE DIRECTORY EXT_DIR AS '/home/oracle/data';
-- Create table
create table ext_tab
(
Col1 VARCHAR2(30),
Col2 VARCHAR2(30),
Col3 VARCHAR2(30)
)
organization external
(
type ORACLE_LOADER
default directory EXT_DIR
access parameters
(
RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY ";"
)
location (EXT_DIR:csvtest.csv')
)
reject limit UNLIMITED;
Oracle TCP/IP Connection Timeout…
• Set the following registry entry (or create if it does not exist):
KeepAliveTime
Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Value type: REG_DWORD – Time in milliseconds
Range: 1 – 0xFFFFFFFF
Default value: 7.200.000 (two hours)
For example this value can be set to 180000 (decimal), equals 3 minutes.
• Reboot the computer.
• Oracle SQL*Net settings the tnsnames.ora file:
Add the line “(ENABLE=BROKEN)” as shown below:
TESTDB =
(DESCRIPTION =
(ENABLE=BROKEN)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = TESTDB)
)
)
This is also useful for WinCC OA and RDB-Manager.
WinCC OA Proxy on a separate host …
config file entries:
Host 1 => WinCC OA Server Name: winccoa
# nothing is needed
Host 2 => Proxyhost where the proxy runs: scada
[general]
dataHost = "winccoa"
eventHost = "winccoa"
[proxy]
server = "winccoa:4897"
server = "winccoa:4998"
Host 3 => Client
[general]
data = "winccoa"
event = "winccoa"
mxProxy = "winccoa scada:5678 cert"
if you do not add the [proxy] configuration at the proxy host then you will get following error when you try to connect from the client:
WCCILproxy (1), 2014.05.27 21:09:21.486, SYS, INFO, 222, Accept SSL connection from host ::ffff:192.168.1.125:1485.
WCCILproxy (1), 2014.05.27 21:09:26.078, PARAM,WARNING, 209, Cannot find the host in the list of the allowed-hosts: (winccoa:4897)
How to copy WinCC OA RDB-Manager schema and data to another database…
// create all tablespaces
create tablespace PVSSRDB_ALERT_00100000 datafile '+PVSS';
create tablespace PVSSRDB_ALERT_00100000I datafile '+PVSS';
create tablespace PVSSRDB_EVENT10_00100003 datafile '+PVSS';
create tablespace PVSSRDB_EVENT10_00100003I datafile '+PVSS';
create tablespace PVSSRDB_EVENT_00100001 datafile '+PVSS';
create tablespace PVSSRDB_EVENT_00100001I datafile '+PVSS';
create tablespace PVSSRDB_EXTERN_00100011 datafile '+PVSS';
create tablespace PVSSRDB_VALUES_00100002 datafile '+PVSS';
create tablespace PVSSRDB_VALUES_00100002I datafile '+PVSS';
create tablespace PVSSRDB_VALUES_00100006 datafile '+PVSS';
create tablespace TS_PVSSRDB datafile '+PVSS';
// create roles
create role R_APP_PVSSRDB;
// create database link to old database
create database link solaris connect to system identified by manager using 'solaris/db';
// create directory (in 12c with pluggable database the default data_pump_dir directory does not work)
create directory data_pump as '/app/oracle/admin/CDB/dpdump';
// import data with database link
impdp system/manager@database/pvss schemas=(PVSSRDB,PVSSAPP) network_link=solaris directory=data_pump parallel=2
// grant execute on sys.dbms_lock to pvssrdb
grant execute on dbms_lock to pvssrdb;
WinCC OA RDB-Manager Config & Database Settings…
WinCC OpenArchitecture using Oracle RDB-Manager…
*) Oracle db_files
*) Oracle logfile size
*) Oracle Password-Lifetime
*) Example WinCC OA config file
*) TCP/IP timeout settings on windows
*) WinCC OA Archive Group Sizing
Oracle db_files
===============
alter system set db_files=65536 scope=both;
Oracle logfile size
===================
For huge load (>1000 values/second) logfile size should be increased!
select * from v$logfile;
alter database add logfile size 512M;
alter database add logfile size 512M;
alter database add logfile size 512M;
remove other/small logfiles. If the logfiles are the current one then you have to switch the logfile and initiate a checkpoint before you are able to remove the old one.
alter system switch logfile;
alter system checkpoint;
alter database drop logfile group
Oracle Password-Life-Time
=========================
To prevent password expiration the default profile should be changed.
alter profile default limit password_life_time unlimited;
WinCC OA Config
===============
[general]
useRDBArchive = 1
useRDBGroups = 1
[data]
sendAlertsToRAIMA=1 # for HDB/RDB Parallel
[ValueArchiveRDB]
DbUser = "PVSSRDB"
DbPass = "xxx"
DbType = "ORACLE"
Db = "DB"
writeWithBulk = 1
[ctrl]
queryRDBdirect = 1
CtrlDLL = "CtrlADO"
CtrlDLL = "CtrlRDBArchive"
CtrlDLL = "CtrlRDBCompr"
[ui]
queryRDBdirect = 1
CtrlDLL = "CtrlADO"
CtrlDLL = "CtrlRDBArchive"
CtrlDLL = "CtrlRDBCompr"
Example TNSNAMES.ORA for a cluster with two networks:
DB =
(DESCRIPTION =
(ENABLE=BROKEN)
(ADDRESS_LIST=
(ADDRESS = (PROTOCOL = TCP)(HOST = mainhdr1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = mainhdr1b-vip)(PORT = 1522))
)
(ADDRESS_LIST=
(ADDRESS = (PROTOCOL = TCP)(HOST = mainhdr2-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = mainhdr2b-vip)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = DB)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 20)
(DELAY = 5)
)
)
)
Windows TCP/IP Timeout
======================
Also the tcp/ip timeout on windows should be decreased:
Set the following registry entry (or create if it does not exist): KeepAliveTime
Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Value type: REG_DWORD – Time in milliseconds
Range: 1 – 0xFFFFFFFF
Default value: 7.200.000 (two hours)
For example this value can be set to 180000 (decimal), equals 3 minutes.
WinCC OA Archive Group Sizing
=============================
Increase the max archive group size of existing (EVENT, ALERT) and new archives. The default size of 1GB is really damn small. Think about the max. db_files parameter (each archive file switch creates a new db file). Sizes of 20GB+ is no problem for Oracle. But keep in mind that there are file size limits (RDB Manager does not use Oracle Big-File-Tablespaces). For a block size of 8k the max file size is 32GB.
Block Size Maximum Datafile File Size
———– —————————
2k 4194303 * 2k = 8 GB
4k 4194303 * 4k = 16 GB
8k 4194303 * 8k = 32 GB
16k 4194303 * 16k = 64 GB
32k 4194303 * 32k = 128 GB
WinCC OA Online Panel Language Translator (Google Translate API)…
Automatic language translation of WinCC OA Panels with Google-Translate. Service for Message-Catalogs and Datapoint-List will be added (soon?)…
* Upload and import the panel-xml-files as a ZIP.
* Select source language and target language(s).
* Calculate the costs – Google-Translate-API is not for free, as well as this service isn’t – but one Coin/Panel is for free.
* Pay the fee with the RocWallet (In-App-Purchase)
* Start the translation
* Create Result-ZIP file
* Download ZIP & start your project…
Upload project zip…
Import, select languages, translate…
Order voucher and pay with mobile phone:
Review translated language texts:
Result: Chinese Translation
Result: Russian Translation