We moved the postgres data directory from its default location /var/lib/pgsql/data to /opt/localdrive/postgres.
This started to give lots of warnings in the SELinux audit logs. Postgres service was running fine as SELinux was in permissive mode, albeit giving verbose warnings as below.
$ sudo tail -f /var/log/audit/audit.log
type=AVC msg=audit(1543413248.637:5277): avc: denied { getattr } for pid=5285 comm="postgres" path="/opt/localdrive/postgres/base/16386/PG_VERSION" dev="sdb1" ino=1725 scontext=system_u:system_r:postgresql_t:s0 tcontext=unconfined_u:object_r:unlabeled_t:s0 tclass=file
type=SYSCALL msg=audit(1543413248.637:5277): arch=c000003e syscall=5 success=yes exit=0 a0=5 a1=7ffef5d9e1f0 a2=7ffef5d9e1f0 a3=1 items=0 ppid=1314 pid=5285 auid=4294967295 uid=26 gid=26 euid=26 suid=26 fsuid=26 egid=26 sgid=26 fsgid=26 tty=(none) ses=4294967295 comm="postgres" exe="/usr/bin/postgres" subj=system_u:system_r:postgresql_t:s0 key=(null)
type=PROCTITLE msg=audit(1543413248.637:5277): proctitle=706F7374677265733A206175746F76616375756D20776F726B65722070726F63657373202020
type=AVC msg=audit(1543413248.638:5278): avc: denied { write } for pid=5285 comm="postgres" name="12730" dev="sdb1" ino=1263 scontext=system_u:system_r:postgresql_t:s0 tcontext=unconfined_u:object_r:unlabeled_t:s0 tclass=file
type=SYSCALL msg=audit(1543413248.638:5278): arch=c000003e syscall=2 success=yes exit=5 a0=2947210 a1=2 a2=180 a3=50 items=0 ppid=1314 pid=5285 auid=4294967295 uid=26 gid=26 euid=26 suid=26 fsuid=26 egid=26 sgid=26 fsgid=26 tty=(none) ses=4294967295 comm="postgres" exe="/usr/bin/postgres" subj=system_u:system_r:postgresql_t:s0 key=(null)
To fix this, we had to perform a number of steps:
Edit SELinux to point to the current postgres data directory
$ sudo semanage fcontext -a -t postgresql_db_t "/opt/localdrive/postgres(/.*)?"
$ sudo restorecon -R -v /opt/localdrive/postgres
Restart Postgres service
$ sudo service postgresql restart
Now the audit "denied" logs are gone!
Showing posts with label PostgreSQL. Show all posts
Showing posts with label PostgreSQL. Show all posts
Wednesday, November 28, 2018
Monday, September 17, 2018
Configuring Orthanc with Postgres backend with a network data directory
So we hve configured Orthanc with a Postgres backend. To support a large-scale data store, we mapped a network directory as the data directory of Postgres. Then we configured Orthanc to have Postgres as its backend data store, instead of its default SQLite backend, using the Postgres plugin. There is also an option for a MySQL/MariaDB backend, which we found not stable with MySQL in a network directory.
However, since we have the configured Postgres in a network directory, we have to make sure everything is running fine. Unfortunately, when we reboot, often the network directory does not mount on its own. Therefore, despite our configuration to start Postgres and Orthanc at the boot time, they both fail.
Data directory unaccessible → Postgres fails to start. Postgres failed to start → Orthanc fails to start.
We have to configure the below services in Centos, following the same order.
1) Postgresql
$ sudo systemctl start postgresql
$ sudo systemctl enable postgresql
$ sudo systemctl status postgresql
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2018-09-17 14:46:41 EDT; 11min ago
Main PID: 2655 (postgres)
CGroup: /system.slice/postgresql.service
├─2655 /usr/bin/postgres -D /opt/pacs/postgres -p 5432
├─2657 postgres: logger process
├─2701 postgres: checkpointer process
├─2702 postgres: writer process
├─2703 postgres: wal writer process
├─2704 postgres: autovacuum launcher process
├─2705 postgres: stats collector process
├─2754 postgres: postgres orthanc ::1(48534) idle
└─2755 postgres: postgres orthanc ::1(48536) idle
Sep 17 14:45:59 HOST.NAME systemd[1]: Starting PostgreSQL database server...
Sep 17 14:45:59 HOST.NAME pg_ctl[2652]: pg_ctl: another server might be running; trying to start server anyway
Sep 17 14:46:41 HOST.NAME systemd[1]: Started PostgreSQL database server.
2) Orthanc
$ sudo systemctl start orthanc
$ sudo systemctl enable orthanc
$ sudo systemctl status orthanc
● orthanc.service - Orthanc DICOM server
Loaded: loaded (/usr/lib/systemd/system/orthanc.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2018-09-17 14:47:14 EDT; 8min ago
Docs: man:Orthanc(1)
http://www.orthanc-server.com/
Main PID: 2753 (Orthanc)
CGroup: /system.slice/orthanc.service
└─2753 /usr/sbin/Orthanc /etc/orthanc/orthanc.json
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.399045 ServerContext.cpp:167] Reloading the jobs from the last execution of Orthanc
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.399776 JobsEngine.cpp:281] The jobs engine has started with 2 threads
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.400023 ServerContext.cpp:293] Disk compression is disabled
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.400050 ServerIndex.cpp:1437] No limit on the number of stored patients
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.400490 ServerIndex.cpp:1454] No limit on the size of the storage area
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.400995 LuaContext.cpp:103] Lua says: Lua toolbox installed
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.403966 main.cpp:848] DICOM server listening with AET BMIPACS on port: 4242
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.404382 MongooseServer.cpp:1087] HTTP compression is enabled
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.405872 MongooseServer.cpp:1001] HTTP server listening on port: 8042 (HTTPS encryption is disabled, remote access is allowed)
Sep 17 14:47:15 HOST.NAME Orthanc[2753]: W0917 14:47:15.405915 main.cpp:667] Orthanc has started
First connect to the postgres client:
$ psql -U postgres
Password for user postgres:
psql (9.2.24)
Type "help" for help.
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
dcm4chee | dcm4chee | UTF8 | en_US.utf8 | en_US.utf8 |
mytest | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
orthanc | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
testtest | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
(7 rows)
Then go to another database to be able to drop the Orthanc database
orthanc=# \c mytest
You are now connected to database "mytest" as user "postgres".
mytest=# drop database orthanc;
ERROR: database "orthanc" is being accessed by other users
DETAIL: There are 2 other sessions using the database.
To clean the data from Orthanc entirely
The easy way is to drop the Orthanc database.
First connect to the postgres client:
$ psql -U postgres
Password for user postgres:
psql (9.2.24)
Type "help" for help.
postgres-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
dcm4chee | dcm4chee | UTF8 | en_US.utf8 | en_US.utf8 |
mytest | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
orthanc | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
testtest | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
(7 rows)
Then go to another database to be able to drop the Orthanc database
orthanc=# \c mytest
You are now connected to database "mytest" as user "postgres".
mytest=# drop database orthanc;
ERROR: database "orthanc" is being accessed by other users
DETAIL: There are 2 other sessions using the database.
Yes, first we need to stop Orthanc!
[root@researchpacs postgres]# systemctl stop orthanc
Now drop the database.
mytest=# drop database orthanc;
DROP DATABASE
mytest=#
Create the database again.
DROP DATABASE
mytest=#
Create the database again.
mytest=# create database orthanc;
CREATE DATABASE
Now you may start Orthanc again!
[root@researchpacs postgres]# systemctl start orthanc
You can also access your data via a browser, using the HTTP Port:
http://HOST.NAME:8042/app/explorer.html
Saturday, October 29, 2011
Google Summer of Code Mentor Summit 2011
Google Summer of Code Mentor Summit
Google invites the mentors for a two day unconference over a weekend to discuss about the Google Summer of Code, the respective projects, FOSS in general, or whatever that is applicable for the set of geeks. Google Summer of Code Mentor Summit is an interesting event hosted by Google and the sessions are scheduled by the attendees themselves. Google pays for the flight and the stay for the two nights (Friday the 21st and Saturday the 22nd of Oct/2011), providing dinner with style for the two nights. The mentor summits are held at the Google Headquarters (Building 43), CA 94043, USA. The event schedule is completed only at the day of the summit, as an ideal unconference! [Have a look at the Mentor Summit 2011 schedule with the parallel unconference tracks].
AbiWord at the Summit
AbiWord at the Summit
As a mentoring organization, AbiWord has been mentoring students for Google Summer of Code since 2006 - for 6 years consecutively, since the program was announced in 2005. In 2006, Martin Sevior represented AbiWord in the mentor summit [Read more on his experience at the mentor summit 2006]. I was, as a mentor from AbiWord for 2011, was really glad to represent AbiWord in the summit for 2011. This was the second time, AbiWord being present at the summit. This year we had 4 students who successfully completed their summer, among the 5 who had their summer with AbiWord [Read more on my thoughts on Google Summer of Code 2011].
Stay at California (21st - 24th, Oct 2011)
This year, the summit was held on 22nd of October the Saturday and 23rd the Sunday. "WildPalms" and "Domain" were the hotels organized by Google for the stay for the two nights. Most of the mentors stayed at WildPalms, Sunnyvale, CA, where some of them stayed at Domain, as rooms in WildPalms filled up. 2011 was the biggest summit ever with around 360 participants, where it was around 200 last year, mentioned Carol. Wild Palms is a silent and simple hotel. It reminded me the structure of the typical hostels - but I like it. We had shuttles to and from Google. We also had shuttles connecting Domain hotel, for them to join the dinner at Wild Palms.
Scheduling the unconference sessions
I [my user profile in the wiki] proposed and coordinated the unconference session titled "Community matters", the Saturday 1.30 - 2.30 at "Algiers". We discussed how and why a community matters the most, how to build a community, the challenges faced, and overcoming them. The session notes can be found in the wiki [Needs credentials to access the wiki page].
I have blogged with the session notes for the wider audience [Read "Community Matters!!!111" in this blog]. However, Google Summer of Code mentors can access the wiki to read more about the Mentor Summit 2011. All the session notes are posted to the wiki.
From Sri Lanka
It was a long journey to Sunnyvale from Colombo! I traveled from Colombo (CMB) to Dubai (DXB), and to Los Angeles (LAX), followed by a local flight to San Jose (SJC). A cab from San Jose to Wild Palms is relatively cheaper (~38$), than from San Francisco (SFO). SJC is known as the airport of the Silicon Valley. I stayed one more night (Sunday night), since my flight was on Monday noon 12 pm. This was my first trip to the new world (Americas). It was a great experience seeing darkness at 3 pm in the sky of the north pole.
Mentor Summit
The summit went really well, starting with a warm welcome from Carol Smith, at "Tunis". I got the chance to meet many folks from many organizations, and listen to their interesting and crazy experiences. Everyone had at least a single interesting experience to share, during the tea, breakfast, or lunch. 2011 was the first year for many organizations (~50) in Google Summer of Code, and (the mentors from those organizations whom I had a chat) were impressed to hear the successful involvement of AbiWord in Google Summer of Code. I met Fridrich representing LibreOffice at the summit. It was really great to meet someone whom I have talked to, over the AbiWord IRC.
Haiku
Meeting the Haiku community was remarkable. Haiku is an MIT licensed open source operating system inspired by BeOS. We thought of a possibility to propose a project co-mentored by AbiWord and Haiku for Google Summer of Code 2012 - "Haiku port for AbiWord". There was also a discussion on this during GSoC 2009 too, which we couldn't make it at that time. Scott from Haiku also pointed out that AbiWord used to run perfectly on Haiku during the early days (well before I joined AbiWord at 2009). We have to go back to the history of AbiWord source code and get it back to build and run, which ceased to build. As we are more into gtk, we have never looked much into this yet, I feel. The relevant discussion can be found at abiword-dev mailing list. Refer to the Haiku FAQ to learn what Haiku is and what it is not.
Catroid
All the 4 mentors from the project Catroid were present at the summit. They were doing interesting demos with their Catroid project running on Android, over the corridors during the breaks. It was their first year at Google Summer of Code and Catroid is really excited as a young organization to participate in Google Summer of Code. By default, Google invites two mentors from each project, along with a waiting list to allow more interested mentors in first-come-first-served. Catroid was really lucky to have everyone around! :)
Marketing and Open Source
An interesting session on "Marketing and Spreading the word about the project/community", followed the session "Community Matters", in the same room (Algiers). How localizers help to widen the user community was discussed. The mentor from PostgreSQL mentioned that they have allowed independent local user/dev communities to own the site in their languages (French, Japanese, ..) Social media engagement (twitter, facebook, dzone) to spread the word of the community and project releases were discussed.
Marketing and Open Source
An interesting session on "Marketing and Spreading the word about the project/community", followed the session "Community Matters", in the same room (Algiers). How localizers help to widen the user community was discussed. The mentor from PostgreSQL mentioned that they have allowed independent local user/dev communities to own the site in their languages (French, Japanese, ..) Social media engagement (twitter, facebook, dzone) to spread the word of the community and project releases were discussed.
Student Salaries
The other two sessions I attended on the first day were on "Humanitarian FOSS", with the participation from OpenMRS, Sahana, and Ushahidi, and "Student Salaries". "Student Salaries" discussed about managing the GSoC's payment. It had a few controversial suggestions followed by a healthy discussion, whether each student should be paid equally, or based on their geographical location, or by the outcomes - a final outcome of the discussion was to propose a reward for the outstanding students - may be a GSoC Student Summit.
Around Google
We took a group photo with all the mentors around, at the end of the first day. We also move around the Google Campus and also visited the Google Store. A room full of chocolates from Goolge, as well as from the mentors allover the globe was awaiting us throughout the summit! ;). The welcome desk was full of Google TShirts and give aways from Google and from the mentoring organizations - specifically stickers from the organizations. I took a few photos around the Google Campus. Feel free to view them in my Facebook album.
The Second Day
I attended the sessions at Tunis, the second day. "Non-profit infrastructure for software freedom" with the views from Software Freedom Conservancy, Free Software Foundation, and Apache Software Foundation, gave some insights in the non-profit infrastructures. "Fund raising 101" by Cat from Google provided some basic hints on successfully getting the open source project funded.
Wrapping Up!
A final speech from Carol ended the summit in a vote of thanks manner. Wait - No! Mentors were asked to provide their suggestions of improvement after her talk. Some encouraging, interesting and also funny comments were thrown, with room full of laughter and applauses. One interesting and usual suggestion was to have the summit at Europe next year. "I love you guys, but, sometimes, I hate you guys," replied Carol.
Wrapping Up!
A final speech from Carol ended the summit in a vote of thanks manner. Wait - No! Mentors were asked to provide their suggestions of improvement after her talk. Some encouraging, interesting and also funny comments were thrown, with room full of laughter and applauses. One interesting and usual suggestion was to have the summit at Europe next year. "I love you guys, but, sometimes, I hate you guys," replied Carol.
The Google Summer of Code Mentor Summit was surely a remarkable experience for everyone who attended. I would like to thank Google and Carol for organizing the Google Summer of Code as well as the summit, on behalf of the AbiWord team.
Subscribe to:
Posts (Atom)
