Архив за месяц Апрель 2016

Автор:human

Скрипт ввода debian 8 в Ldap(домен)

Как быстро ввести рабочую станцию или сервер на debian(ubuntu) в LDAP??Как быстро ввести рабочую станцию или сервер на debian(ubuntu) в LDAP??

Сегодня столкнулся с проблемой ввода серверов в ldap. Их 100 и нам стало неохота проделывать всю работу вручную поэтому мы и решили написать скрипт для этого дела.

Исходные данные:

Общий вид cn=admin,dc=domain,dc=com

Домен domain

Админ — admin

Пароль — PassWord

Группа с павами sudo для клиентов — main

Ip адрес ldap сервера — 10.1.9.106

Сам скрипт ввода в Ldap

PROFIT!! даже перезагрузка не нужна.
Разобрать в коде очень просто, если вы имеете некоторые представления о bash.

Автор:human

Лучшие open source системы мониторинга серверов

Лучшие open source системы мониторинга серверов

Most of the organizations works an servers to develop code, generate productivity so on. If suddenly Server goes down OR Network device goes Down there is a big question mark for all System Administrators, Managers and Engineers. Get ride of unknown server down. No need ping the servers to see whether servers are running. Just install and configure any of these monitoring tools that’s it, they will monitor all servers, services and network devices whenever any device / service stopped they will send us an alert via Email OR SMS.

In this article we are going to see most popular Top 5 Enterprise opensource monitoring tools

1. Nagios

Nagios project is started in 1999. Nagios Enterprise monitoring tool will monitor your entire IT infrastructure to ensure systems, applications, services and business process are functioning properly. Which has two types of Software’s one is Nagios Core which is fully free (opensource) we have to configure everything by our own. Another one is Nagios XI which has beautiful GUI interface it is very easy to configure monitoring.

Nagios monitors your entire IT infrastructure to ensure systems, applications, services, and business processes are functioning properly. In the event of a failure, Nagios can alert technical staff of the problem, allowing them to begin remediation processes before outages affect business processes, end-users, or customers. With Nagios you’ll never be left having to explain why an unseen infrastructure outage hurt your organization’s bottom line.

Few Advantages using Nagios Core

  1. Monitor your entire IT infrastructure
  2. Spot problems before they occur
  3. Know immediately when problems arise
  4. Share Available data with stakeholders
  5. Detect security breaches
  6. Plan and budget for IT upgrades
  7. Schedule Planed down times

Download Nagios Core

Nagios Core Installation and configuration Guide

nagios core

Nagios Webconsole - Tech Tutorials

 

2. Icinga

Monitoring Servers and networking devices with icinga2 is very easy. You can download and add plugins as many as like. No need to make set-up or maintenance of the monitoring system itself any more complex. That’s why Icinga 2 features a new configuration format that is intuitive to write, efficient to execute and even adjusts to the changing conditions of your environment at run-time.

Clear-cut, object-based configuration
Icinga 2 introduces a new object-based, rule-driven configuration format, which offers user-friendly features such as apply rules for dynamic object generation.
Taking inspiration from Puppet formats, Icinga 2 offers clear, “one best way” configuration rules. This allows Icinga 2 to depart from Nagios(TM)’s multiple configuration formats (e.g. defining host/service dependencies and parent/child relationships for hosts) – the cause of much user confusion.

The Icinga 2 configuration format is currently set as text files, in preparation for later transition to configuration via API, or GUI and CLI. A configuration migration script that translates existing Icinga 1 / Nagios configurations into the new Icinga 2 format also makes migration easier.
Apply & assign attributes
Keep configuration work to a minimum by defining templates to ”apply” to configuration objects. Apply services and notifications to hosts, or downtimes and dependencies to services.

Clever commands & runtime macros
Commands in Icinga 2 are smarter than their Nagios™-style cousins. To begin with, Icinga 2 offers three distinct command types: Check, notification and event commands. They can be given default values, custom attributes, runtime macros and conditional behaviours. Each additional option can be given precedence over the other, so that your configuration intelligently adapts at runtime to changing monitoring conditions.

