Sunday, March 10, 2019

How to reset check_mk admin password

My Windows 10 Laptop just crashed after latest Intel patch upgrade.

Forgot to save the admin password on one of the latest check_mk site I built.
su - mysite

cd etc

ls -l htpasswd

OMD[mysite]:~/etc$ ls -l htpasswd
Example: check_mk version 1.4:
lambert:!$1$042926$lmAEb.P5TAi0sZfiGyWHX.
omdadmin:M29dfyFjgy5iA
check_mk version 1.5:
automation:$1$857531$PzhNz/zMdQv8xGu68EZhD.
cmkadmin:$1$386620$Xe5mZKwrPRlzx0BvZCJM8.
htpasswd htpasswd omdadmin          # set password for user *omdadmin*

New password: 

Re-type new password:
You should be good! Have a nice day!

Monday, February 25, 2019

recommend Script to remove Windows 10 bloatware

Recommend a great Script to remove Windows 10 bloatware.

You can find it here:

https://github.com/Sycnex/Windows10Debloater

Just download the zip and run in PowerShell by right click: Windows10Debloater.ps1
If you like GUI: Windows10DebloaterGUI.ps1

PS:
  1. Appreciate Richard Newton's great work.
  2. I did not run white list, because I do not want anything except the 'Core Windows 10'.
  3. If you really really need keep some Windows 10 bloatware, please run Windows10SysPrepDebloater.ps1 before you start the main .PowerShell script.
  4. The only one I may keep is the Mail which crashed every time I check the Gmail folders.
  5. I sill using Windows 10 as my Main working OS and Outlook as my Main Email client. But not a fan of any bloatware.

Tuesday, December 11, 2018

git pull: Unable to create ORIG_HEAD.lock No space left on device

# git pull
fatal: Unable to create '/mds/mds/.git/ORIG_HEAD.lock': No space left on device

# df -h .
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/b1358fbb-dab1-482d-ab22-fa2523975c2e   16G   11G  3.9G  74% /

# df -i .
Filesystem                                              Inodes   IUsed  IFree IUse% Mounted on
/dev/disk/by-uuid/b1358fbb-dab1-482d-ab22-fa2523975c2e 1003680 1003680      0  100% /
It just to many small log files in the folder. To quick delete them:
cd yourdirectory
perl -e 'for(<*>){((stat)[9]<(unlink))}'
Reference & Thanks: https://stackoverflow.com/questions/24895502/git-pull-unable-to-create-orig-head-lock-no-space-left-on-device/25002467 https://unix.stackexchange.com/questions/37329/efficiently-delete-large-directory-containing-thousands-of-files

Friday, October 12, 2018

Install abiword on Amazon Linux 2

In Amazon Linux 2, there is no full version of Abiword. But abiword library and convert tools are available, if you can live with it.
libabw.x86_64 : A library for import of AbiWord files
libabw-tools.x86_64 : Tools to transform AbiWord files into other formats
However my client running a python/django website using webodt package to convert word documents to html and txt.
The [libabw-tools] package has 2 tools for this kind of work.
/usr/bin/abw2html
/usr/bin/abw2text

But I won't rewrite the code. I install abiword 3.0.2 for EL7 from http://repo.iotti.biz/CentOS/.
rpm -Uvh http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
Have to update the repo files before update. /etc/yum.repos.d/lux.repo
[lux]
name=CentOS $releasever - $basearch - Lux
baseurl=http://repo.iotti.biz/CentOS/$releasever
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
Because the $releasever = 2 in Amazon Linux 2, just change it To 7 in the file.
[lux]
name=CentOS $releasever - $basearch - Lux
baseurl=http://repo.iotti.biz/CentOS/7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
Same /etc/yum.repos.d/frank.repo
[frank]
name=CentOS $releasever - $basearch - Frank
baseurl=http://repo.iotti.biz/Frank/$releasever
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
# Frank should be manually enabled
enabled=0
# Frank packages should be explicitly included with includepkgs
exclude=*
To:
[frank]
name=CentOS $releasever - $basearch - Frank
baseurl=http://repo.iotti.biz/Frank/7
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
# Frank should be manually enabled
enabled=0
# Frank packages should be explicitly included with includepkgs
exclude=*
Then you can update and install via yum:
yum update
yum install abiword
Dependencies Resolved

=======================================================================================================================================================================
 Package                                         Arch                         Version                                           Repository                        Size
