Selasa, 26 Juni 2018

How to start TomcatStack apache tomcat mysql from command line

  Tidak ada komentar
Some time as sys admin we face a some request from developer to deploy or maintenance the tomcat webserver, we have to restart and trouble shoot the webserver here are some experience that i did when i was got the case.
Step 1: Check status service
Enter the tomcat stack directory as following figure
[root@simlalabim tomcatstack-7.0.86-0]# ls
apache2        bnsupport       config        licenses               properties.ini  uninstall
apache-ant     bnsupport-tool  ctlscript.sh  manager-linux-x64.run  README.txt      uninstall.dat
apache-tomcat  changelog.txt   img           mysql                  scripts         use_tomcatstack
apps           common          java          php                    sqlite
[root@simlalabim tomcatstack-7.0.86-0_dua]#
Make sure the ctrl script path was right
[root@simlalabim tomcatstack-7.0.86-0]$ cat ctlscript.sh
#!/bin/sh

# Allow only root execution
if [ `id|sed -e s/uid=//g -e s/\(.*//g` -ne 0 ]; then
    echo "This script requires root privileges"
    exit 1
fi


# Disabling SELinux if enabled
if [ -f "/usr/sbin/getenforce" ] && [ `id -u` = 0 ] ; then
    selinux_status=`/usr/sbin/getenforce`
    /usr/sbin/setenforce 0 2> /dev/null
fi

INSTALLDIR=/opt/tomcatstack-7.0.86-0

if [ -r "$INSTALLDIR/scripts/setenv.sh" ]; then
. "$INSTALLDIR/scripts/setenv.sh"
fi
Execute following command
sudo ./ctlscript.sh status
It will response
apache not running
tomcat not running
mysql not running

Step 2: Start the service
Execute the following command if you down know the command to do it
[root@simlalabim tomcatstack-7.0.86-0]# ./ctlscript.sh help
usage: ./ctlscript.sh help
       ./ctlscript.sh (start|stop|restart|status)
       ./ctlscript.sh (start|stop|restart|status) mysql
       ./ctlscript.sh (start|stop|restart|status) apache
       ./ctlscript.sh (start|stop|restart|status) tomcat

help       - this screen
start      - start the service(s)
stop       - stop  the service(s)
restart    - restart or start the service(s)
status     - show the status of the service(s)
You can start all services by running following command
[root@simlalabim tomcatstack-7.0.86-0]# ./ctlscript.sh start
Or you can start a service (example tomcat ) by running following command
[root@simlalabim tomcatstack-7.0.86-0]# ./ctlscript.sh start tomcat

How to configure Galera Cluster on Linux system Redhat Centos 7

  Tidak ada komentar
Firewall Setting
Galera Cluster requires a number of ports in order to maintain network connectivity between the nodes. Depending on your deployment, you may require all or some of these ports on each node in the cluster:
  • 3306 For MySQL client connections and State Snapshot Transfer that use the mysqldump method.
  • 4567 For Galera Cluster replication traffic, multicast replication uses both UDP transport and TCP on this port.
  • 4568 For Incremental State Transfer.
  • 4444 For all other State Snapshot Transfer
The commands given in the above section allow you to configure FirewallD on a running server and update the firewall rules without restarting. However, these changes are not persistent. When the server restarts, FirewallD reverts to its default configuration. To update the default configuration yourself, a somewhat different approach is required:

Setting for Firewalld firewall service
1. Enable the database service for FirewallD:
sudo firewall-cmd --zone=public --add-service=mysql --permanent
2. Open the TCP ports for Galera Cluster:
sudo firewall-cmd --zone=public --add-port=4568/tcp --permanent
sudo firewall-cmd --zone=public --add-port=4444/tcp --permanent
3. Optionally, in the event that you would like to use multicast replication, run this command as well to open UDP transport on 4567:
sudo firewall-cmd --zone=public --add-port=4567/udp --permanent
4. Reload the firewall rules, maintaining the current state information:
sudo firewall-cmd --reload
5. Check the current rules information:
sudo firewall-cmd --list-all
Setting for Iptables firewall service
When configuring packet filtering rules for a LAN environment, such as on an office network, there are four ports that you need to open to TCP for Galera Cluster and one to UDP transport to enable multicast replication. This means five commands that you must run on each cluster node:
sudo iptables --append INPUT --in-interface eth0 --protocol tcp --match tcp --dport 3306 --source 192.168.0.1/24 --jump ACCEPT
sudo iptables --append INPUT --in-interface eth0 --protocol tcp --match tcp --dport 4567 --source 192.168.0.1/24 --jump ACCEPT
sudo iptables --append INPUT --in-interface eth0 --protocol udp --match udp --dport 4567 --source 192.168.0.1/24 --jump ACCEPT
sudo iptables --append INPUT --in-interface eth0 --protocol tcp --match tcp --dport 4568 --source 192.168.0.1/24 --jump ACCEPT
sudo iptables --append INPUT --in-interface eth0 --protocol tcp --match tcp --dport 4444 --source 192.168.0.1/24 --jump ACCEPT
These commands open the relevant ports to TCP and UDP transport. It assumes that the IP addresses in your network begin with 192.168.0.1/24
Note