Logical Dependencies
Say goodbye to confusing parent/child relationships. Dependencies in Icinga 2 are straightforward; they can be defined as host-host, service-service or mixed (host-service and service-host) and all work in the same manner.

Dynamic Notifications
Similar to Icinga 1, event handlers and notifications are supported. Thanks to the new dynamic configuration format, users can adjust notification settings at runtime (e.g. in order to implement on-call rotation).
For example, new notification objects replace notification-specific attributes for services, while user and user groups replace contact and contact groups. This new format allows notifications to be defined more precisely and intuitively. On top of this, escalations in Icinga 2 are configured as notifications with a defined beginning and end, as are recurring downtimes.

Download Icinga

Icinga

 

3. OpenNMS

OpenNMS is the world’s first Enterprise opensource monitoring tool. Which is capable of monitoring Servers and Networking devices using SNMP protocol. OpenNMS has more and more features such as

  1. Automated and Directed discovery and provisioning
  2. Event and Notification Management
  3. Service Assurance
  4. Performance Measurement

Open Source: OpenNMS is 100% Free and Open Source software, with no license fees, software subscriptions or special “enterprise” versions.

Download OpenNMS

openNMS monitoring tool

openNMS monitoring tool

 

4. zabbix

Using zabbix enterprise level monitoring tool, we can monitorr real time thousands of servers, networking devices, virtual machines simultaneously.  Along with storing the data, visualization features are available (overviews, maps, graphs, screens, etc), as well as very flexible ways of analyzing the data for the purpose of alerting.  Zabbix offers great performance for dat gathering and can be scaled to very large environments.

Features

  1. Monitor Everything
  2. Enterprise Ready
  3. Proactive Monitoring
  4. Capacity Planning
  5. True Open Source
  6. Business Solutions

Download Zabbix

zabbix arkit

Top 5 Enterprise opensource monitoring tools

5. cacti

Cacti mainly used for Network device monitoring. We can create templates. Download performance data as CSV and we can do whatever we want. User Management and graphs. Cacti makes use of RRDTool  to generate graphs and collect data from Networking devices.  The frontend is completely PHP driven. Along with being able to maintain Graphs, Data Sources, and Round Robin Archives in a database, cacti handles the data gathering. There is also SNMP support for those used to creating traffic graphs with MRTG.

Features

  1. Graphs
  2. Datasources
  3. Data Gathering
  4. Template creation
  5. Graph Display
  6. User Management
  7. Graph templates enable common graphs to be grouped together by templating. Every field for a normal graph can be templated or specified on a per-graph basis.
  8. Data source templates enable common data source types to be grouped together by templating. Every field for a normal data source can be templated or specified on a per-data source basis.
  9. Host templates are a group of graph and data source templates that allow you to define common host types. Upon the creation of a host, it will automatically take on the properties of its template.
  10. The tree view allows users to create “graph hierarchies” and place graphs on the tree. This is an easy way to manage/organize a large number of graphs.
  11. The list view lists the title of each graph in one large list which links the user to the actual graph.
  12. The preview view displays all of the graphs in one large list format. This is similar to the default view for the 14all cgi script for RRDTool/MRTG.

Download Cacti

Top 5 Enterprise opensource monitoring tools

 

That’s About Top 5 Enterprise opensource monitoring tools

Автор:human

Собираем информацию с серверов за секунды

Собираем информацию с серверов за секунды

Давайте посмотрим как можно собрать информацию о серверах с помощью скрипта

Важно: перед использование  на продакшенах протестируйте.

Создади скрипт

вставим код

запустить скрипт командой

 

если вы хотите собирать инфу с нескольких серваков необходимо настроить доступ по ssh( с помощью ключей)Запишите список серверов в файл, например в  /tmp/hostlist.txt

теперь создадим скрипт и запустим его

touch multiservers.sh

Вставим код

Делайем исполняем и запускаем

Вот и все. Получите письма

Автор:human

Установка и настройка mysqlcluster на centos7

MySQL Cluster is designed to provide a MySQL compatible database with high availability and low latency. The MySQL Cluster technology is implemented through the NDB (Network DataBase) and NDBCLUSTER storage engines and provides shared-nothing clustering and auto-sharding for MySQL database systems. In the shared-nothing architecture, each of nodes has its own memory and disk, the use of shared storage such as NFS, SANs is not recommended and supported.