=======================================================================================================================================================================
Installing:
 abiword                                         x86_64                       1:3.0.2-3.el7.lux                                 lux                              1.3 M
Installing for dependencies:
 adwaita-cursor-theme                            noarch                       3.26.0-1.amzn2                                    amzn2-core                       641 k
 adwaita-icon-theme                              noarch                       3.26.0-1.amzn2                                    amzn2-core                        12 M
 aiksaurus                                       x86_64                       1:1.2.1-34.el7.lux                                lux                              324 k
 at-spi2-atk                                     x86_64                       2.22.0-2.amzn2.0.2                                amzn2-core                        81 k
 at-spi2-core                                    x86_64                       2.22.0-1.amzn2.0.2                                amzn2-core                       159 k
 atk                                             x86_64                       2.22.0-3.amzn2.0.2                                amzn2-core                       258 k
 avahi-libs                                      x86_64                       0.6.31-19.amzn2                                   amzn2-core                        62 k
 cairo                                           x86_64                       1.14.8-2.amzn2.0.2                                amzn2-core                       718 k
 cairo-gobject                                   x86_64                       1.14.8-2.amzn2.0.2                                amzn2-core                        25 k
 colord-libs                                     x86_64                       1.3.4-1.amzn2.0.2                                 amzn2-core                       186 k
 cups-libs                                       x86_64                       1:1.6.3-35.amzn2                                  amzn2-core                       360 k
 dbus-glib                                       x86_64                       0.100-7.2.amzn2                                   amzn2-core                       103 k
 dconf                                           x86_64                       0.26.0-2.amzn2.0.2                                amzn2-core                       106 k
 desktop-file-utils                              x86_64                       0.23-1.amzn2.0.2                                  amzn2-core                        68 k
 enchant                                         x86_64                       1:1.6.0-8.amzn2.0.2                               amzn2-core                        55 k
 fontconfig                                      x86_64                       2.10.95-11.amzn2.0.2                              amzn2-core                       231 k
 fontpackages-filesystem                         noarch                       1.44-8.amzn2                                      amzn2-core                        10 k
 fribidi                                         x86_64                       0.19.4-6.amzn2.0.2                                amzn2-core                        63 k
 gdk-pixbuf2                                     x86_64                       2.36.5-1.amzn2.0.2                                amzn2-core                       567 k
 glib-networking                                 x86_64                       2.50.0-1.amzn2.0.2                                amzn2-core                       132 k
 gnutls                                          x86_64                       3.3.26-9.amzn2.0.2                                amzn2-core                       670 k
 graphite2                                       x86_64                       1.3.10-1.amzn2.0.2                                amzn2-core                       115 k
 gsettings-desktop-schemas                       x86_64                       3.24.1-2.amzn2                                    amzn2-core                       586 k
 gtk-update-icon-cache                           x86_64                       3.22.26-4.amzn2                                   amzn2-core                        27 k
 gtk2                                            x86_64                       2.24.31-1.amzn2.0.2                               amzn2-core                       3.4 M
 gtk3                                            x86_64                       3.22.26-4.amzn2                                   amzn2-core                       4.4 M
 gtkmathview                                     x86_64                       0.8.0-16.el7.lux                                  lux                              628 k
 harfbuzz                                        x86_64                       1.3.2-1.amzn2.0.2                                 amzn2-core                       181 k
 hicolor-icon-theme                              noarch                       0.12-7.amzn2                                      amzn2-core                        43 k
 jasper-libs                                     x86_64                       1.900.1-31.amzn2.0.2                              amzn2-core                       149 k
 json-glib                                       x86_64                       1.2.6-1.amzn2.0.2                                 amzn2-core                       134 k
 lcms2                                           x86_64                       2.6-3.amzn2.0.2                                   amzn2-core                       152 k
 libX11                                          x86_64                       1.6.5-1.amzn2.0.2                                 amzn2-core                       614 k
 libX11-common                                   noarch                       1.6.5-1.amzn2.0.2                                 amzn2-core                       164 k
 libXau                                          x86_64                       1.0.8-2.1.amzn2.0.2                               amzn2-core                        29 k
 libXcomposite                                   x86_64                       0.4.4-4.1.amzn2.0.2                               amzn2-core                        22 k
 libXcursor                                      x86_64                       1.1.14-8.amzn2.0.2                                amzn2-core                        30 k
 libXdamage                                      x86_64                       1.1.4-4.1.amzn2.0.2                               amzn2-core                        20 k
 libXext                                         x86_64                       1.3.3-3.amzn2.0.2                                 amzn2-core                        39 k
 libXfixes                                       x86_64                       5.0.3-1.amzn2.0.2                                 amzn2-core                        18 k
 libXfont                                        x86_64                       1.5.2-1.amzn2.0.2                                 amzn2-core                       152 k
 libXft                                          x86_64                       2.3.2-2.amzn2.0.2                                 amzn2-core                        60 k
 libXi                                           x86_64                       1.7.9-1.amzn2.0.2                                 amzn2-core                        41 k
 libXinerama                                     x86_64                       1.1.3-2.1.amzn2.0.2                               amzn2-core                        14 k
 libXrandr                                       x86_64                       1.5.1-2.amzn2.0.2                                 amzn2-core                        27 k
 libXrender                                      x86_64                       0.9.10-1.amzn2.0.2                                amzn2-core                        26 k
 libXtst                                         x86_64                       1.2.3-1.amzn2.0.2                                 amzn2-core                        20 k
 libXxf86vm                                      x86_64                       1.1.4-1.amzn2.0.2                                 amzn2-core                        17 k
 libabiword                                      x86_64                       1:3.0.2-3.el7.lux                                 lux                              5.2 M
 libasyncns                                      x86_64                       0.8-7.amzn2.0.2                                   amzn2-core                        26 k
 libepoxy                                        x86_64                       1.3.1-2.amzn2                                     amzn2-core                       198 k
 libfontenc                                      x86_64                       1.1.3-3.amzn2.0.2                                 amzn2-core                        31 k
 libglvnd                                        x86_64                       1:1.0.0-1.amzn2.0.2                               amzn2-core                        89 k
 libglvnd-egl                                    x86_64                       1:1.0.0-1.amzn2.0.2                               amzn2-core                        43 k
 libglvnd-glx                                    x86_64                       1:1.0.0-1.amzn2.0.2                               amzn2-core                       124 k
 libgsf                                          x86_64                       1.14.26-7.amzn2.0.2                               amzn2-core                       165 k
 libgusb                                         x86_64                       0.2.9-1.amzn2.0.2                                 amzn2-core                        40 k
 libical                                         x86_64                       1.0.1-1.amzn2.0.2                                 amzn2-core                       175 k
 libmodman                                       x86_64                       2.0.1-8.amzn2.0.2                                 amzn2-core                        29 k
 libpng                                          x86_64                       2:1.5.13-7.amzn2.0.2                              amzn2-core                       214 k
 libproxy                                        x86_64                       0.4.11-10.amzn2.0.3                               amzn2-core                        61 k
 librsvg2                                        x86_64                       2.40.16-1.amzn2.0.2                               amzn2-core                       129 k
 libsoup                                         x86_64                       2.56.0-6.amzn2                                    amzn2-core                       401 k
 libthai                                         x86_64                       0.1.14-9.amzn2.0.2                                amzn2-core                       187 k
 libusbx                                         x86_64                       1.0.21-1.amzn2                                    amzn2-core                        62 k
 libwayland-client                               x86_64                       1.14.0-2.amzn2.0.1                                amzn2-core                        32 k
 libwayland-cursor                               x86_64                       1.14.0-2.amzn2.0.1                                amzn2-core                        20 k
 libwayland-server                               x86_64                       1.14.0-2.amzn2.0.1                                amzn2-core                        38 k
 libwmf                                          x86_64                       0.2.8.4-41.amzn2.0.2                              amzn2-core                       136 k
 libwmf-lite                                     x86_64                       0.2.8.4-41.amzn2.0.2                              amzn2-core                        68 k
 libxcb                                          x86_64                       1.12-1.amzn2.0.2                                  amzn2-core                       216 k
 libxkbcommon                                    x86_64                       0.7.1-1.amzn2.0.2                                 amzn2-core                       109 k
 libxshmfence                                    x86_64                       1.2-1.amzn2.0.2                                   amzn2-core                       7.2 k
 link-grammar                                    x86_64                       5.3.14-1.el7.lux                                  lux                              2.1 M
 loudmouth                                       x86_64                       1.5.3-1.el7.lux                                   lux                               71 k
 lyx-fonts                                       noarch                       2.2.3-1.el7                                       epel                             159 k
 mesa-libEGL                                     x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                       100 k
 mesa-libGL                                      x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                       159 k
 mesa-libgbm                                     x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                        37 k
 mesa-libglapi                                   x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                        43 k
 mesa-libwayland-egl                             x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                        18 k
 minisat2-libs                                   x86_64                       2.2.1-1.el7.lux                                   lux                               43 k
 nettle                                          x86_64                       2.7.1-8.amzn2.0.2                                 amzn2-core                       329 k
 ots-libs                                        x86_64                       0.5.0-12.el7.lux                                  lux                               46 k
 pango                                           x86_64                       1.40.4-1.amzn2.0.2                                amzn2-core                       276 k
 pangox-compat                                   x86_64                       0.0.2-2.el7                                       epel                              56 k
 pixman                                          x86_64                       0.34.0-1.amzn2.0.2                                amzn2-core                       254 k
 rest                                            x86_64                       0.8.0-2.amzn2                                     amzn2-core                        63 k
 t1lib                                           x86_64                       5.1.2-14.amzn2.0.2                                amzn2-core                       168 k
 telepathy-glib                                  x86_64                       0.24.0-1.amzn2.0.2                                amzn2-core                       725 k
 trousers                                        x86_64                       0.3.14-2.amzn2.0.2                                amzn2-core                       294 k
 urw-fonts                                       noarch                       2.4-16.amzn2                                      amzn2-core                       3.0 M
 wv                                              x86_64                       1.2.9-10.el7.lux                                  lux                              259 k
 xkeyboard-config                                noarch                       2.20-1.amzn2                                      amzn2-core                       799 k
 xorg-x11-font-utils                             x86_64                       1:7.5-20.amzn2.0.2                                amzn2-core                        87 k

Transaction Summary
=======================================================================================================================================================================
Install  1 Package (+95 Dependent packages)

Total download size: 46 M
Installed size: 147 M
Have a nice worm day!

Monday, October 8, 2018

Debian 9.3 Stretch Unattended-upgrades not detecting Linux kernel security update by default

All my Debian 9.3 "Stretch" instance is showing a kernel update as being available: linux-image-amd64/stable 4.9+8 amd64 But Default Unattended-upgrades config fails to install kernel security update. My configure of '/etc/apt/apt.conf.d/50unattended-upgrades'
Unattended-Upgrade::Origins-Pattern {
        "origin=Debian,codename=${distro_codename},label=Debian-Security";
        "origin=nginx,label=nginx";
        "site=packages.sury.org";
};
I have to add one extra line:
        "origin=Debian,codename=${distro_codename},label=Debian";
Then the Kernel upgrade got pickup.
Unattended-Upgrade::Origins-Pattern {
        "origin=Debian,codename=${distro_codename},label=Debian";
        "origin=Debian,codename=${distro_codename},label=Debian-Security";
        "origin=nginx,label=nginx";
        "site=packages.sury.org";
};
Reference of the fix for this bug:
https://unix.stackexchange.com/questions/414991/unattended-upgrades-not-detecting-linux-kernel-security-update-by-default
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=886415

