Category Archives: CentOS

CentOS

Setup Ansible latest version

Download ansible from git:

1
2
3
cd /opt/
git clone https://github.com/ansible/ansible.git
cd ansible

Download all necessary modules:

1
2
3
4
git submodule update --init lib/ansible/modules/core
git submodule update --init lib/ansible/modules/extras
git submodule update --init v1/ansible/modules/core
git submodule update --init v1/ansible/modules/extras

add ansible's path to PATH (I use it from root):

1
2
echo 'export PATH=/opt/ansible/bin:$PATH' >> ~/.bashrc
echo 'export PYTHONPATH=/opt/ansible/lib' >> ~/.bashrc

reload .bashrc and after check ansible version command:

1
ansible --version

if you see that there is no some modules:

1
pip install <module name>

output should looks similar to:

1
2
3
4
5
6
7
ansible --version
ansible 2.0.0 (devel 2c9d1257ba) last updated 2015/07/06 12:42:09 (GMT +300)
  lib/ansible/modules/core: (detached HEAD ff69ce7912) last updated 2015/07/06 12:53:13 (GMT +300)
  lib/ansible/modules/extras: (detached HEAD 4e48ef9eca) last updated 2015/07/06 12:53:21 (GMT +300)
  v1/ansible/modules/core: (detached HEAD f8d8af17cd) last updated 2015/07/06 12:53:27 (GMT +300)
  v1/ansible/modules/extras: (detached HEAD 495ad450e5) last updated 2015/07/06 12:53:33 (GMT +300)
  configured module search path = /usr/share/ansible

e2fsck cheatsheet

e2fsck has softlinks in /sbin that one can use to keep the names of fsck tools more uniform. i.e. fsck.ext2, fsck.ext3 and fsck.ext4 (similarly, other filesystem types have e.g.: fsck.ntfs) This cheatsheet will make use of these softlinks and will use ext4 and /dev/sda1 as an example.

fsck.ext4 -p /dev/sda1 — will check filesystem on /dev/sda1 partition. It will also automatically fix all problems that can be fixed without human intervention. It will do nothing, if the partition is deemed clean (no dirty bit set).

fsck.ext4 -p -f /dev/sda1 — same as before, but fsck will ignore the fact that the filesystem is clean and check+fix it nevertheless.

fsck.ext4 -p -f -C0 /dev/sda1 — same as before, but with a progress bar.

fsck.ext4 -f -y /dev/sda1 — whereas previously fsck would ask for user input before fixing any nontrivial problems, -y means that it will simply assume you want to answer «YES» to all its suggestions, thus making the check completely non-interactive. This is potentially dangerous but sometimes unavoidable; especially when one has to go through thousands of errors. It is recommended that (if you can) you back up your partition before you have to run this kind of check. (see dd command for backing up filesystems/partitions/volumes)

fsck.ext4 -f -c -C0 /dev/sda1 — will attempt to find bad blocks on the device and make those blocks unusable by new files and directories.

fsck.ext4 -f -cc -C0 /dev/sda1 — a more thorough version of the bad blocks check.

fsck.ext4 -n -f -C0 /dev/sda1 — the -n option allows you to run fsck against a mounted filesystem in a read-only mode. This is almost completely pointless and will often result in false alarms. Do not use.