Warning: The IP addresses in the example are for demonstration purposes only. Use the real values from your nodes and netmask in your iptables configuration.
Galera Cluster can now pass packets through the firewall to the node, but the configuration reverts to default on reboot. In order to update the default firewall configuration you have to make Firewall Changes Persistent
For systems that use init, you can save the packet filtering state with one command:
sudo service save iptables 
For systems that use systemd, you need to save the current packet filtering rules to the path the iptables unit reads from when it starts. This path can vary by distribution, but you can normally find it in the /etc directory. For example:
  • /etc/sysconfig/iptables
  • /etc/iptables/iptables.rules
Once you find where your system stores the rules file, use iptables-save to update the file:
sudo iptables-save > /etc/sysconfig/iptables
When your system reboots, it now reads this file as the default packet filtering rules.

How to fresh Install Galera Cluster on Linux system Redhat Centos 7 Ubuntu

  Tidak ada komentar
Some time need to perform MariaDB Galera Cluster installation on Linux machine.To do that follow the below steps.
Note: Please do not use below steps if Galera Cluster have any running databases.
Step 1: Add Galera Cluster Repo
First add galera cluster repo on your server, for RPM-based distributions, such as CentOS, Red Hat and Fedora, you can enable the MariaDB repository by adding a .repo file to the /etc/yum/repos.d/ directory like bellow
# sudo  vi /etc/yum.repos.d/mariadb.repo
Add following lines
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=0
If you use Debian-based distributions no need to add it.

Step 2: Install Galera Cluster Packages
For RPM-based distributions, in the terminal run the following command:
# yum --enablerepo=mariadb -y install MariaDB-Galera-server MariaDB-client rsync galera socat
If you use Debian-based distributions, in the terminal run the following command:
# apt-get install mariadb-galera-server mariadb-client rsync galera socat

After completing above three steps, now you have a fresh Galera Cluster install on your system with new settings.

Source :

http://galeracluster.com/documentation-webpages/installmariadb.html

How to completely clean unistall MariaDBGalera Cluster in Linux system redhat centos

  Tidak ada komentar
Some time we faces issues with MariaDB Galera Cluster installation on Linux machine. If we simply remove Galera Cluster packages and re-install doesn’t fixes the issue, in that case old settings may still exists on server which again affects new install. In that case first uninstall Galera Cluster completely from system and erase all settings of old install. To do the same follow the below settings.
Note: Please do not use below steps if Galera Cluster have any running databases.
Step 1: Uninstall Galera Cluster Packages
First uninstall all the Galera Cluster packages installed on your server
# yum remove MariaDB-Galera-server MariaDB-client rsync galera socat
Step 2: Remove Galera Cluster Directory
Now we need to remove MySQL data directory from system which by default exists at /var/lib/mysql. If you didn’t find this, It may be changed to some other place, which you can find in my.cnf file with variable datadir. Delete the /var/lib/mysql directory from system but we prefer to rename it to keep a backup of existing files.
# mv /var/lib/mysql /var/lib/mysql_old_backup
Step 3: Remove Galera Cluster config Directory if still exist
After removing Galera Cluster completely, install it again using yum package manager, It will re create mysql directory under /var/lib/.
# mv /etc/my.cnf /etc/my.cnf_old_backup
# mv /etc/my.cnf.d /etc/my.cnf.d_old_backup
After completing above three steps, now you have a fresh MySQL install on your system with new settings.
Step 4: Install Galera Cluster Packages Again
After removing Galera Cluster completely, install it again using yum package manager, It will re create Galera Cluster directory under /var/lib/ and Galera Cluster config under /etc/.
# yum --enablerepo=mariadb -y install MariaDB-Galera-server MariaDB-client rsync galera socat
After completing above three steps, now you have a fresh Galera Cluster install on your system with new settings.

How to completely clean unistall MySql in Linux system redhat centos

  Tidak ada komentar
Some time we faces issues with MySQL installation on Linux machine. If we simply remove MySQL packages and re-install doesn’t fixes the issue, in that case old settings may still exists on server which again affects new install. In that case first uninstall MySQL completely from system and erase all settings of old install. To do the same follow the below settings.
Note: Please do not use below steps if MySQL have any running databases.
Step 1: Uninstall MySQL Packages
First uninstall all the MySQL packages installed on your server
 # yum remove mysql mysql-server
Step 2: Remove MySQL Directory
Now we need to remove MySQL data directory from system which by default exists at /var/lib/mysql. If you didn’t find this, It may be changed to some other place, which you can find in my.cnf file with variable datadir. Delete the /var/lib/mysql directory from system but we prefer to rename it to keep a backup of existing files.
 # mv /var/lib/mysql /var/lib/mysql_old_backup
Step 3: Remove MySQL config Directory if still exist
After removing MySQL completely, install it again using yum package manager, It will re create mysql directory under /var/lib/.
# mv /etc/my.cnf /etc/my.cnf_old_backup
# mv /etc/my.cnf.d /etc/my.cnf.d_old_backup
After completing above three steps, now you have a fresh MySQL install on your system with new settings.
Step 4: Install MySQL Packages Again
After removing MySQL completely, install it again using yum package manager, It will re create mysql directory under /var/lib/ and mysql config under /etc/.
# yum install mysql mysql-server
After completing above three steps, now you have a fresh MySQL install on your system with new settings.

Minggu, 24 Juni 2018

How to update root password and create user MariaDb MySql command line

  Tidak ada komentar


MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> update user set password=PASSWORD('the_password') where User='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4  Changed: 0  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> exit
Bye


How to Create read only user :

MariaDB [(none)]> GRANT SELECT ON *.* to haproxy@'%' IDENTIFIED BY 'the_password';
Query OK, 0 rows affected (0.00 sec)