To implement a MySQL Cluster, we have to install three types of nodes. Each node type will be installed on it’s own server. The components are:

1. Management Node — NDB_MGMD/MGM
The Cluster management server is used to manage the other node of the cluster. We can create and configure new nodes, restart, delete, or backup nodes on the cluster from the management node.

2. Data Nodes — NDBD/NDB
This is the layer where the process of synchronizing and data replication between nodes happens.

3. SQL Nodes — MySQLD/API
The interface servers that are used by the applications to connect to the database cluster.

In this tutorial, I will guide you trough the installation and configuration of a MySQL Cluster with centOS 7. We will configure the management node, two data nodes, and two SQL nodes.

Prerequisites

  • The OS is CentOS 7 — 64bit.
  • 5 CentOS servers or virtual machines. I will use the hostnames and IP addresses as shown below:
    • Management Node
      db1 = 192.168.1.120
    • Data Nodes
      db2 = 192.168.1.121
      db3 = 192.168.1.122
    • SQL Nodes
      db4 = 192.168.1.123
      db5 = 192.168.1.124

Step 1 — Setup Management Node

The first step is to create the «Management Node» with CentOS 7 db1 and IP 192.168.1.120. Make sure you are logged into the db1 server as root user.

A. Download the MySQL Cluster software

I’ll download it from the MySQL site with wget. I’m using the «Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit), RPM Bundle » here which is compatible with CentOS 7. Then extract the tar file.

cd ~
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
tar -xvf MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar

Install MySQL Cluster package rpm.

B. Install and Remove Packages

Before you install the rpm package for MySQL Cluster, you need to install perl-Data-Dumper that is required by the MySQL-Cluster server. And you need to remove mariadb-libs before we can install MySQL Cluster.

yum -y install perl-Data-Dumper
yum -y remove mariadb-libs

C. Install MySQL Cluster

Install MySQL Cluster package with these rpm commands:

cd ~
rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm

Make sure there is no error.

D. Configure MySQL Cluster

Create a new directory for the configuration files. I will use the «/var/lib/mysql-cluster» directory.

mkdir -p /var/lib/mysql-cluster

Then create new configuration file for the cluster management named «config.ini» in the mysql-cluster directory.

cd /var/lib/mysql-cluster
vi config.ini

Paste the configuration below:

Save the file and exit.

E. Start the Management Node

Next start the management node with the command below:

ndb_mgmd —config-file=/var/lib/mysql-cluster/config.ini

The result should be similar to this:

MySQL Cluster Management Server mysql-5.6.28 ndb-7.4.10
2016-03-22 19:26:08 [MgmtSrvr] INFO     — The default config directory ‘/usr/mysql-cluster’ does not exist. Trying to create it…
2016-03-22 19:26:08 [MgmtSrvr] INFO     — Successfully created config directory

The management node is started, now you can use command «ndb_mgm» to monitor the node:

ndb_mgm
show

Check cluster status.

You can see the management node has been started with: mysql-6.6 and ndb-7.4.

Step 2 — Setup the MySQL Cluster Data Nodes

We will use 2 CentOS servers for the Data Nodes.

  1. db2 = 192.168.1.121
  2. db3 = 192.168.1.122

A. Login as root user and download the MySQL Cluster software

Login to the db2 server with ssh:

ssh root@192.168.1.121

Then download the MySQL Cluster package and extract it:

cd ~
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
tar -xvf MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar

B. Install and Remove Packages

Install perl-Data-Dumper and remove the mariadb-libs:

yum -y install perl-Data-Dumper
yum -y remove mariadb-libs

C. Install MySQL Cluster

Now we can install the MySQL Cluster packages for the Data Nodes with these rpm commands:

cd ~
rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm

Make sure there is no error.

D. Configure Data Node

Create a new configuration file in the /etc directory with the vi editor:

vi /etc/my.cnf

Paste configuration below:

Save the file and exit.

Then create the new directory for the database data that we defined in the management node config file «config.ini».

mkdir -p /var/lib/mysql-cluster

