Monday, February 13, 2017

SVN Installlation on CentOS 7



Apache Installation
------------------------


1. sudo yum install httpd
2. sudo service httpd start
3.

SVN Installation
----------------------------

1. sudo yum install mod_dav_svn
2. sudo yum install subversion

3. sudo vi /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
<Location /repos>
   DAV svn
   SVNParentPath /var/www/svn
   # Limit write permission to list of valid users.
   AuthType Basic
   AuthName "Authorization Realm"
   AuthUserFile /var/www/svn-auth/passwd
   AuthzSVNAccessFile  /var/www/svn-auth/access
   Require valid-user
</Location>


4. sudo mkdir /var/www/svn

5. sudo mkdir /var/www/svn-auth

6. sudo vi /var/www/svn-auth/access

[/]
user1 = rw
user2 = rw
guest = rw

7.
sudo htpasswd -cb /var/www/svn-auth/passwd user1 password1
sudo htpasswd -b /var/www/svn-auth/passwd user2 password2
sudo htpasswd -b /var/www/svn-auth/passwd guest password3


8.
cd /var/www/svn
sudo svnadmin create REPO1

9.
sudo chown -R apache.apache /var/www/svn /var/www/svn-auth
sudo chmod 600 /var/www/svn-auth/access /var/www/svn-auth/passwd

10.

sudo service httpd restart

11.
sudo chkconfig httpd on
sudo chkconfig --list

12.
http://YOUR_INSTANCE_IP/repos/REPO1



Other operations

To copy from an older repo including revisions:
# sudo svnadmin dump /var/www/svn/REPO1 > /tmp/REPO1.svn
(copy the file to the new server then)
# sudo svnadmin load /var/www/svn/REPO1 < /tmp/REPO1.svn

To connect a backup mirror on another (non-free) EC2 server with the same setup (guide)
First make revisions editable in the mirror repo:
# sudo echo '#!/bin/sh' > /var/www/svn/REPO1/hooks/pre-revprop-change
# sudo chmod 755 /var/www/svn/REPO1/hooks/pre-revprop-change
Then initialize the mirror from the old one:
# sudo svnsync init file:///var/www/svn/REPO1 http://YOUR_INSTANCE_IP/repos/REPO1
Should see "Copied properties for revision 0."
Then copy the data including all revisions:
# sudo svnsync sync file:///var/www/svn/REPO1
Can use this to make nightly backups to another server

Source:
http://northwaygames.com/setting-up-subversion-on-amazon-ec2-for-free/



Troubleshoot
-------------------------
Clear Cache from Eclipse on Win 7



Delete file from svn.simple folder for that
Go to C:\Users[username]\AppData\Roaming\Subversion\auth\svn.simple
After clicking {username} if AppData folder is not visible Then Go Tools-->FolderOptions-->View-->click on show hidden folders button.

 Shutdown svn
--------------------------

ps aux | grep svnserve


 Add file to  svn
--------------------------
sudo svn import /tmp/svnconfig/project1/ file:///var/www/svn/REPO1 -m "Initial repository layout for mytestproj"
Delete file to  svn
--------------------------
sudo svn delete file:///var/www/svn/REPO1/project1 -m "Initial repository layout for mytestproj" 

Saturday, January 7, 2017

MYSQL Installation on CentOS 7

MYSQL Server 5.7.17 Installation on CentOS 7 
-----------------------------------------------------------------------

Download / Copy mysql57-community-release-el7-9.noarch.rpm to /opt folder

1.  sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm
  
2. sudo yum install mysql-community-server

3. sudo service mysqld start
4. sudo service mysqld status

6. sudo grep 'temporary password' /var/log/mysqld.log
   A temporary password is generated for root@localhost: _D#p,Sjid5Zb

7. mysql -uroot -p
   > _D#p,Sjid5Zb [put temporary password]

8. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mpassword1212!';



8.   mysql -h localhost -u root -p [use password Mpassword1212!]

Note: To disable  password validate plugin

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPa$$123456789';

mysql> uninstall plugin validate_password;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxx'; [new password]


