Install iptables and Disable Firewalld on CentOS 7 / RHEL 7

Saturday, January 16, 2016

Install iptables and Disable Firewalld on CentOS 7 / RHEL 7 :- 

There are below Steps to install iptables and disable firewalld :-

Step 1:- Disable Firewalld Service
            [root@server ~]# systemctl mask firewalld

Step 2:- Stop Firewalld Service
            [root@server ~]# systemctl stop firewalld

Step 3:- Install iptables service related packages
          [root@server ~]# yum -y install iptables-services

Step 4:- Make sure service starts at boot
           [root@server ~]# systemctl enable iptables

          # If you do not want ip6tables, You can skip following command.
         [root@server ~]# systemctl enable ip6tables

Step 5:- Now, Finally Let’s start the iptables services
          [root@server ~]# systemctl start iptables
         
          # If you do not want ip6tables, You can skip following command
          [root@server ~]# systemctl start ip6tables 

Read more...

How to Install Apache on CentOS 7

How to Install Apache on CentOS 7 :-

Following Steps to install apache on CentOS7.

Step 1:- Install Apache
          # sudo yum clean all
          # sudo yum -y update
          # sudo yum -y install httpd

Step 2:- Allow Apache via Firewall
          Allow the default HTTP and HTTPS port, ports 80 and 443, through firewalld:
         # sudo firewall-cmd --permanent --add-port=80/tcp
         # sudo firewall-cmd --permanent --add-port=443/tcp

         And reload the firewall:
         # sudo firewall-cmd --reload

Step 3:- Configure Apache to Start on Boot
         # sudo systemctl start httpd
         # sudo systemctl enable httpd
         # sudo systemctl status httpd

         To stop Apache:
         # sudo systemctl stop httpd

Read more...

Installing MariaDB In Centos 7 With Yum

Installing MariaDB In Centos 7 With Yum :-

Following Steps

1. Add the MariaDB YUM Repository :-
  [root@server ~]# touch /etc/yum.repos.d/MariaDB.repo

   [root@server ~]# vi /etc/yum.repos.d/MariaDB.repo
    and add below entry 

  [mariadb]
  name = MariaDB
  baseurl = http://yum.mariadb.org/10.1/centos7-amd64
  gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  gpgcheck=1

2. Install MariaDB with YUM :-
    [root@server ~]#  sudo yum install MariaDB-server MariaDB-client

3. Set Password :-
  
[root@server ~]# /usr/bin/mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

4. systemctl start mariadb

Be sure that MySQL/MariaDB starts at boot:

systemctl enable mariadb

5. To check the status of MySQL/MariaDB:

systemctl status mariadb

6. To stop MySQL/MariaDB:

systemctl stop mariadb

7. Check the installation with the command client:

mysql

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.40-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
 

Read more...

How to Install and Configure HAProxy on CentOS (RHEL) 7 and 6 and 5

How to Install and Configure HAProxy on CentOS/RHEL 7/6/5

There are following steps :-

1. Install HAProxy :-
    [root@mylappy ~]# yum -y install haproxy

2. Configure HAProxy :-
    
[root@mylappy ~]# mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.org
[root@mylappy ~]# vi /etc/haproxy/haproxy.cfg
# create new
 global
      # for logging section
    log         127.0.0.1 local2 info
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
      # max per-process number of connections
    maxconn     256
      # process' user and group
    user        haproxy
    group       haproxy
      # makes the process fork into background
    daemon

defaults
      # running mode
    mode               http
      # use global settings
    log                global
      # get HTTP request log
    option             httplog
      # timeout if backends do not reply
    timeout connect    10s
      # timeout on client side
    timeout client     30s
      # timeout on server side
    timeout server     30s

# define frontend ( set any name for "http-in" section )
frontend http-in
      # listen 80
    bind *:80
      # set default backend
    default_backend    backend_servers
      # send X-Forwarded-For header
    option             forwardfor

# define backend
backend backend_servers
      # balance with roundrobin
    balance            roundrobin
      # define backend servers
    server             wwwserver1 10.0.0.1:80 check
    server             wwwserver2 10.0.0.2:80 check
   
