@@ -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,31 @@ 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+
67123
68124View Archive Data
69125-----------------
@@ -74,11 +130,20 @@ change these settings in your :ref:`preference_settings` ::
74130
75131 org.csstudio.trends.databrowser3/urls=jdbc:mysql://my.host.site.org/archive|RDB
76132 org.csstudio.trends.databrowser3/archives=jdbc:mysql://my.host.site.org/archive|RDB
133+ org.phoebus.archive.reader.rdb/user=report
134+ org.phoebus.archive.reader.rdb/password=$report
77135
78136The ``MySQL.dbd `` used to install the archive tables adds a few demo samples
79137for ``sim://sine(0, 10, 50, 0.1) `` around 2004-01-10 13:01, so you can simply
80138add that channel to a Data Browser and find data at that time.
81139
140+ For PostgreSQL, change the URLs to
141+ ``jdbc:postgresql://my.host.site.org:5432/archive ``
142+
143+ In case of connection problems, you may want to start with ``my.host.site.org ``
144+ replaced by ``127.0.0.1 `` and running on the database host.
145+ Use the MySQL or PostgreSQL command line tools to test connections with
146+ the same host, port, user and password.
82147
83148
84149List, Export and Import Configurations
@@ -91,13 +156,7 @@ List configurations::
91156 ID Name Description URL
92157 1 Demo Demo Engine http://localhost:4812
93158
94-
95- <<<<<<< Updated upstream
96- Extract configuration into an XML file::
97- =======
98-
99159Extract configuration into an XML file::
100- >>>>>>> Stashed changes
101160
102161 archive-engine.sh -engine Demo -export Demo.xml
103162
@@ -145,15 +204,10 @@ Run the Archive Engine
145204To start the archive engine for a configuration::
146205
147206 archive-engine.sh -engine Demo -port 4812 -settings my_settings.ini
148- <<<<<<< Updated upstream
149207
150208The engine name ('Demo') needs to match a previously imported configuration name,
151209and 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
210+
157211The settings (my_settings.ini) typically contain the EPICS CA address list settings
158212as well as archive engine configuration details, see archive engine settings
159213in :ref: `preference_settings `.
0 commit comments