Now start the data node/ndbd:

ndbd

results:

2016-03-22 19:35:56 [ndbd] INFO     — Angel connected to ‘192.168.1.120:1186’
2016-03-22 19:35:56 [ndbd] INFO     — Angel allocated nodeid: 2

MySQL cluster node is online.

Data Node db2 connected to the management node ip 192.168.1.120.

E. Redo step 2.A — 2.D on db3 server.

As we have 2 data nodes, please redo the steps 2.A — 2.D on our second data node.

Step 3 — Setup SQL Node

This is step contains the setup for the SQL Node that provides the application access to the database. We use 2 CentOS servers for the SQL Nodes:

  1. db4 = 192.168.1.123
  2. db5 = 192.168.1.124

A. Log in and Download MySQL Cluster

Login to the db4 server as root user:

ssh root@192.168.1.123

And download MySQL Cluster package:

cd ~
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar
tar -xvf MySQL-Cluster-gpl-7.4.10-1.el7.x86_64.rpm-bundle.tar

B. Install and Remove Packages

Install perl-Data-Dumper and remove the mariadb-libs that conflict with MySQL Cluster.

yum -y install perl-Data-Dumper
yum -y remove mariadb-libs

C. Install MySQL Cluster

Install the MySQL Cluster server, client and shared package with the rpm commands below:

cd ~
rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm

D. Configure the SQL Node

Create a new my.cnf file in the /etc directory:

vi /etc/my.cnf

And paste configuration below:

Save the file and exit the editor.

Start the SQL Node by starting the MySQL server:

service mysql start

E. Redo step 3.A — 3.D on db5 server.

Please redo the steps 3.A — 3.D on the second SQL server (db5).

Step 4 — Monitor the Cluster

To see the cluster status, we have to log into the management node db1.

ssh root@192.168.1.120

We can use the ndb_mgm command to see the cluster status:

ndb_mgm
ndb_mgm> show

Check the NDB clsuter state.

Another useful command is:

ndb_mgm -e «all status»
ndb_mgm -e «all report memory»

Step 5 — Testing the Cluster

To perform a test on our new MySQL Cluster, we have to login to the SQL Nodes db4 or db5 servers.

Login to the db4 server:

ssh root@192.168.1.123

Change the default MySQL password that stored in «.mysql_secret» file in root directory:

cd ~
cat .mysql_secret

this is my sample:

# The random password set for the root user at Tue Mar 22 19:44:07 2016 (local time): qna3AwbJMuOnw23T

Now change the password with command below:

mysql_secure_installation

Type your old mysql password and then type the new one, press enter to confirm all.

If all is done, you can login to the MySQL shell with your password:

mysql -u root -p

After you logged in, create a new root user with host «@«, so we will be able to access the MySQL from outside.

CREATE USER ‘root’@’%’ IDENTIFIED BY ‘aqwe123’;

Replace aqwe123 with your own secure password! Now you can see the new root user with host «@» on the MySQL user list:

select user, host, password from mysql.user;

And grant the new root user read and write access from the remote node:

GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY PASSWORD ‘*94CC7BF027327993D738E11…(Encrypted PASSWORD)’ WITH GRANT OPTION;

Grant priveliges.

Now try to create a new database from db4 server and you will see the database on db5 too.

This is just a sample result for testing the cluster data replication.

All nodes are online.

The MySQL Cluster has been setup successfully on CentOS 7 with 5 server nodes.

Conclusion

MySQL Cluster is a technology that provides High Availability and Redundancy for MySQL databases. It uses NDB or NDBCLUSTER as the storage engine and provides shared-nothing clustering and auto-sharding for MySQL databases.  To implement the cluster, we need 3 components: Management Node(MGM), Data Nodes (NDB) and SQL Nodes (API). Each of node must have its own memory and disk. It is not recommended to use network storage such as NFS. To install MySQL Cluster on a CentOS 7 minimal system, we have to remove the mariadb-libs package, mariadb-libs conflict with MySQL-Cluster-server and you have to install the perl-Data-Dumper package, it’s needed by MySQL-Cluster-server. A MySQL Cluster is easy to install and configure on multiple CentOS servers.