10. CREATE DATABASE projects;
11. CREATE USER 'dbuser1'@'%' IDENTIFIED BY 'Dbuser@123';
12. GRANT ALL ON projects.* TO 'dbuser1'@'%';
13. flush privileges;

sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
$ sudo firewall-cmd --reload

$ sudo firewall-cmd --list-all  
 
 
 
 Mysql Service Start
------------------------------- 
 sudo systemctl start mysqld
 or 
 sudo service mysqld start
 sudo service mysqld stop


mysql config file 
--------------------------
sudo vi /etc/my.cnf

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
port=3306
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
bind-address=1.2.3.4


mysql log file
----------
tail -100f /var/log/mysqld.log  
 
 
 
CREATE DATABASE projects;


CREATE USER 'projuser1'@'%' IDENTIFIED BY 'password';


GRANT ALL ON projects.* TO 'projuser1'@'%';

flush privileges;
 
Note: '%' means accessible from any client 
 
 
CREATE USER 'activemq'@'1.2.3.4' IDENTIFIED BY 'password';

GRANT ALL ON activemq.* TO 'activemq'@'1.2.3.4';
 
Note: '1.2.3.4' means accessible from only 1.2.3.4 ip client 
 
flush privileges;
 
DROP USER ‘activemq’@‘1.2.3.4’; 
 

Verify
--------------
mysql -u root -p
use mysql;
select user,host from user; 
 
 
 
 

Linux Server Basics

1. Create User

useradd <username> && passwd <username>


>put password 

 usermod -aG wheel <username>

2.  Change date time
timedatectl set-timezone 'Australia/Sydney'

3. Linux version

