postgresql – How to stop or delete repmgr service?

I installed repmgr10 on PostgreSQL server before. But now will reinstall them.

Deleted postgresql’s data folder: /var/lib/pgsql/10/data/.

Stoped postgresql-10 service: sudo systemctl stop postgresql-10.

Also did sudo systemctl stop repmgr10.

But check repmgr’s status, got

$ sudo systemctl status repmgr10
● repmgr10.service - A replication manager, and failover management tool for PostgreSQL
   Loaded: loaded (/usr/lib/systemd/system/repmgr10.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2020-07-08 10:37:43 JST; 3h 7min ago
  Process: 250464 ExecStop=/usr/bin/kill -TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 251422 ExecStart=/usr/pgsql-10/bin/repmgrd -f ${REPMGRDCONF} -p ${PIDFILE} -d --verbose (code=exited, status=1/FAILURE)
 Main PID: 152648 (code=exited, status=0/SUCCESS)

Jul 08 10:37:43 server_db systemd(1): Starting A replication manager, and failover management tool for PostgreSQL...
Jul 08 10:37:43 server_db repmgrd(251422): (2020-07-08 10:37:43) (NOTICE) using provided configuration file "/etc/repmgr/10/repmgr.conf"
Jul 08 10:37:43 server_db repmgrd(251422): (2020-07-08 10:37:43) (NOTICE) redirecting logging output to "/var/log/repmgr/repmgr.log"
Jul 08 10:37:43 server_db systemd(1): repmgr10.service: control process exited, code=exited status=1
Jul 08 10:37:43 server_db systemd(1): Failed to start A replication manager, and failover management tool for PostgreSQL.
Jul 08 10:37:43 server_db systemd(1): Unit repmgr10.service entered failed state.
Jul 08 10:37:43 server_db systemd(1): repmgr10.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

I checked log in the /var/log/repmgr/repmgr.log

(2020-07-08 10:24:18) (NOTICE) repmgrd (repmgrd 5.0.0) starting up
(2020-07-08 10:24:18) (ERROR) repmgr extension not found on this node
(2020-07-08 10:24:18) (DETAIL) repmgr extension is available but not installed in database "repmgr"
(2020-07-08 10:24:18) (HINT) check that this node is part of a repmgr cluster
(2020-07-08 10:37:43) (NOTICE) repmgrd (repmgrd 5.0.0) starting up
(2020-07-08 10:37:43) (ERROR) repmgr extension not found on this node
(2020-07-08 10:37:43) (DETAIL) repmgr extension is available but not installed in database "repmgr"
(2020-07-08 10:37:43) (HINT) check that this node is part of a repmgr cluste

It shown repmgr extension is available but not installed in database "repmgr".

But now repmgr service can’t been restarted so how to install repmgr extension in database?

So I want to know how to stop repmgr daemon or remove this package then install again? That maybe can solve the problem.

delete – after deleting 100 millions of records in postgresql free space doesn’t change as i expected

recently i configured netflow for monitoring traffic of my company.i use pmacct for collect netflow packets and postgresql for svaing them.i only keep netflow records for a week and after that every day i delete all records that older than 7 days.

this script runs every day with cronjob:

date >> /root/log/cronlog

du -h /var/lib/postgresql/data/base/ >> /root/log/cronlog

psql -U pmacct -d pmacct_switch -c "DELETE FROM acct_v9 WHERE stamp_updated < NOW() - INTERVAL '7 days';" >> /root/log/cronlogpsql -U pmacct -d pmacct_switch -c "VACUUM;" >> /root/log/cronlog

du -h /var/lib/postgresql/data/base/ >> /root/log/cronlog

date >> /root/log/cronlog

and this is the cronlog file:

Wed Jul 8 01:00:02 +0430 20207.4M

/var/lib/postgresql/data/base/17.5M

/var/lib/postgresql/data/base/1299480G

/var/lib/postgresql/data/base/167654.0K

/var/lib/postgresql/data/base/pgsql_tmp7.4M

/var/lib/postgresql/data/base/129936.5M

/var/lib/postgresql/data/base/1638480G

/var/lib/postgresql/data/base/DELETE 100424891VACUUM7.4M

/var/lib/postgresql/data/base/17.5M

/var/lib/postgresql/data/base/1299481G

/var/lib/postgresql/data/base/167654.0K

/var/lib/postgresql/data/base/pgsql_tmp7.4M

/var/lib/postgresql/data/base/129936.5M

/var/lib/postgresql/data/base/1638481G /var/lib/postgresql/data/base/Wed Jul 8 02:29:33 +0430 2020

as you see after deleting 100 millions of records free space dosen’t increase!

so, what’s the soloution?

magento2 – How to delete specific product images from Magento 2 database and physical images from folder?

Deleting selected product / SKU images from Magento 2 database and the physical images files from the media product catalog folders which are dynamically created by Magento during image upload.

  1. Locate the image and image physical path. In the database, the images and the physical path reference of the images are stores in the below 3 tables
  • catalog_product_entity_media_gallery
    //This is where the physical
    image path is stored
  • catalog_product_entity_media_gallery_value
    //This table has the storeid, valueid, product entity id and the
    position of the images
  • catalog_product_entity_media_gallery_value_to_entity //This table is
    where the mapping between the product entity id and valueid mapping
    done.
  • And the images are stored physically under magento2rootpath/pub/media/catalog/product/x/x/x
  1. First step is to identify the physical path of the server and delete from the media –> catalog –> product path, I used the below query to create a file with remove command and the image physical path on the server.

This example was executed on Ubuntu 16.04, the below commands and sql querie. Will run on any Linux distro and Mysql.

Basically create a file with the below command to delete the images,

run the below query on the command prompt.

 - mysql -u username -p databasename -e "select concat('rm -f
   /home/magento2rootpath/pub/media/catalog/product',value) from
   catalog_product_entity_media_gallery  where value_id in (select
   value_id from catalog_product_entity_media_gallery_value_to_entity
   where entity_id in (select entity_id from catalog_product_entity
   where sku in ('SKU1','SKU2','SKU3'))) and attribute_id=90;" >
   imagefilestodelete.sh

In my case, Magento is installed in folder /home/magento2rootpath – replace with your actual magento root path and replace SKU1, SKU2, SKU3 with your actual product SKU

Output of the generated file imagefilestodelete.sh

rm -f /home/magento2rootpath/pub/media/catalog/product/4/m/4m6a6330.jpg
rm -f /home/magento2rootpath/pub/media/catalog/product/4/m/4m6a6332.jpg
rm -f /home/magento2rootpath/pub/media/catalog/product/4/m/4m6a6333.jpg
rm -f /home/magento2rootpath/pub/media/catalog/product/4/m/4m6a6335.jpg

From the CLI run the below command

sh imagefilestodelete.sh

Now that we have deleted the physical image files from the media catalog respective image path folder, we will now need to remove the same from database, I used the below sql queries in the same order to remove the file references from database.

  1. Remove the image references from the respective tables in Magento

Login to your mysql with user having privilege to execute delete
queries

 - delete from catalog_product_entity_media_gallery where value_id in
   (select value_id from catalog_product_entity_media_gallery_value_to_entity where entity_id
   in (select entity_id from catalog_product_entity where sku in
   ('SKU1','SKU2','SKU3'))) and attribute_id=90;

 - delete from catalog_product_entity_media_gallery_value_to_entity
   where entity_id in (select entity_id from catalog_product_entity
   where sku in ('SKU1','SKU2','SKU3'));

 - delete from catalog_product_entity_media_gallery_value where
   entity_id in (select entity_id from catalog_product_entity where sku
   in ('SKU1','SKU2','SKU3'));

NOTE: Before you execute the above delete queries, run SELECT to check the entries. To do that replace delete from above queries to SELECT *

This way it was easier for me to delete images for specific products on production and not truncate the entire tables.

java – How to delete certain cards that has been used from player hand?

I am programming the game in Java. I am using Java ArrayList to store the cards. But do a ignore case string check on the cards, the problem is it is deleting the cards with the name “Trooper”, but it always leave one trooper card in the player hand. I wanted it to leave all trooper cards.

Card Display in Java Console:
Trooper
Agent
Agent
Agent
Trooper
Trooper

Jave Code:

if(mouseCursor.getRectangle().intersects(placeList.get(i).getRectangle())
                        && mouseCursor.isPressed() )
                        {

                            if(attackPower >= placeList.get(i).getAttackPower())
                            {
                                for(int j = 0 ; j < playerDisplayDeck.size();j++)
                                {
                                    System.out.println(playerDisplayDeck.get(j).getName());
                                }
                                
                                for(int j = 0 ; j < playerDisplayDeck.size();j++)
                                {

                                    if(playerDisplayDeck.get(j).getName().equalsIgnoreCase("trooper"))
                                    {
                                        playerDisplayDeck.remove(j);
                                    }
                                }
                                
                                for(int j = 0 ; j < playerDisplayDeck.size();j++)
                                {
                                    System.out.println(playerDisplayDeck.size());
                                }
                                
                                attackPower = attackPower - placeList.get(i).getAttackPower();
}
                            

How do I delete content from a PDF file?

I’ve tried the first 5 or so results on Google for PDF editors, and none of them allow me to delete existing PDF content, they only allow me to add new content on top of the existing content.

I’ve also tried opening the PDF in LibreOffice Draw, but the text does not look correct and overflows.

How do I delete content from a PDF file?

Delete SharePoint item ASP.NET MVC

I’m having a problem with the delete function using ASP.NET mvc I can’t seem to get how the delete works here. Should I create another method in the custom class for the delete? How does that work?

Here’s my custom class that shows the item details

Custom.cs

public static Formular GetFormular(int itemId, ClientContext ctx, string listName)
        {
            var web = ctx.Web;
            var list = web.Lists.GetByTitle(listName);
            var formular = list.GetItemById(itemId);
            ctx.Load(formular,
                item => item("Title"),
                item => item("TemplateVersion"),
                item => item("TemplateNumber")
            ctx.Load(formular.AttachmentFiles);
            ctx.ExecuteQuery();

            var model = new Formular
            {
                TemplateName = formular("Title") as string != null ? formular("Title") as string : string.Empty,
                TemplateVersion = formular("TemplateVersion") as string,
                TemplateNumber = formular("TemplateNumber") as string
            };

            return model;
        }

i then call this to my controller
Controller

(SharePointContextFilter)
        public ActionResult Index(int? id)
        {

            User spUser = null;
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            int currentItem = id.Value;

            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                if (clientContext != null)
                {
                    var queryString = HttpUtility.ParseQueryString(HttpContext.Request.Url.Query);
                    queryString.Remove("id");
                    ViewBag.CopyFormular = "./new/?id=" + currentItem + "&" + queryString;

                    var model = custom.GetFormular(currentItem, clientContext, "listName");
                    return View(model);

                }
            }

            return View();
        }
(SharePointContextFilter)
        public ActionResult Delete(int? id)
        {
            User spUser = null;
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            int currentItem = id.Value;
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                if (clientContext != null)
                {
                    var queryString = HttpUtility.ParseQueryString(HttpContext.Request.Url.Query);
                    queryString.Remove("id");
                    ViewBag.CopyFormular = "./new/?id=" + currentItem + "&" + queryString;

                    var model = Customizations.GetFormular(currentItem, clientContext, "listName");
                    model.Delete();

                }
            }

            return View();

8 – composer require error: can’t delete default.services.yml

Make your “local” machine work as intended

This approach will fix the issue on your local machine. The default .gitignore will limit the change to your local (it will persist on your local without affecting anyone else; don’t make this change to settings.php to avoid affecting other instances, including PROD).

Steps

  1. enable settings.local.php (here are the instructions from the docblock in settings.local.php):
 * To activate this feature, copy and rename it such that its path plus
 * filename is 'sites/default/settings.local.php'. Then, go to the bottom of
 * 'sites/default/settings.php' and uncomment the commented lines that mention
 * 'settings.local.php'.
 *
 * If you are using a site name in the path (... read about exceptions in file)
  1. set file permissions to allow user to write to the file:

    $ chmod u+w {name_of_docroot}/sites/default

  2. find and change $settings('skip_permissions_hardening'); make it = TRUE;

Step #3 tells Drupal not to reset permissions on the default folder only on your local, and allows you to work more smoothly with composer on your local without loosening permissions on any other copy of the codebase.