Thanks for Sharing and Happy Thanks Giving!

Wednesday, October 3, 2018

Debian 9 unattended upgrades Nginx and PHP 7 repo apt

I install Nginx mainline version from Nginx's officel Repo. PHP 7.2 FPM from packages.sury.org. In order to let the unattended upgrades do the work for me.
  1. I add /etc/apt/apt.conf.d/50unattended-upgrades
  2. Unattended-Upgrade::Origins-Pattern {
      ...
            "origin=nginx,label=nginx";
            "site=packages.sury.org";
    };
    
  3. Testing it out
  4. # unattended-upgrade --debug --dry-run
    Initial blacklisted packages: 
    Initial whitelisted packages: 
    Starting unattended upgrades script
    Allowed origins are: ['origin=Debian,codename=stretch,label=Debian-Security', 'origin=nginx,label=nginx', 'site=packages.sury.org']
    pkgs that look like they should be upgraded: 
    Fetched 0 B in 0s (0 B/s)                                                                                                                                             
    fetch.run() result: 0
    blacklist: []
    whitelist: []
    No packages found that can be upgraded unattended and no pending auto-removals
    

Friday, September 28, 2018

Install Postgresql 9.6 on Amazon Linux 2 by Amazon Linux Extras

Yes you can install the latest Postgresql via https://www.postgresql.org/download/linux/redhat/.