cat /etc/*release

4. Disallow root logins over SSH

vi /etc/ssh/sshd_config

PermitRootLogin no

sudo systemctl restart sshd

Update the linux kernel after the VPS start

$> sudo yum update 

Active MQ 5.14.3 Setup on Centos 7

Active MQ 5.14.3 Setup
-----------------------
Required Java installation --- Check Java installation


1. cd /opt
2. download/ftp  apache-activemq-5.14.3-bin.tar.gz
3. sudo chown -R root:root apache-activemq-5.14.3-bin.tar.gz
4.  sudo tar xzf apache-activemq-5.14.3-bin.tar.gz
5. sudo ln -sf /opt/apache-activemq-5.14.3/ /opt/activemq
6. sudo useradd activemq && passwd activemq
7. usermod -aG wheel activemq
8. sudo chown -R activemq: /opt/apache-activemq-5.14.3/
9. sudo chown -R activemq: /opt/activemq
10. sudo vi activemq/conf/activemq.xml

Comment Out :
------------------------
 <!-- <kahaDB directory="${activemq.data}/kahadb"/> -->
          <jdbcPersistenceAdapter dataDirectory="${activemq.base}/data" dataSource="#mysql-ds"/>


Add DataSource:
-------------------------------
        <bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
                <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://dbhost.xxxxx.com/activemq?relaxAutoCommit=true"/>
                <property name="username" value="xxxxxxx"/>
                <property name="password" value="xxxxxxx"/>
                <property name="poolPreparedStatements" value="true"/>
        </bean>


 

11.sudo vi /etc/init.d/activemq

#!/bin/bash
#
# activemq     Starts ActiveMQ.
#
# chkconfig: 345 88 12
# description: ActiveMQ is a JMS Messaging Queue Server.
### BEGIN INIT INFO
# Provides: $activemq
### END INIT INFO

# Source function library.
. /etc/init.d/functions

# Set JDK related environment
JAVA_HOME=/opt/jdk1.8.0_111/jre
PATH=$PATH:$JAVA_HOME/bin

# Set Mule related environment
ACTIVEMQ_HOME=/opt/activemq
PATH=$PATH:$ACTIVEMQ_HOME/bin

RETVAL=0

umask 077

# Export environment variables
export JAVA_HOME ACTIVEMQ_HOME PATH

start() {
       echo -n $"Starting ActiveMQ: "
       daemon /opt/activemq/bin/activemq start
       echo
       return $RETVAL
}
stop() {
       echo -n $"Shutting down ActiveMQ: "
       su -c "/opt/activemq/bin/activemq stop"
       echo
       return $RETVAL
}
restart() {
       stop
       start
}
case "$1" in
start)
       start
       ;;
stop)
       stop
       ;;
status)
       /opt/activemq/bin/activemq status
       ;;
restart|reload)
       restart
       ;;
*)
       echo $"Usage: $0 {start|stop|restart}"
       exit 1
esac

exit $?


13. sudo chmod +x /etc/init.d/activemq
14.  ls -al /etc/init.d/activemq


15. copy mysql adapter to activemq
sudo scp -r user@xxx.com:/opt/activemq/lib/optional/mysql-connector-java-5.1.22-bin.jar /opt/activemq/lib/optional/

16. sudo chown activemq:activemq mysql-connector-java-5.1.22-bin.jar


17.sudo service activemq start
   sudo service activemq stop
   sudo service activemq status

Set up ActiveMQ to start after reboots 

----------------------------------------------------
  sudo chkconfig --add activemq
  sudo chkconfig activemq on


Firewall  Changes
---------------------------------
1. Check the firewall status

sudo systemctl status firewalld
and
sudo firewall-cmd --state
 
if not running 
 
sudo systemctl start firewalld
sudo systemctl enable firewalld 

REBOOT if required 
 
Open the Ports for Active MQ
---------------------------------
$ sudo firewall-cmd --zone=public --add-port=8161/tcp --permanent

$ sudo firewall-cmd --reload

$ sudo firewall-cmd --list-all 


$ sudo firewall-cmd --zone=public --add-port=61616/tcp --permanent

$ sudo firewall-cmd --reload

$ sudo firewall-cmd --list-all  


Check on
http://xxxxxx.com:8161/   with password


MuleSoft Installation and Configuration on Centos 7

Mule ESB
----------------
https://developer.mulesoft.com/download-mule-esb-runtime
cd /opt
mkdir mule
cd mule
sudo wget "https://repository-master.mulesoft.org/nexus/content/repositories/releases/org/mule/distributions/mule-standalone/3.8.1/mule-standalone-3.8.1.tar.gz"

mkdir mule-dev

sudo tar xzf mule-standalone-3.8.1.tar.gz
mv /opt/mule/mule-standalone-3.8.1 /opt/mule/mule-dev



useradd mule && passwd masxxx
usermod -aG wheel mule

sudo chown -R mule:mule mule-dev

sudo vi /etc/init.d/mule-dev

#!/bin/bash
# RHEL Mule Init Script
#
# chkconfig: 2345 65 64
# description: Mule ESB service

. /etc/init.d/functions
#
if [ -f /etc/sysconfig/mule ]; then
   . /etc/sysconfig/mule
fi

# Set JDK related environment
JAVA_HOME=/usr/java/default
PATH=$PATH:$JAVA_HOME/bin

# Set Mule related environment
MULE_HOME=/opt/mule/mule-dev
MULE_LIB=$MULE_HOME/lib
PATH=$PATH:$MULE_HOME/bin
RUN_AS_USER=mule
MULE_ENV=production

# Export environment variables
export JAVA_HOME MULE_HOME MULE_LIB PATH MULE_ENV RUN_AS_USER

case "$1" in
   start)
      echo "Start service mule"
      $MULE_HOME/bin/mule start -M-Dspring.profiles.active=$MULE_ENV -M-DMULE_ENV=$MULE_ENV
      ;;
   stop)
      echo "Stop service mule"
      $MULE_HOME/bin/mule stop
      ;;
   restart)
      echo "Restart service mule"
      $MULE_HOME/bin/mule restart -M-Dspring.profiles.active=$MULE_ENV -M-DMULE_ENV=$MULE_ENV
      ;;
   *)
      echo "Usage: $0 {start|stop|restart}"
      exit 1
      ;;
esac


sudo chmod 755 /etc/init.d/mule-dev

sudo service mule-dev start

sudo service mule-dev stop

Check status
-----------------------------
cd /opt/mule/mule-dev/bin/
./mule status