@@ -17,6 +17,7 @@ archive settings and as a service to write samples from PVs to the RDB.
1717You can build the archive engine from sources or fetch a binary from
1818https://controlssoftware.sns.ornl.gov/css_phoebus
1919
20+ Below are examples using either MySQL or PostgreSQL.
2021
2122Install MySQL (Centos Example)
2223------------------------------
@@ -39,10 +40,40 @@ To start RDB when computer boots::
3940 sudo systemctl enable mariadb.service
4041
4142
43+ Install PostgreSQL (RHEL 9.6)
44+ -----------------------------
45+
46+ Install::
47+
48+ sudo yum install postgresql-server
49+
50+ Key setup steps from `/usr/share/doc/postgresql/README.rpm-dist `::
51+
52+ sudo postgresql-setup --initdb
53+ sudo systemctl start postgresql.service
54+ sudo systemctl enable postgresql.service
55+
56+ By default, access to the database is extremely limited.
57+ In later examples, we want to allow a user ``archive `` to
58+ write data and a user ``report `` to read.
59+ An easy way to allow this from localhost is the following::
60+
61+ sudo su - postgres
62+
63+ # Add this to /var/lib/pgsql/data/pg_hba.conf
64+ host all all 127.0.0.1/32 password
65+
66+ pg_ctl reload
67+
68+ Note that the ``password `` type of access is not secure.
69+ Study the PostgreSQL documentation for secure alternatives
70+ that meet your requirements.
71+
72+
4273Create archive tables
4374---------------------
4475
45- Connect to mysql as root::
76+ For MySQL, connect to mysql as root::
4677
4778 mysql -u root -p'$root'
4879
@@ -64,6 +95,44 @@ as "storage" and enforcing the correctness of the data inside the archive engine
6495when it is importing a configuration or adding samples.
6596For a production setup, you may want to add or remove constraints as desired.
6697
98+ For PostgreSQL, connect to the database as the ``postgres `` super user::
99+
100+ sudo su - postgres -c psql
101+
102+ and create the archive tables as shown in
103+ https://github.com/ControlSystemStudio/phoebus/blob/master/services/archive-engine/dbd/postgres_schema.txt
104+
105+ You should not simply copy/paste the whole file into the psql shell.
106+ For example, commands for creating accounts and setting permissions are shown in the file as comments,
107+ where some of them need to be executed _before_ and others _after_ creating all the archive tables.
108+ You need to decide if you want to paste those commands as shown in the comment,
109+ or change for example the passwords to your liking.
110+
111+ To test access, try this from any user account on the same host::
112+
113+ psql -h 127.0.0.1 -U archive -W archive
114+ Password: $archive
115+ SELECT * FROM channel;
116+ \q
117+
118+ psql -h 127.0.0.1 -U report -W archive
119+ Password: $report
120+ SELECT * FROM channel;
121+ \q
122+
123+ Example for python access::
124+
125+ pip install psycopg
126+
127+ python3
128+
129+ import psycopg
130+ with psycopg.connect("host=127.0.0.1 user=report password=$report dbname=archive") as conn:
131+ with conn.cursor() as cur:
132+ cur.execute("SELECT channel_id, name FROM channel")
133+ for row in cur:
134+ print("#%5d - %s" % (row[0], row[1]))
135+
67136
68137View Archive Data
69138-----------------
@@ -74,11 +143,20 @@ change these settings in your :ref:`preference_settings` ::
74143
75144 org.csstudio.trends.databrowser3/urls=jdbc:mysql://my.host.site.org/archive|RDB
76145 org.csstudio.trends.databrowser3/archives=jdbc:mysql://my.host.site.org/archive|RDB
146+ org.phoebus.archive.reader.rdb/user=report
147+ org.phoebus.archive.reader.rdb/password=$report
77148
78149The ``MySQL.dbd `` used to install the archive tables adds a few demo samples
79150for ``sim://sine(0, 10, 50, 0.1) `` around 2004-01-10 13:01, so you can simply
80151add that channel to a Data Browser and find data at that time.
81152
153+ For PostgreSQL, change the URLs to
154+ ``jdbc:postgresql://my.host.site.org:5432/archive ``
155+
156+ In case of connection problems, you may want to start with ``my.host.site.org ``
157+ replaced by ``127.0.0.1 `` and running on the database host.
158+ Use the MySQL or PostgreSQL command line tools to test connections with
159+ the same host, port, user and password.
82160
83161
84162List, Export and Import Configurations
@@ -91,13 +169,7 @@ List configurations::
91169 ID Name Description URL
92170 1 Demo Demo Engine http://localhost:4812
93171
94-
95- <<<<<<< Updated upstream
96- Extract configuration into an XML file::
97- =======
98-
99172Extract configuration into an XML file::
100- >>>>>>> Stashed changes
101173
102174 archive-engine.sh -engine Demo -export Demo.xml
103175
@@ -145,15 +217,10 @@ Run the Archive Engine
145217To start the archive engine for a configuration::
146218
147219 archive-engine.sh -engine Demo -port 4812 -settings my_settings.ini
148- <<<<<<< Updated upstream
149220
150221The engine name ('Demo') needs to match a previously imported configuration name,
151222and the port number (4812) needs to match the port number used when importing the configuration.
152- =======
153-
154- The engine name ('Demo') needs to match a previously imported configuration name,
155- and the port number (4812) needs to match the port number used when importing the configuration.
156- >>>>>>> Stashed changes
223+
157224The settings (my_settings.ini) typically contain the EPICS CA address list settings
158225as well as archive engine configuration details, see archive engine settings
159226in :ref: `preference_settings `.
0 commit comments