Erreur connue : difficulté à redémarrer les services postgres
Erreur connue : erreur sur la sequence "Uncaught PDOException"
su postgres
psql \c nomdelabase ||||||| \connect (or \c) [ nom_base [ nom_utilisateur ] [ hôte ] [ port ] ]
ou
$ su
Password:
# su postgres
postgres@nomserveur:/home/admin$ psql votrebase
psql (9.4.18)
Type "help" for help.
$ postgres -V
ou
§ locate bin/postgres
ou
Aller dans le repertoire :
§ /usr/lib/postgresql# ls -ltr
total 4
drwxr-xr-x 4 root root 4096 Jul 20 2016 9.4
\l
\x
psql -p port
se connecter en postgres
pg_dump base_de_donnees > fichier_de_sortie
pg_dump base_name > /tmp/export_base_Date.sql
pg_dump maarchcourrier > /tmp/export_base_2020_11_12.sql
psql -U user database < name_file.sql
\q
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'nom_de_la_base';
# select * from res_letterbox order by res_id desc;
# select * from listinstance where item_id = 'le_id_de_l'utilisateur;
ou
$ select * from res_letterbox where dest_user = ''le_id_de_l'utilisateur';
=# select alt_identifier from mlb_coll_ext where res_id in (select DISTINCT CAST(document->>'id' as int)
from emails where status = 'ERROR' and document->>'id' is not null);
select fulltext_result FROM res_letterbox where fulltex_result is not null
$ select * from users where firstname ilike '%lanie%';
$ select * from notif_email_stack;
Afficher uniquement les informations utiles et en ordre descendant
select email_stack_sid, recipient, subject, exec_date, exec_result from notif_email_stack order by exec_date desc;
maarch=# select * from notif_email_stack order by email_stack_sid desc limit 5;
Récupérer l’user attributaire par défaut des entités. entity_id
est en texte (ex : PJS), user_id
est un nombre (ex : 42). Fonctionne sur Courrier 20.03, 20.10, 21.03.
select
e.entity_id,
lti.item_id user_id
from
list_templates lt,
list_templates_items lti,
entities e
where
lt.entity_id = e.id
and lti.list_template_id = lt.id
and lti.item_mode='dest'
and lti.item_type='user'
and sequence = 0
order by e.entity_id;
Supprimer les tags (étiquettes) dont la date de création est nulle ET qui ne sont pas utilisés par les courriers :
delete
from tags
where id in (select t1.id from (
select label, max(id) as id, count(*) as nbr_doublon
from tags
where creation_date is null
and id not in (select distinct tag_id from resources_tags)
group by label
having count(*) > 1
) as t1 );
Lors de la connection sur l'application vous avez ce message d'erreur :
Database connection failedDatabase connection failedDatabase connection failedDatabase connection failedDatabase connection
failedDatabase connection failedDatabase connection failedDatabase connection failedDatabase connection failedDatabase connection
$ ps -ef |grep postgres
postgres 710 1 0 juil.29 ? 00:00:52 /usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf
postgres 727 710 0 juil.29 ? 00:00:00 postgres: checkpointer process
postgres 728 710 0 juil.29 ? 00:00:13 postgres: writer process
postgres 729 710 0 juil.29 ? 00:00:12 postgres: wal writer process
postgres 730 710 0 juil.29 ? 00:00:46 postgres: autovacuum launcher process
postgres 731 710 0 juil.29 ? 00:00:44 postgres: stats collector process
root 8669 8398 0 14:58 pts/0 00:00:00 su postgres
postgres 8671 8669 0 14:58 pts/0 00:00:00 bash
postgres 8857 8671 0 15:04 pts/0 00:00:00 ps -ef
postgres 8858 8671 0 15:04 pts/0 00:00:00 [grep]
$ /etc/init.d/postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled)
Active: active (exited) since lun. 2019-07-29 12:51:09 CEST; 2 weeks 2 days ago
Process: 787 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 787 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/postgresql.service
ou
$ service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled)
Active: active (exited) since mer. 2019-08-14 15:08:46 CEST; 7min ago
Process: 9072 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 9072 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/postgresql.service
août 14 15:08:46 MaarchCourrier systemd[1]: Starting PostgreSQL RDBMS...
août 14 15:08:46 MaarchCourrier systemd[1]: Started PostgreSQL RDBMS.
août 14 15:16:21 MaarchCourrier systemd[1]: Started PostgreSQL RDBMS.
root@MaarchCourrier:/var/www/MaarchCourrier/custom/cs_MaarchCourrier/apps/maarch_entreprise/xml# cat config.xml
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<CONFIG>
<databaseserver>localhost</databaseserver>
<databaseserverport>5433</databaseserverport>
<databasetype>POSTGRESQL</databasetype>
<databasename>maarchcourrier</databasename>
<databaseuser>maarch</databaseuser>
<databasepassword>maarch</databasepassword>
<databasesearchlimit>500</databasesearchlimit>
<nblinetoshow>10</nblinetoshow>
<limitcharsearch>2</limitcharsearch>
<lang>fr</lang>
<adminmail>dev@maarch.org</adminmail>
<adminname>maarch</adminname>
<debug>false</debug>
<applicationname>MAARCH 19.04 </applicationname>
<defaultPage>welcome</defaultPage>
<exportdirectory/>
<CookieTime>60</CookieTime> <!-- minutes -->
<ldap>true</ldap> <!-- if true, ldap authentification, see ldap xml config file -->
<userdefaultpassword>maarch</userdefaultpassword> <!-- default user's password -->
<usePDO>false</usePDO>
<usePHPIDS>false</usePHPIDS>
</CONFIG>
su postgres
service postgresql restart
service postgresql status
nano /etc/postgresql/9.6/main/postgresql.conf
netstat -l |grep postgres
pg_ctlcluster 9.6 main restart
systemctl status postgresql@9.6-main.service
service postgresql status
systemctl start postgresql@9.6-main.service
netstat -a
systemctl start postgresql@9.6-main.service
pg_ctlcluster 9.6 main restart
systemctl daemon-reload
pg_ctlcluster 9.6 main restart
pg_ctlcluster --status
pg_ctlcluster 9.6 status
cd /var/lib/postgresql/9.6
postgres pg_ctlcluster 9.6 main start
pg_ctlcluster 9.6 main start
journalctl -xn
htop
top
kill -9 25116
top
pg_ctlcluster 9.6 main start
Fatal error: Uncaught PDOException: SQLSTATE[23505]: Unique violation: 7 ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « contacts_v2_pkey » DETAIL: La clé « (contact_id)=(214) » existe déjà. in /var/www/html/MaarchCourrierProduction/core/class/class_db_pdo.php:387 Stack trace: #0 /var/www/html/MaarchCourrierProduction/core/class/class_db_pdo.php(387): PDOStatement->execute(Array) #1 /var/www/html/MaarchCourrierProduction/apps/maarch_entreprise/class/class_contacts_v2_Abstract.php(296): Database->query('INSERT INTO con...', Array) #2 /var/www/html/MaarchCourrierProduction/apps/maarch_entreprise/my_contacts/my_contact_up_db.php(39): contacts_v2_Abstract->addupcontact('add', false, 'Y', 'iframe') #3 /var/www/html/MaarchCourrierProduction/core/class/class_core_tools.php(1652): require('/var/www/html/M...') #4 /var/www/html/MaarchCourrierProduction/apps/maarch_entreprise/index.php(212): core_tools->insert_page() #5 {main} thrown in /var/www/html/MaarchCourrierProduction/core/class/class_db_pdo.php on line 387
=# select * from contact_v2_id_seq;
-[ RECORD 1 ]-+--------------------
sequence_name | contact_v2_id_seq
last_value | 216
start_value | 200
increment_by | 1
max_value | 9223372036854775807
min_value | 14
cache_value | 1
log_cnt | 32
is_cycled | f
is_called | t
=# alter sequence contact_v2_id_seq restart with 2028;
ALTER SEQUENCE
=# select * from contacts_v2 order by contact_id desc;
=# select * from contact_v2_id_seq;
-[ RECORD 1 ]-+--------------------
sequence_name | contact_v2_id_seq
last_value | 2028
start_value | 200
increment_by | 1
max_value | 9223372036854775807
min_value | 14
cache_value | 1
log_cnt | 0
is_cycled | f
is_called | f
SELECT nextval('seq_nuu_filtreelement')
service apache2 restart
service apache2 status