#!/bin/bash
# This script is going to verify make sure all users are backup.
# Home user : /home/[0-9] and /home/[a-z]
# Home backup user: /homebackup/[0-9] and /homebackup/[a-z]
for users in {0..9} {a..z}; do
diff /home/$users/ /homebackup/$users/ | grep /home/$users/ | awk '{print $4}' >> /opt/scripts/differences.txt
done
sed -i -e "/and/d" /opt/scripts/differences.txt
# Check file content
FILE=/opt/scripts/differences.txt
if [[ -s $FILE ]] ; then
echo "Has some difference."
echo "Email Users not backup are:" >> /opt/scripts/mail.tmp
echo "" >> /opt/scripts/mail.tmp
cat /opt/scripts/differences.txt >> /opt/scripts/mail.tmp
echo "" >> /opt/scripts/mail.tmp
echo "Please check MX01." >> /opt/scripts/mail.tmp
mail -s "Mail User Not Backup" ken.vannakk@gmail.com < /opt/scripts/mail.tmp
# Remove file
rm /opt/scripts/differences.txt
rm /opt/scripts/mail.tmp
else
echo "No difference."
# Remove file
rm /opt/scripts/differences.txt
fi
# End
==================================================
#!/bin/bash
# This script is going to verify make sure all users are backup.
HOMEUSER=/home/vmail
BACKUPUSER=/homebackup/vmail
# Check the the difference between HOMEUSER and BACKUPUSER
diff $HOMEUSER $BACKUPUSER | grep $HOMEUSER | awk '{print $4}' > /opt/scripts/differences.txt
sed -i -e "/and/d" /opt/scripts/differences.txt
# Check file content
FILE=/opt/scripts/differences.txt
if [[ -s $FILE ]] ; then
echo "Has some difference."
echo "Email Users not backup are:" >> /opt/scripts/vmail.tmp
echo "" >> /opt/scripts/vmail.tmp
cat /opt/scripts/differences.txt >> /opt/scripts/vmail.tmp
echo "" >> /opt/scripts/vmail.tmp
echo "Please check MX01." >> /opt/scripts/vmail.tmp
mail -s "Mail User Not Backup" ken.vannakk@gmail.com < /opt/scripts/vmail.tmp
# Remove file
rm /opt/scripts/differences.txt
rm /opt/scripts/vmail.tmp
else
echo "No difference."
# Remove file
rm /opt/scripts/differences.txt
fi
# End
Tuesday, June 24, 2014
Wednesday, May 7, 2014
Ansible
Ansible
Rather than writing custom code to automate your systems, your team writes simple task descriptions that even the newest team member can understand on first read -- saving not only up-front costs, but making it easier to react to change over time.
Introduciton
LEARN HOW ANSIBLE WORKS.
Thursday, February 20, 2014
Reset Password MySQL User
Reset Password MySQL User
Sometime we also forgot or miss mysql user password. and here are the way to reset password mysql user. But we need to have mysql root `s password.
If you are also forgot or miss mysql root`s password.
Here is my previous article: Recovery MySQL Root Password
HowTo - Reset password mysql user.
1. Log in as root
(In this example database server is "localhost", If mysql server on different server we need to specify with -h option for database host.)
mysql -u root -p2. Use mysql database and update new password for user "vannak"
use mysql;
UPDATE mysql.user SET Password=PASSWORD('NewPassw0rd') WHERE User='vannak' AND Host='localhost';
FLUSH PRIVILEGES;
Enjoy,
Below screen shoot is the full process HowTo:
Sunday, February 16, 2014
Configure Ethernet Channel Bonding
Configure Ethernet Channel Bonding
1. Why Ethernet channel Bonding?2. How to
1. Why Ethernet channel Bonding?
Ethernet channel Bonding enable 2 or more Network Interfaces Card (NIC) to single virtual NIC card.
This is a great way to achive redundant links, fault tolerance or load balancing.
2. HowTo
OS: Ubuntu 13.04
2.1 Installation
apt-get install ifenslave
2.2 Configuration
2.2.1 Check kernel support
vi /etc/modules
loop
lp
rtc
bonding
2.2.2 Enable module
modprobe bonding
2.2.3 Edit interface configuration
vi /etc/network/interfaces
-----------------------------------
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# eth0 - the first network interface
auto eth0
iface eth0 inet manual
hwaddress ether 00:0c:29:b0:00:80
bond-master bond0
# eth1 - the second network interface
auto eth1
iface eth1 inet manual
hwaddress ether 00:0c:29:b0:00:8a
bond-master bond0
# Network bond for eth0 and eth1
auto bond0
iface bond0 inet static
address 192.168.5.200
netmask 255.255.255.0
gateway 192.168.5.2
bond-mode 1
bond-miimon 100
slaves eth0 eth1
-----------------------------------
Show IP:
2.2.4 Checking bonding interface
cat /proc/net/bonding/bond0
Try to disable one of the NIC, IP: 192.168.5.200 still available,
Enjoy,
Wednesday, January 15, 2014
Install Multiple MySQL Versions On a Single Server
In this example is going to install multiple MySQL version on a single server.
OS: Ubuntu Server 12.04
Default MySQL versoion: 5.5.34
Compiled MySQL version: 5.1.65
Note:
- mysql-server IP: 192.168.5.5
- remote-client IP: 192.168.5.1
1. Install MySQL from APT-GET
2. Install MySQL from Compile
2.1. Required Softwares
2.2 Compile MySQL
2.2.1 Download
2.2.2 Extract
2.2.3 Compile
1. Install MySQL from APT-GET
#apt-get install mysql-server
During the installation will be ask you to enter root's password.
Log in into MySQL server by command:
# mysql -u root -p
Create a test database after login by command:
#mysql> create database dbtest1;
2. Install MySQL from Compile
2.1. Required Softwares
Install compiler tools
#apt-get install build-essential libncurses-dev libstdc++6 libc6 libltdl-dev autoconf
2.2 Compile MySQL
Create folder structure,
In this example we are going to install another MySQL version 5.1.65 in /opt/mysql-versions/
# mkdir -p /opt/mysql-versions/mysql5165/datafiles
# mkdir -p /opt/mysql-versions/mysql5165/logs
# mkdir -p /opt/mysql-versions/mysql5165/pid
# mkdir -p /opt/mysql-versions/mysql5165/socket
2.2.1 Download
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.65.tar.gz
2.2.2 Extract
tar -xvf mysql-5.1.65.tar.gz
2.2.3 Compile
Go to folder mysql-5.1.65:
# cd mysql-5.1.65
-------------------------------------------------------------------------------------------------------------------------
./configure --prefix=/opt/mysql-versions/mysql5165/ --enable-assembler --with-mysqld-ldflags=-all-static --with-tcp-port=3307 --with-unix-socket-path=/opt/mysql-versions/mysql5165/socket/mysql5165.sock
-------------------------------------------------------------------------------------------------------------------------
Run command: make and make install
# make
# make install
After run command "make install"
create a file name "mysql5165.cnf" with content:
-------------------------------------------------------------------------------------------------------------------------
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = R00tPa$$w0rd
port = 3307
socket = /opt/mysql-versions/mysql5165/socket/mysql-5165.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3307
socket = /opt/mysql-versions/mysql5165/socket/mysql-5165.sock
pid-file = /opt/mysql-versions/mysql5165/pid/mysql-5165.pid
datadir = /opt/mysql-versions/mysql5165/datafiles
log = /opt/mysql-versions/mysql5165/logs/mysqld5165.log
log-error = /opt/mysql-versions/mysql5165/logs/mysqld5165.err
basedir = /opt/mysql-versions/mysql5165
skip-locking
skip-name-resolve
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=
# MASTER_USER=
#
# where you replace
#
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host =
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user =
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port =
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /opt/mysql-versions/mysql5165/var
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /opt/mysql-versions/mysql5165/var
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
--------------------------------------------------------------------------------------------------------------------------
Go to folder folder "bin" in the mysql compiled:
cd /opt/mysql-versions/mysql5165/bin
and issue command:
./mysql_install_db --defaults-file=/opt/mysql-versions/mysql5165/mysql5165.cnf --user=mysql
Change ownership the mysql compiled folder to user "mysql"
chown -R mysql:mysql /opt/mysql-versions/mysql5165
Test to start in safe mode
# /opt/mysql-versions/mysql5165/bin/mysqld_safe --defaults-file=/opt/mysql-versions/mysql5165/mysql5165.cnf --user=mysql &
# Note: If we want to auto start up add in : /etc/rc.local
Start the server
# /opt/mysql-versions/mysql5165/share/mysql/mysql.server start
Change root password
# /opt/mysql-versions/mysql5165/bin/mysqladmin -u root -P 3307 -S /opt/mysql-versions/mysql5165/socket/mysql-5165.sock password "R00tPa$$w0rd"
Log in with new password
# /opt/mysql-versions/mysql5165/bin/mysql -u root -P 3307 -S /opt/mysql-versions/mysql5165/socket/mysql-5165.sock -p
Allow other machine to remote to
Add a line "skip-name-resolve" in /opt/mysql-versions/mysql5165/mysql5165.cnf
# and on mysql server log into mysql: mysql> grant all privileges on *.* to 'root'@'192.168.5.1' identified by 'R00tPa$$w0rd' with grant option;
Login and create database:
mysql -u root -h 192.168.5.5 -p -P3307
Thursday, January 9, 2014
Script Change PHP Versions
Script Change PHP Versions
I am lazy to edit the vhost file to change the PHP version that I usually change,So I create this script to help me complete this task. :D
This is the script to change PHP version which is base on where you keep the path of your PHP.
Download this script file and put somewhere on you computer.
*** Adjust this script base on your custom configurations.
How to run the script:
sudo ./change-php-version.sh
You will get the options to choose:
Please select the options, Enter the number only.
1. For list virtualhost
2. For list PHP version
3. For Change PHP version
4. For Exit
Note: If you choose option number 3 you need to provide other informations in order to change PHP version such as:
* virtualhost-name
* PHP version
As the following example:
Please Enter virtualhost file:
(example: local.demo)
local.demo
Please Enter PHP version number only:
(example: 5.3.8)
5.4.9
If the virtualhost file exist and with PHP version is correct, Script will run without error.
Changing PHP Version to 5.4.9
* Reloading web server config [ OK ]
Virtualhost local.demo changed to PHP version 5.4.9
Done, In this example, The script will change vhost file local.demo to PHP version 5.4.9.
==================== Here is the Script Content ================
#!/bin/bash
# Version 1.0
# Require user "root" to run this script.
if [ "$(whoami)" != 'root' ]; then
echo "You have no permission to run $0 as non-root user."
echo "Log in as user '"root"' or Use '"sudo"' !!!"
exit 1;
fi
# Available options
echo ""
echo "Please select the options, Enter the number only."
echo ""
echo "1. For list virtualhost"
echo "2. For list PHP version"
echo "3. For Change PHP version"
echo "4. For Exit"
echo ""
read USERINPUT
USAGE="Pleaes enter the valid option"
if [ $USERINPUT = "1" ]
then
CONFIG_OPTION="1"
fi
if [ $USERINPUT = "2" ]
then
CONFIG_OPTION="2"
fi
if [ $USERINPUT = "3" ]
then
CONFIG_OPTION="3"
fi
if [ $USERINPUT = "4" ]
then
CONFIG_OPTION="4"
fi
if [ "$CONFIG_OPTION" = "" ]
then
echo "$USAGE"
echo ""
exit 1
fi
if [ "$USERINPUT" = "1" ]
then
echo "Available virtualhost files..."
echo ""
if [ "$USERINPUT" = "1" ];
sudo ls /etc/apache2/sites-enabled/ >> /opt/php-versions/vhost.tmp ; cat /opt/php-versions/vhost.tmp ; rm /opt/php-versions/vhost.tmp
then
echo ""
else
echo "$USAGE"
echo ""
exit 1
fi
fi
if [ "$USERINPUT" = "2" ]
then
echo "Available PHP versions..."
echo ""
if [ "$USERINPUT" = "1" ];
sudo ls /opt/php-versions/ |grep php5 >> /opt/php-versions/php-version.tmp ; cat /opt/php-versions/php-version.tmp ; rm /opt/php-versions/php-version.tmp
then
echo ""
else
echo "$USAGE"
echo ""
exit 1
fi
fi
if [ "$USERINPUT" = "4" ]; then
echo "Exit the programm"
exit 1;
fi
################################################################
if [ "$USERINPUT" = "3" ]
then
echo ""
echo "Please Enter virtualhost file:"
echo ""
echo "(example: local.demo)"
echo ""
read VHOST
echo ""
echo "Checking if file virtualhost exist or not.."
echo ""
if [ -f /etc/apache2/sites-available/$VHOST ];
then
echo "File virtualhost $VHOST exist..."
else
echo "File virtualhost $VHOST does not exists..."
exit 1
fi
echo ""
echo "Please Enter PHP version number only:"
echo ""
echo "(example: 5.3.8) "
echo ""
read PHPVERSION
echo ""
if [ $PHPVERSION = "5.3.8" ]
then
PHPPATH="/opt/php-versions/php538/"
fi
if [ $PHPVERSION = "5.4.9" ]
then
PHPPATH="/opt/php-versions/php549/"
fi
if [ $PHPVERSION = "5.4.13" ]
then
PHPPATH="/opt/php-versions/php5413/"
fi
if [ $PHPVERSION = "5.5.0" ]
then
PHPPATH="/opt/php-versions/php550/"
fi
if [ "$PHPPATH" = "" ]
then
echo "This PHP Version does not exist. or not included. "
exit 1
fi
#########################
# If $PHPVERSION = 5.3.8#
#########################
if [ $PHPVERSION = "5.3.8" ]
then
echo "Changing PHP Version to "$PHPVERSION""
# Remove "#" before Alias if more then 4 keep only 1.
sudo sed -i -e 's/#####Alias/#Alias/g' /etc/apache2/sites-available/$VHOST
# Comment all the line that exist the word "php5-default".
sudo sed -i -e 's/\
# Uncomment the line which contain the PHP version that we want to enable
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php538\//g' /etc/apache2/sites-available/$VHOST
#service apache2 restart
sudo service apache2 reload
fi
#########################
# If $PHPVERSION = 5.4.9#
#########################
if [ $PHPVERSION = "5.4.9" ]
then
echo "Changing PHP Version to "$PHPVERSION""
# Remove "#" before Alias if more then 4 keep only 1.
sudo sed -i -e 's/#####Alias/#Alias/g' /etc/apache2/sites-available/$VHOST
# Comment all the line that exist the word "php5-default".
sudo sed -i -e 's/\
# Uncomment the line which contain the PHP version that we want to enable
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default\//g' /etc/apache2/sites-available/$VHOST
#service apache2 restart
sudo service apache2 reload
fi
##########################
# If $PHPVERSION = 5.4.13#
##########################
if [ $PHPVERSION = "5.4.13" ]
then
echo "Changing PHP Version to "$PHPVERSION""
# Remove "#" before Alias if more then 4 keep only 1.
sudo sed -i -e 's/#####Alias/#Alias/g' /etc/apache2/sites-available/$VHOST
# Comment all the line that exist the word "php5-default".
sudo sed -i -e 's/\
# Uncomment the line which contain the PHP version that we want to enable
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php5413\//g' /etc/apache2/sites-available/$VHOST
#service apache2 restart
sudo service apache2 reload
fi
#########################
# If $PHPVERSION = 5.5.0#
#########################
if [ $PHPVERSION = "5.5.0" ]
then
echo "Changing PHP Version to "$PHPVERSION""
# Remove "#" before Alias if more then 4 keep only 1.
sudo sed -i -e 's/#####Alias/#Alias/g' /etc/apache2/sites-available/$VHOST
# Comment all the line that exist the word "php5-default".
sudo sed -i -e 's/\
# Uncomment the line which contain the PHP version that we want to enable
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//g' /etc/apache2/sites-available/$VHOST
sudo sed -i -e 's/#Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//Alias \/fcgi-bin\/ \/var\/www\/cgi-bin\/php5-default_php550\//g' /etc/apache2/sites-available/$VHOST
#service apache2 restart
sudo service apache2 reload
fi
echo ""
echo "Virtualhost $VHOST changed to PHP version $PHPVERSION"
else
echo ""
exit 1
fi
####################### End Of Script #######################
Monday, January 6, 2014
Zabbix Installation on CentOS 6.X
Zabbix Installation on CentOS 6.X
1. what is Zabbix?
2. Installations
3. Usage
Here we go:
1. what is Zabbix?
Zabbix is an open source monitoring solution that can be used to monitor and track performance and availability of network servers, devices and other IT resources.
2. Requirements Installations
2.1 LAMP
LAMP (Linux, Apache HTTP Server, MySQL database, and PHP/Perl/Python)
2.1.1 Install Apache
# yum install httpd
Start Apache and add to auto startup when every boot.
# service httpd start
# chkconfig httpd on
Allow Port 80 through our firewall
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# service iptables restart
2.1.2 Install MySQL
# yum install mysql mysql-server
Start MySQL and add to auto startup when every boot.
# service mysqld start
# chkconfig mysqld on
Set MySQL root's password by:
# mysql_secure_installation
2.1.3 Install PHP
# yum install php
# yum install php-mysql
2.2 EPEL
Before we can install Zabbix or other packages we need to install EPEL (Extra Packages for Enterprise Linux) first:
For CentOS 6.x
# wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm
we can show our repository installed by:
# yum repolist
Update Repository
#yum update
Install Zabbix services
#yum install zabbix-server-mysql zabbix-agent zabbix-web-mysql
Log in into MySQL and create database and user for Zabbix
[root@zabbix ~]# mysql -u root -p
Enter password:
mysql> create database zabbix;
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbixpassword';
mysql> flush privileges;
mysql> exit
Import zabbix templates to Zabbix database
# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-1.8.18/create/schema/mysql.sql
# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-1.8.18/create/data/data.sql
# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-1.8.18/create/data/images_mysql.sql
Configure Zabbix server
# vi /etc/zabbix/zabbix_server.conf
[...]
DBName=zabbix
[...]
DBUser=zabbix
[...]
DBPassword=zabbixpassword
[...]
Edit file /etc/zabbix/zabbix_agentd.conf
# vi /etc/zabbix/zabbix_agentd.conf
[...]
Hostname= zabbix.vannakk.net
[...]
Edit Zabbix reqirements:
vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 900
php_value max_input_time 600
php_value memory_limit 256M
php_value upload_max_filesize 32M
php_value post_max_size 32M
Edit PHP.ini
# vi /etc/php.ini
date.timezone = Asia/Phnom_Penh
Adjust Firewall settings
Adjust iptables to allow the zabbix ports 10050 and 10051.
# vi /etc/sysconfig/iptables
[...]
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT
[...]
# service iptables restart
Restart zabbix and httpd services and make them to start automatically on every reboot
# service zabbix-server start
# service zabbix-agent start
# service httpd restart
# service mysqld restart
# chkconfig zabbix-server on
# chkconfig zabbix-agent on
Access Zabbix Web console
http://ip-address/zabbix or http://domain-name/zabbix
Follow the screen shoot and complete all the steps:
The default username/password is admin/zabbix
3. Usage
(Not yet added)




