But it suppose to work on Cent OS 7 or RHEL 7.
Ammazon Linux 2 have more "Fresher" package, including the Kernel.

From Amazon Linux 2, it added Amazon Linux Extras

Extras is a mechanism in Amazon Linux 2 to enable the consumption of new versions of application software on a stable operating system that is supported until June 30, 2023.
Extras include Ansible 2.4.2, memcached 1.5, nginx 1.12, Postgresql 9.6, MariaDB 10.2, Go 1.9, Redis 4.0, R 3.4, Rust 1.22.1.

I think it is better using Extras from Amazon Linux Team. Here is how:
  1. Check the AMI version:
  2. # uname -a
    Linux ip-10-10-10-10.tal-ent.local 4.14.70-72.55.amzn2.x86_64 #1 SMP Wed Sep 19 19:09:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
    # cat /etc/system-release
    Amazon Linux 2
    # cat /etc/image-id
    image_name="amzn2-ami-hvm"
    image_version="2"
    image_arch="x86_64"
    image_file="amzn2-ami-hvm-2.0.20180810-x86_64.xfs.gpt"
    image_stamp="8008-2abd"
    image_date="20180811020321"
    recipe_name="amzn2 ami"
    recipe_id="c652686a-2415-9819-65fb-4dee-9792-289d-1e2846bd"
    
  3. Check available package in Extras:
  4. # amazon-linux-extras
      0  ansible2                 available    [ =2.4.2  =2.4.6 ]
      1  emacs                    available    [ =25.3 ]
      2  httpd_modules            available    [ =1.0 ]
      3  memcached1.5             available    [ =1.5.1 ]
      4  nginx1.12                available    [ =1.12.2 ]
      5  postgresql9.6            available    [ =9.6.6  =9.6.8 ]
      6  postgresql10             available    [ =10 ]
      8  redis4.0                 available    [ =4.0.5  =4.0.10 ]
      9  R3.4                     available    [ =3.4.3 ]
     10  rust1                    available    [ =1.22.1  =1.26.0  =1.26.1  =1.27.2 ]
     11  vim                      available    [ =8.0 ]
     12  golang1.9                available    [ =1.9.2 ]
     13  ruby2.4                  available    [ =2.4.2  =2.4.4 ]
     14  nano                     available    [ =2.9.1 ]
     15  php7.2                   available    [ =7.2.0  =7.2.4  =7.2.5  =7.2.8 ]
     16  lamp-mariadb10.2-php7.2  available    [ =10.2.10_7.2.0  =10.2.10_7.2.4  =10.2.10_7.2.5  =10.2.10_7.2.8 ]
     17  libreoffice              available    [ =5.0.6.2_15  =5.3.6.1 ]
     18  gimp                     available    [ =2.8.22 ]
     19  docker=latest            enabled      [ =17.12.1  =18.03.1  =18.06.1 ]
     20  mate-desktop1.x          available    [ =1.19.0  =1.20.0 ]
     21  GraphicsMagick1.3        available    [ =1.3.29 ]
     22  tomcat8.5                available    [ =8.5.31  =8.5.32 ]
     23  epel                     available    [ =7.11 ]
    
  5. Install postgresql 9.6
  6. # amazon-linux-extras install postgresql9.6
    Installing postgresql
    Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
    amzn2-core                                                                                                                                      | 2.4 kB  00:00:00     
    amzn2extra-docker                                                                                                                               | 1.3 kB  00:00:00     
    amzn2extra-epel                                                                                                                                 | 1.3 kB  00:00:00     
    amzn2extra-postgresql9.6                                                                                                                        | 1.3 kB  00:00:00     
    amzn2extra-postgresql9.6/2/x86_64/primary_db                                                                                                    |  23 kB  00:00:00     
    152 packages excluded due to repository priority protections
    Resolving Dependencies
    --> Running transaction check
    ---> Package postgresql.x86_64 0:9.6.8-1.amzn2.0.1 will be installed
    --> Processing Dependency: postgresql-libs(x86-64) = 9.6.8-1.amzn2.0.1 for package: postgresql-9.6.8-1.amzn2.0.1.x86_64
    --> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-9.6.8-1.amzn2.0.1.x86_64
    --> Running transaction check
    ---> Package postgresql-libs.x86_64 0:9.6.8-1.amzn2.0.1 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =======================================================================================================================================================================
     Package                                Arch                          Version                                    Repository                                       Size
    =======================================================================================================================================================================
    Installing:
     postgresql                             x86_64                        9.6.8-1.amzn2.0.1                          amzn2extra-postgresql9.6                        1.3 M
    Installing for dependencies:
     postgresql-libs                        x86_64                        9.6.8-1.amzn2.0.1                          amzn2extra-postgresql9.6                        253 k
    
    Transaction Summary
    =======================================================================================================================================================================
    Install  1 Package (+1 Dependent package)
    
    Total download size: 1.6 M
    Installed size: 5.3 M
    Is this ok [y/d/N]: y
    Downloading packages:
    (1/2): postgresql-libs-9.6.8-1.amzn2.0.1.x86_64.rpm                                                                                             | 253 kB  00:00:00     
    (2/2): postgresql-9.6.8-1.amzn2.0.1.x86_64.rpm                                                                                                  | 1.3 MB  00:00:00     
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                  7.2 MB/s | 1.6 MB  00:00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : postgresql-libs-9.6.8-1.amzn2.0.1.x86_64                                                                                                            1/2 
      Installing : postgresql-9.6.8-1.amzn2.0.1.x86_64                                                                                                                 2/2 
      Verifying  : postgresql-libs-9.6.8-1.amzn2.0.1.x86_64                                                                                                            1/2 
      Verifying  : postgresql-9.6.8-1.amzn2.0.1.x86_64                                                                                                                 2/2 
    
    Installed:
      postgresql.x86_64 0:9.6.8-1.amzn2.0.1                                                                                                                                
    
    Dependency Installed:
      postgresql-libs.x86_64 0:9.6.8-1.amzn2.0.1                                                                                                                           
    
    Complete!
    
  7. It will output the summary after installation:
  8.   0  ansible2                 available    [ =2.4.2  =2.4.6 ]
      1  emacs                    available    [ =25.3 ]
      2  httpd_modules            available    [ =1.0 ]
      3  memcached1.5             available    [ =1.5.1 ]
      4  nginx1.12                available    [ =1.12.2 ]
      5  postgresql9.6=latest     enabled      [ =9.6.6  =9.6.8 ]
      6  postgresql10             available    [ =10 ]
      8  redis4.0                 available    [ =4.0.5  =4.0.10 ]
      9  R3.4                     available    [ =3.4.3 ]
     10  rust1                    available    [ =1.22.1  =1.26.0  =1.26.1  =1.27.2 ]
     11  vim                      available    [ =8.0 ]
     12  golang1.9                available    [ =1.9.2 ]
     13  ruby2.4                  available    [ =2.4.2  =2.4.4 ]
     14  nano                     available    [ =2.9.1 ]
     15  php7.2                   available    [ =7.2.0  =7.2.4  =7.2.5  =7.2.8 ]
     16  lamp-mariadb10.2-php7.2  available    [ =10.2.10_7.2.0  =10.2.10_7.2.4  =10.2.10_7.2.5  =10.2.10_7.2.8 ]
     17  libreoffice              available    [ =5.0.6.2_15  =5.3.6.1 ]
     18  gimp                     available    [ =2.8.22 ]
     19  docker=latest            enabled      [ =17.12.1  =18.03.1  =18.06.1 ]
     20  mate-desktop1.x          available    [ =1.19.0  =1.20.0 ]
     21  GraphicsMagick1.3        available    [ =1.3.29 ]
     22  tomcat8.5                available    [ =8.5.31  =8.5.32 ]
     23  epel=latest              enabled      [ =7.11 ]
    
  9. Install the postgresql service package
  10. # sudo yum update
    # sudo yum install postgresql-server.x86_64
    
    # sudo systemctl list-unit-files | grep postgresql
    postgresql.service                            disabled
    postgresql@.service                           disabled
    
    # sudo systemctl enable postgresql.service
    
  11. Inital postgresql database, Create postgres data dir.
  12. # sudo /usr/bin/postgresql-setup --initdb
    # sudo systemctl start postgresql
    
  13. Now you can login and check the Databases.
  14. # sudo -u postgres -- psql
    postgres=> \l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (3 rows)
    
  15. My connection config file: /var/lib/pgsql/data/pg_hba.conf
  16. # PostgreSQL Client Authentication Configuration File
    # ===================================================
    #
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # "local" is for Unix domain socket connections only
    local   all             all                                     md5
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5
    # IPv6 local connections:
    host    all             all             ::1/128                 md5
    
It's easy, clean and safer for me.