[root@mylappy ~]# systemctl start haproxy
[root@mylappy ~]# systemctl enable haproxy

3. Configure Rsyslog to get logs for HAProxy :-
   [root@mylappy ~]# vi /etc/rsyslog.conf
# line 15,16: uncomment, lne 17: add
$ModLoad imudp
$UDPServerRun 514
$AllowedSender UDP, 127.0.0.1
# line 54: change like follows
*.info;mail.none;authpriv.none;cron.none,local2.none   /var/log/messages
 local2.*                                                /var/log/haproxy.log

[root@mylappy ~]# systemctl restart rsyslog

4. Change httpd settings on Backends to logging X-Forwarded-For header :-
[root@mylappy ~]# vi /etc/httpd/conf/httpd.conf
# line 196: change like follows
LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
[root@mylappy ~]# systemctl restart httpd

5. Enable and start the haproxy service on each server:-
[root@mylappy ~]# systemctl enable haproxy
ln -s '/usr/lib/systemd/system/haproxy.service' \
  '/etc/systemd/system/multi-user.target.wants/haproxy.service'
[root@mylappy ~]# systemctl start haproxy
If you change the HAProxy configuration, reload the haproxy service:

[root@mylappy ~]# systemctl reload haproxy


6. Make sure all works fine to access to the frontend server from a Client with HTTP to check in browser














Read more...

-bash: bzip2: command not found on contos

Thursday, January 14, 2016

-bash: bzip2: command not found on centos :-

if you get below message in your screen than install bzip2 via below command :-

yum install bzip2

Read more...

How to Set Date, Time, Zone on linux sever

How to Set Date, Time, Zone on linux server ?


To Check current date and time Use Date Command :-
date
Fri June 14 21:22:41 CET 2012

How To Set Date:-
Use below comand to set new data and time:

date set="STRING"
example like :

date -s "28 May 2012 17:00:00"

How To Set Time:-
Use below Command To set time:

date +%T -s "06:11:16"
Where:

06: Hour (hh)
11: Minute (mm)
16: Second (ss)


Change timezone :-

/etc /localtime file has details about time zone. The Zone information file is located at /usr/share/zoneinfo and this depends on your distribution.

cd /etc/
ln -sf /usr/share/zoneinfo/EST localtime

If you want to set to IST (Asia/Calcutta):

ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime

Read more...

How to reset root users privileges in MySQL

Friday, January 8, 2016

How to reset root users privileges in MySQL

when ever you lost root user privileges. or you see below error multiple times.

"#1045 - Access denied for user 'root'@'localhost' (using password: YES)"

So How can I restore the MySQL root user’s full privileges? If the GRANT ALL doesn't work.

Don't Worry below steps Help to restore root user privileges.

Step 1:- Stop mysqld
          > /etc/init.d/mysqld stop
         
Step 2:- Start it with the --skip-grant-tables option.
         > /etc/init.d/mysqld start --skip-grant-tables

Step 3:- Connect to the mysqld server with just: mysql,  no -u, -p option required
          > mysql

Step 4:- Use Mysql
         > use mysql;

Step 5:- Update root privileges
           >update user set Select_priv='Y', Insert_priv='Y',Update_priv='Y',Delete_priv='Y',
        Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',
        Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',
        Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',
        Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',
        Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',
        Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',
        Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y' where User='root';

Step 6:- Give All Privileges to user
             GRANT ALL ON *.* TO 'root'@'localhost';

After that, you just need to stop the MySQL and start again.


Read more...

Reset MySQL Root Password

How To Reset MySQL Root Password

when ever you forgot root password of mysql. u can reset via below steps:-

Step 1:- Stop Mysql

            > /etc/init.d/mysqld stop


Step 2:- Start Mysql in safe mode with skip grant option

          > mysqld_safe --skip-grant-tables
   
         OR

         > /etc/init.d/mysqld start --skip-grant-tables


Step 3:- Connect to mysql without any user and password

          >mysql

Step 4:- Use Mysql;

Step 5:- Update Root Password

          > update user set Password=PASSWORD('new-password') where user='root';

Step 6:- flush privileges

           >flush privileges;

Step 7:- exit from mysql prompt
          > exit;

Restart mysql and connect via password. you will get success 

Read more...

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP