понедельник, 23 февраля 2015 г.

SCP без логина и пароля & копирование файлов за сегодня

Здравствуйте.

Для начала представим ситуацию когда нам надо сделать скприт чтобы копировало файлы между компьютерами, ну да Вы подумаете это же пустяк, а нет надо чтобы скрипт был написан один раз и без участия админа запускалось все.

Тут возникает проблема ввода пароля при копировании, да есть много вариантов как избежать этого но самый хороший вариант это RSA ключи.

Ну и начнем, у нас есть два компа 172.16.10.1 и 172.16.10.2

Наша задача копирование файлов с 10.1 на 10.2

Генерируем ключ на первой машине командой


# ssh-keygen -t rsa

Generating public/private rsa key pair.
 Enter file in which to save the key (/home/linuxpathfinder/.ssh/id_rsa): [Press enter key]
 Enter passphrase (empty for no passphrase): [Press enter key]
 Enter same passphrase again: [Press enter key]
 Your identification has been saved in /home/linuxpathfinder/.ssh/id_rsa.
 Your public key has been saved in /home/linuxpathfinder/.ssh/id_rsa.pub.
 The key fingerprint is:
 35:00:a6:9c:e3:34:ce:65:bf:e2:54:5c:a8:83:a0:5e linuxpathfinder@linuxpathfinder.com
 The key's randomart image is:
 +--[ RSA 2048]----+
 |      o..        |
 |   . +   o       |
 |  . B o . +      |
 | . * * + o .     |
 |.  E= o S        |
 |. .    o .       |
 | .    o .        |
 |     o .         |
 |      .          |
 +-----------------+



Создаем директорию  .ssh на втором сервере (если нет такой директории конечно)

$ ssh asiface@172.16.10.2 mkdir -p .ssh


копирует содержимое файла /root/.ssh/id_rsa.pub в папку /root/.ssh/authorized_keys второго сервера.
Для папки .ssh делаем chmod 700 .ssh & chmod 640 authorized_keys 

Начинаем то ради чего все это задумали, копируем на второй сервер файлы которые созданы сегодня на первом сервере.

find /var/spool/asterisk/monitor/ -type f -mtime -1 | xargs -I{} scp {} root@172.16.10.2:/var/spool/asterisk/monitor/


  • -mmin n (modification time in minutes)
  • -mtime n (modification time in days)
  • -newer file (modification time newer than modification time of file)
  • -daystart (adjust start time from current time to start of day)

Вот и все на этом у нас все готово можно копировать уже на основе ключа.

воскресенье, 25 января 2015 г.

Convert WAV to MP3, Asterisk record files

Hi Dears,

So after several days which started new call-center disk is almost full, so it means file format .wav is too big and we need to convert to MP3.

1. yum install lame
2. create script for convert

script: 

#!/bin/bash
#mkdir temp
for f in /var/spool/asterisk/monitor/*.wav; do lame --replaygain-accurate -q 0 --vbr-new -V 3  "$f" "${f%.wav}.mp3"; done

пятница, 16 января 2015 г.

Доступ из WINDOWS в LINUX, Netbios -> Samba -> Netbios

В общем здравствуйте.

Появилась задача сделать доступным папку из Linux(SLES 11) для пользователей на Windows машинах, и ежу понятно что тут нужна Samba (service smb start) далее в папке /etc/samba есть конфига smb.conf  вот туда добавляем следующее:

        [backup]
        path = /backup
        writable = yes
        guest ok = yes
        public = yes
        force user = root
        force group = root
        create mask = 666
        directory mask = 666
        security mask = 666
        force create mode = 666

Все готово все довольны, буду рад если кому то сее чудо будет нужна.

пятница, 11 июля 2014 г.

Backup table on ORACLE via PLSQL

For first need to connect to DB, then

SELECT * FROM TABLE
click under your query and see this picture:



















click under Export data then see another windows




















You can choose which parameter you want for example you can drop or trancate table or backup only data.

среда, 8 августа 2012 г.

Краткий справочник команд Linux

Здравствуйте.
 Хорошо когда у ОС есть уже установленное GUI, но раз вы попали на эту страничку то у вас иной вариант :) и я специально хочу привести несколько основных команд которые помогут новичкам и не только.

Проверка памяти (оперативной памяти):
 $ grep -i memtotal /proc/meminfo

 Проверка размера swap: $ grep -i swaptotal /proc/meminfo

 Информация о процессоре: $ grep "model name" /proc/cpuinfo

 Доступный размер RAM и swap: $ free

 Доступный размер доступной места: $ df -k /dev/shm

 Копирование данных между серверамы: scp -r filename root@server_ip:/home/komil

 Копирование папки: cp -r foldername /home/komil

четверг, 2 августа 2012 г.

Date and Time in Linux

How can I set the system date and time from the command prompt (bash shell)? I don't have GUI installed and I am login over ssh session. How can I set date under Linux operating systems?


Use the date command to display the current date and time or set the system date / time over ssh session. You can also run the date command from X terminal as root user.
This is useful if the Linux server time and/or date is wrong, and you need to set it to new values from the shell prompt.
You must login as root user to use date command.
Linux Set Date

Use the following syntax to set new data and time:
date --set="STRING"
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
# date -s "2 OCT 2006 18:00:00"

OR
# date --set="2 OCT 2006 18:00:00"
You can also simplify format using following syntax:
# date +%Y%m%d -s "20081128"
Linux Set Time

To set time use the following syntax:
# date +%T -s "10:13:13"

Where,
10: Hour (hh)
13: Minute (mm)
13: Second (ss)
Use %p locale’s equivalent of either AM or PM, enter:

# date +%T%p -s "6:10:30AM"
# date +%T%p -s "12:10:30PM"

Install JBoss 7.1 on CentOS 6



This post will cover installing JBoss 7.1.1 on CentOS 6.x.

We'll also set up JBoss to run as a service, as well as set up access to the management console

Finally, we will look at how run JBoss on port 80 or, alternatively, placing JBoss behind Apache.

In this post, we will set up the JBoss 7.1.1 in Standalone mode. In a subsequent post we will look at setting up JBoss 7.1.1 in Domain mode.
Step 1: Install the Java 6 or 7


Firstly, we will need to install Java.

JBoss 7.1.1 will work with JDK 6 or JDK 7.

I'm using JDK 7, update 5.

You can download the JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

The instructions below will also work with JDK 6, you just need to change the file names accordingly.


Start by creating a directory /usr/java.


[root@dev2 ~]# mkdir /usr/java


Download jdk-7u5-linux-x64.tar.gz (or latest) and save to /usr/java directory you created above.


[root@dev2 java]# ls
jdk-7u5-linux-x64.tar.gz


Extract it:


[root@dev2 java]# tar -zxf  jdk-7u5-linux-x64.tar.gz


This will create the directory, /usr/java/jdk1.7.0_05, this will be our JAVA_HOME.


[root@dev2 java]# ls
jdk1.7.0_05  jdk-7u5-linux-x64.tar.gz
[root@dev2 java]# cd jdk1.7.0_05
[root@dev2 jdk1.7.0_05]# pwd
/usr/java/jdk1.7.0_05


Note: If you decided to use JDK 6 rather than 7 as we did above, simply save the JDK 6 bin file to /opt (or another location), then navigate to /usr/java and issue: 'sh /opt/jdk-6u33-linux-x64.bin' as shown below (substitute whichever version you downloaded). This will create a JAVA Home of /usr/java/jdk1.6.0.33


[root@dev2 ~]#cd /usr/java
[root@dev2 java]# sh /opt/jdk-6u33-linux-x64.bin



Step 2: Download and Install JBoss 7.1.1 Application Server


Change to the /usr/share directory:


[root@dev2 jdk1.7.0_05]# cd /usr/share


Download jboss-as-7.1.1.Final.zip at http://www.jboss.org/jbossas/downloads and save it to /usr/share. Or, use wget:


[root@dev2 share]# wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip


Unzip the file:


[root@dev2 share]# unzip -q jboss-as-7.1.1.Final.zip


Rename jboss-as-7.1.1.Final to jboss-as. This isn't strictly necessary, but it will save you the bother of changing the start up script later.


[root@dev2 share]# mv jboss-as-7.1.1.Final jboss-as


Our JBOSS_HOME is '/usr/share/jboss-as'.


[root@dev2 share]# cd jboss-as
[root@dev2 jboss-as]# pwd
/usr/share/jboss-as


Step 3: Create the user jboss, who will own and run JBoss


Since we will want to run JBoss as a non-root user with minimal privileges, we'll create a user, jboss, who will own the JBoss files and JBoss will run under his account.

To do this, do the following.

Create a new group, jboss, and then create the user jboss and add the user to the jboss group.


[root@dev2 share]# groupadd jboss
[root@dev2 share]# useradd -s /bin/bash -g jboss jboss


Change ownership of the JBoss home directory, /usr/share/jboss-as so all files are owned by the user jboss we created.


[root@dev2 share]# chown -Rf jboss.jboss /usr/share/jboss-as/


Step 4: Put Java into the path of jboss


Now, we need to put Java into the path of the user jboss (as well as any other users you like)

The JAVA_HOME is where we installed the JDK above: /usr/java/jdk1.7.0_05

Add the following to the .bash_profile of the user jboss:


JAVA_HOME=/usr/java/jdk1.7.0_05
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH


Switch to the user jboss and issue 'java -version' to verify that Java is now in the users path.


[root@dev2 ~]# su - jboss
[jboss@dev2 ~]$ java -version
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
[jboss@dev2 ~]$


Step 5: Create a start/stop/restart script for JBoss.


To create our JBoss script, we will copy the jboss-as-standalone.sh script located under /usr/share/jboss-as/bin/init.d

As root, copy jboss-as-standalone.sh to /etc/init.d and rename it jboss

.

[root@dev2 ~]# cd /usr/share/jboss-as/bin/init.d
[root@dev2 bin]# cp jboss-as-standalone.sh /etc/init.d/jboss


The only change I needed to make two changes to the script

The first was to change line #5 below from it's original '# chkconfig: - 80 20' to '# chkconfig: 234 80 20' The second was to set the JBOSS_USER.

To set the JBOSS_USER, add the following lines to script:

JBOSS_USER=jboss
export JBOSS_USER

You can add the lines just under 'export JAVA_HOME' on line 18 or so below. So the beginning of your script will look like this:


#!/bin/sh
#
# JBoss standalone control script
#
# chkconfig: 234 80 20
# description: JBoss AS Standalone
# processname: standalone
# pidfile: /var/run/jboss-as/jboss-as-standalone.pid
# config: /etc/jboss-as/jboss-as.conf

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

# Load Java configuration.
[ -r /etc/java/java.conf ] && . /etc/java/java.conf
export JAVA_HOME
 
JBOSS_USER=jboss
export JBOSS_USER

# Load JBoss AS init.d configuration.
if [ -z "$JBOSS_CONF" ]; then
  JBOSS_CONF="/etc/jboss-as/jboss-as.conf"
fi
 
[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}"

# Set defaults.
 
if [ -z "$JBOSS_HOME" ]; then
  JBOSS_HOME=/usr/share/jboss-as
fi
export JBOSS_HOME


Step 6: Run JBoss as a Service.


To run JBoss as a service and enable start up at boot, make the script we created above executable and add it to our chkconfig so it starts at boot.


[root@dev2 init.d]# chmod 755 jboss
[root@dev2 init.d]# chkconfig --add jboss
[root@dev2 init.d]# chkconfig --level 234 jboss on


We should now be able to Start, Stop, and Restart JBoss as a service.

Start JBoss (JBoss can take some time to start, but it is faster than JBoss 6).:


[root@dev2 init.d]# service jboss start
Starting jboss-as:                                         [  OK  ]
[root@dev2 init.d]#  


Stop JBoss:

[root@dev2 init.d]# service jboss stop
Stopping jboss-as: *** JBossAS process (25794) received TERM signal ***
                                                           [  OK  ]


Step 7: Change bind address to make JBoss accessible.


By default, JBoss 7.1.1 is bound to the loopback IP of 127.0.0.1, so if we want to make it available on the web, we need to change this.

Locate standalone.xml under /usr/share/jboss-as/standalone/configuration/.

Open standalone.xml in vi or a text editor and look for the public interfaces node as shown below.

<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>

To make JBoss publicly accessible, change 127.0.0.1 to either 0.0.0.0 to allow access on all interfaces or to your public IP.

So, for example, if your public IP is 173.194.35.177, you would change it as so:


<interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
        </interface>
        <interface name="public">
            <inet-address value="${jboss.bind.address:173.194.35.177}"/>
        </interface>
        <!-- TODO - only show this if the jacorb subsystem is added  -->
        <interface name="unsecure">
            <!--
              ~  Used for IIOP sockets in the standard configuration.
              ~                  To secure JacORB you need to setup SSL  
              -->
            <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
        </interface>
    </interfaces>


Again, if you wish to have JBoss publicly accessible on all interfaces, use 0.0.0.0 in place of your IP above.

Save your changes, start up JBoss, and check it is publicly accessible via http://yourIP:8080


[root@dev2 init.d]# service jboss start
Starting jboss-as:                                         [  OK  ]

Общее·количество·просмотров·страницы