IT Security Brothers (http://itsb.pro)

Hi guys, I would like to present you our new project IT Security Brothers http://itsb.pro
We provide pentest, consultations and IT outsourcing services.
Feel free to hire us for IT jobs.

Install postgresql 9.2

Download version for your platform:
[spoiler title="Platforms packages"]
Fedora 17 — x86_64
http://yum.pgrpms.org/9.2/fedora/fedora-17-x86_64/pgdg-fedora92-9.2-5.noarch.rpm
Fedora 16 — i686
http://yum.pgrpms.org/9.2/fedora/fedora-16-i386/pgdg-fedora92-9.2-5.noarch.rpm
Fedora 16 — x86_64
http://yum.pgrpms.org/9.2/fedora/fedora-16-x86_64/pgdg-fedora92-9.2-5.noarch.rpm
Fedora 15 — i686
http://yum.pgrpms.org/9.2/fedora/fedora-15-i386/pgdg-fedora92-9.2-5.noarch.rpm
Fedora 15 — x86_64
http://yum.pgrpms.org/9.2/fedora/fedora-15-x86_64/pgdg-fedora92-9.2-5.noarch.rpm
Red Hat Enterprise Linux 6 — i386
http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-redhat92-9.2-7.noarch.rpm
Red Hat Enterprise Linux 6 — x86_64
http://yum.pgrpms.org/9.2/redhat/rhel-6-x86_64/pgdg-redhat92-9.2-7.noarch.rpm
Scientific Linux 6 — i386
http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-sl92-9.2-8.noarch.rpm
Scientific Linux 6 — x86_64
http://yum.pgrpms.org/9.2/redhat/rhel-6-x86_64/pgdg-sl92-9.2-8.noarch.rpm
CentOS 6 — i386
http://yum.pgrpms.org/9.2/redhat/rhel-6-i386/pgdg-centos92-9.2-6.noarch.rpm
CentOS 6 — x86_64
http://yum.pgrpms.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
Red Hat Enterprise Linux 5 — i386
http://yum.pgrpms.org/9.2/redhat/rhel-5-i386/pgdg-redhat92-9.2-7.noarch.rpm
Red Hat Enterprise Linux 5 — x86_64
http://yum.pgrpms.org/9.2/redhat/rhel-5-x86_64/pgdg-redhat92-9.2-7.noarch.rpm
Scientific Linux 5 — i386
http://yum.pgrpms.org/9.2/redhat/rhel-5-i386/pgdg-sl92-9.2-8.noarch.rpm
Scientific Linux 5 — x86_64
http://yum.pgrpms.org/9.2/redhat/rhel-5-x86_64/pgdg-sl92-9.2-8.noarch.rpm
CentOS 5 — i386
http://yum.pgrpms.org/9.2/redhat/rhel-5-i386/pgdg-centos92-9.2-6.noarch.rpm
CentOS 5 — x86_64
http://yum.pgrpms.org/9.2/redhat/rhel-5-x86_64/pgdg-centos92-9.2-6.noarch.rpm
[/spoiler]

yum install pgdg-<platform>92-<full version>.noarch.rpm
add "exclude=postgresql* " (without quotes) to /etc/yum.repos.d/-Base.repo in the end of sections [base] and [updates].

yum install postgresql92 postgresql92-server postgresql92-contrib
#initialize db
service postgresql-9.2 initdb
service postgresql-9.2 start
chkconfig postgresql-9.2 on

Replication:
how to make replication you can learn from official wiki:
https://wiki.postgresql.org/wiki/Streaming_Replication

CentOS: how to install postgresql 9.1

$ wget http://yum.pgrpms.org/reporpms/9.1/pgdg-centos91-9.1-4.noarch.rpm

# rpm -i pgdg-centos91-9.1-4.noarch.rpm

add "exclude=postgresql* " (without quotes) to /etc/yum.repos.d/CentOS-Base.repo in the end of sections [base] and [updates].

# yum install postgresql91-server  

# service postgresql-9.1 initdb 

# service postgresql-9.1 start 

# chkconfig postgresql-9.1 on

 

Replication:

how to make replication you can learn from official wiki:

https://wiki.postgresql.org/wiki/Streaming_Replication

CentOS: manage services

  • /sbin/service [name] start
    starts the background service
  • /sbin/service [name] stop
    stops the background service
  • /sbin/service [name] restart
    restarts the background service
  • /sbin/service [name] status
    displays the background service status
  • /sbin/chkconfig ––list
    displays all the available services
  • /sbin/chkconfig ––level 345 [name] on
    automatically runs the background service on the next startup
  • /sbin/chkconfig ––level 345 [name] off
    removes the background service from the startup list
  • /sbin/chkconfig [name] on
    enables the on-demand service
  • /sbin/chkconfig [name] off
    disables the on-demand service