Friday, May 11, 2012

How To Install RED5 Server on Centos


In this how to i will describe how to install RED5 server on Centos 5.3. This how to can be used to install RED5 server on Centos 4 and Fedora 8 – 11 as well. RED5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc.

1) Download and Install Java

RED5 server depends on Java. CentOS 5.3 comes with OpenJDK 1.6 and install it using yum.
yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

2) Download and Install Ant & Ivy (Apache Project)

Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.
cd /usr/src
wget http://mirrors.isu.net.sa/pub/apache//ant/binaries/apache-ant-1.8.2-bin.tar.bz2
tar jxvf apache-ant-1.8.2-bin.tar.bz2
mv apache-ant-1.8.2 /usr/local/ant
if not working download from here http://archive.apache.org/dist/ant/binaries/

cd /usr/src
svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
cd ivy
ant jar
cp build/artifact/jars/ivy.jar /usr/local/ant/lib/
if ant is not working .. first do this
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin


after 



cd /usr/src
cd ivy
ant jar
cp build/artifact/jars/ivy.jar /usr/local/ant/lib/


3) Export Variables for Ant and Java

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
Also export these variables in /etc/bashrc to become available for every user login or for any terminal opens.
echo ‘export ANT_HOME=/usr/local/ant’ >> /etc/bashrc
echo ‘export JAVA_HOME=/usr/lib/jvm/java’ >> /etc/bashrc
echo ‘export PATH=$PATH:/usr/local/ant/bin’ >> /etc/bashrc

4) Download and Install RED5 Server

Here the latest version available for RED5 is 0.7 on site but download from google code using svn as the tarball of 0.7 on site is missing some of the files.
cd /usr/src
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
mv red5 /usr/local/
cd /usr/local/red5
ant prepare
ant dist
you will see a ton of lines, but you should get at last
BUILD SUCCESSFUL
that’s mean its install and now copy the conf directory from dist/ and test the red5 installation.
cp -r dist/conf .
./red5.sh
If it shows Installer service created in the last then everything is fine here, press ctrl+c and move to next step to create init script.

5) Init Script

Now we will create init script for red5 to start, stop and restart easily.
vi /etc/init.d/red5
download http://www.sohailriaz.com/downloads/red5.txt and copy / paste code in it. The init script code also be viewed below.
#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5
PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid
# Source function library
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5
RETVAL=0
case “$1″ in
start)
echo -n $”Starting $PROG: ”
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG
fi
[ $RETVAL -eq 0 ] && success $”$PROG startup” || failure $”$PROG startup”
echo
;;
stop)
echo -n $”Shutting down $PROG: ”
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|status}”
RETVAL=1
esac
exit $RETVAL
Enable executable permission
chmod +x /etc/init.d/red5
Now start the service
/etc/init.d/red5 start
check status
/etc/init.d/red5 status
red5 (pid  XXXXX) is running…
again you can do stop, restart.

6) Test

Now test the RED5 installation by opening following URL in browser
http://yourip:5080/
you will see red5 page like this
red5_11
and demos can be find here.
http://yourip:5080/demos/
red5_21
You can use simple port tester tool that determines which ports the Flash Player is able to connect through to the Red5 server. Put your server address or IP in HOST when using port tester. You should get SUCCESS on RTMP or port 1935. If not please check your firewall.
http://yourip:5080/demos/port_tester.html
red5_3

7) ISSUE

When you run ./red5.sh, it will show you Installer service created. Thats mean everything runs fine and red5 server is up. But if you went to port_tester.swf using demos above or your application shows connections FAILS, this is an issue of RTMPT and RTMPTS. You can see it by running
/usr/local/red5/red5.sh
output trancated
[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPT server bean was not found
[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPS server bean was not found
output truncated
If you see this you have to uncomment the RTMPT and RTMPTS TomcatLoader in/usr/local/red5/conf/red5-core.xml
vi /usr/local/red5/conf/red5-core.xml
Search for a lines
<!– RTMPT –>
<!–
<bean id=”rtmpt.server” class=”org.red5.server.net.rtmpt.TomcatRTMPTLoader” init-method=”init” lazy-init=”true”>
Remove the <!– from start of <bean and –> from end of </bean>
Same goes for RTMPS
<!– RTMPS –>
<!–
<bean id=”rtmps.server” class=”org.red5.server.net.rtmps.TomcatRTMPSLoader” init-method=”init” lazy-init=”true”>
Remove the <!– from start of <bean and –> from end of </bean>
Restart the red5 services and connection fails problem will be fixed.
If you any question please use comments.

Saturday, April 21, 2012

Linux Creating a Partition Size Larger Than 2TB

Linux GPT Kernel Support

EFI GUID Partition support works on both 32bit and 64bit platforms. You must include GPT support in kernel in order to use GPT. If you don't include GPT support in Linux kernelt, after rebooting the server, the file system will no longer be mountable or the GPT table will get corrupted. By default Redhat Enterprise Linux / CentOS comes with GPT kernel support. However, if you are using Debian or Ubuntu Linux, you need to recompile the kernel. SetCONFIG_EFI_PARTITION to y to compile this feature.
File Systems
   Partition Types
     [*] Advanced partition selection
     [*] EFI GUID Partition support (NEW)
....

Find Out Current Disk Size

Type the following command:
# fdisk -l /dev/sdb
Sample outputs:
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table

Linux Create 3TB partition size

To create a partition start GNU parted as follows:
# parted /dev/sdb
Output:
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
Creates a new GPT disklabel i.e. partition table:
(parted) mklabel gpt
Sample outputs:
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted)
Next, set the default unit to TB, enter:
(parted) unit TB
To create a 3TB partition size, enter:
(parted) mkpart primary 0 0
OR
(parted) mkpart primary 0.00TB 3.00TB
To print the current partitions, enter:
(parted) print
Sample outputs:
Model: ATA ST33000651AS (scsi)
Disk /dev/sdb: 3.00TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name     Flags
 1      0.00TB  3.00TB  3.00TB  ext4         primary
Quit and save the changes, enter:
(parted) quit
Sample outputs:
Information: You may need to update /etc/fstab.
Use the mkfs.ext3 or mkfs.ext4 command to format the file system, enter:
# mkfs.ext3 /dev/sdb1
OR
# mkfs.ext4 /dev/sdb1
Sample outputs:
mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183148544 inodes, 732566272 blocks
36628313 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
22357 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
 102400000, 214990848, 512000000, 550731776, 644972544
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
Type the following commands to mount /dev/sdb1, enter:
# mkdir /data
# mount /dev/sdb1 /data
# df -H

Sample outputs:
Filesystem             Size   Used  Avail Use% Mounted on
/dev/sdc1               16G   819M    14G   6% /
tmpfs                  1.6G      0   1.6G   0% /lib/init/rw
udev                   1.6G   123k   1.6G   1% /dev
tmpfs                  1.6G      0   1.6G   0% /dev/shm
/dev/sdb1              3.0T   211M   2.9T   1% /data
Make sure you replace /dev/sdb1 with actual RAID or Disk name or Block Ethernet device such as /dev/etherd/e0.0. Do not forget to update /etc/fstab, if necessary. Also note that booting from a GPT volume requires support in your BIOS / firmware. This is not supported on non-EFI platforms. I suggest you boot server from another disk such as IDE / SATA / SSD disk and store data on /data.
http://www.cybercity.biz

Saturday, April 14, 2012

Counter Strike 1.6 server Linux

Создаем директорию для нашего сервера:
mkdir /usr/hlds
cd /usr/hlds
Затем скачиваем следующие файлы:
- HldsUpdateTool:
wget http://www.steampowered.com/download/hldsupdatetool.bin
- NoSteamAuthEngines:
wget http://dig.org.ua/files/cs/engine.v15.tgz
Переходим непосредственно к установке.
1. Переходим в /usr/hlds. Запускаем hldsupdatetool.bin:
chmod +x hldsupdatetool.bin
./hldsupdatetool.bin

После запуска должен появиться файл steam.
2. Устанавливаем сервер:
./steam -command update -game valve -dir .
В зависимости от вашего интернет-подключения, установка сервера может длиться от нескольких минут, до нескольких часов (в моем случае).
3. Устанавливаем мод Counter-Strike:
./steam -command update -game cstrike -dir .
Опять же, в зависимости от вашего интернета, ждем, варим и употребляем кофе :)
Если вы собираете Steam-сервер (для лицензионных пользователей), этот текст можно пропустить. А для NoSteam-сервера (в моем случае) нам необходимо пропатчить сервер.
cd /usr/hlds/:
rm -rf engine_amd.so
rm -rf engine_i486.so
rm -rf engine_i686.so
tar xfvz engine.v15.tgz

Переходим к конфигурированию. 
Пример файла конфигурации /usr/hlds/cstrike/server.cfg:
hostname “Server Name”
mp_autokick 0
mp_autocrosshair 0
mp_autoteambalance 0
mp_buytime 2
mp_consistency 1
mp_c4timer 35
mp_fadetoblack 0
mp_falldamage 0
mp_flashlight 1
mp_forcecamera 3
mp_forcechasecam 2
mp_friendlyfire 1
mp_freezetime 3
mp_fraglimit 0
mp_hostagepenalty 0
mp_limitteams 6
mp_logfile 1
mp_logmessages 1
mp_logdetail 3
mp_maxrounds 0
mp_playerid 0
mp_roundtime 3
mp_startmoney 800
mp_timelimit 35
mp_tkpunish 0
mp_winlimit 0
sv_aim 0
sv_airaccelerate 10
sv_airmove 1
sv_allowdownload 1
sv_clienttrace 1.0
sv_clipmode 0
sv_allowupload 1
sv_cheats 0
sv_gravity 800
sv_lan 1
sv_maxrate 7000
sv_maxspeed 320
sv_maxupdaterate 101
sys_ticrate 10000
decalfrequency 60
pausable 0
log on
decalfrequency 60
edgefriction 2
host_framerate 0
exec listip.cfg
exec banned.cfg
rcon_password yourpassword
Важно для nosteam-сервера поменять значение secure в /usr/hlds/cstrike/liblist.gam c 1 на 0.
Запуск сервера
cd /usr/hlds
./hlds_run -game cstrike +ip IP.СЕРВЕРА +sv_lan 1 -nomaster +maxplayers 18 +map dm_zerstoeren

Для запуска сервера в screen:
screen -A -m -d -S hlds ./hlds_run -game cstrike +ip IP.СЕРВЕРА +sv_lan 1 -nomaster +maxplayers 18 +map dm_zerstoeren
Если вы хотите, чтобы сервер запускался автоматически при старте ОС, нужно добавить в /etc/rc.local:
cd /usr/hlds
screen -A -m -d -S hlds ./hlds_run -game cstrike +ip IP.СЕРВЕРА +sv_lan 1 -nomaster +maxplayers 18 +map dm_zerstoeren
Как патчить сошки (*.so) и как это сделать, чтобы сервер был доступен для non-steam игроков?
- Этого делать не нужно. Достаточно поставить и настроить свежую версию dlproto. Тогда на вашем сервере смогут играть как steam так и non-steam игроки, с обоими протоколами 47/48.

Не запускается сервер, что делать?
- Проверить, установлены ли права CHMOD 777 на файлы engine_ и hlds_.

Не запускается сервер с ошибкой Error:Error:libSteamValidateUserIDTickets_i386.so: cannot open shared object file: No such file or directory, либо просто связанной со словом libSteamValidateUserIDTickets_i386.so
- скачать файл libsteamvalidateuseridtickets_i386.rar [604,24 Kb] (cкачиваний: 324), разархивировать и положить его в папку /hlds.

Сервер выдает ошибку, связанную с файлом metamod_i386.so
- Выполнить в консоли следующие команды:
cd /hlds/cstrike/addons/metamod/dlls
wget http://prdownloads.sourceforge.net/metamod/metamod-1.19-linux.tar.gz?download
tar xfvz metamod-1.19-linux.tar.gz
rm -f metamod-1.19-linux.tar.gz


Wednesday, April 4, 2012

Installing daemontools on centos

$ sudo mkdir -p /package
$ sudo chmod 1755 /package/
$ cd /package/
$ sudo wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz
$ sudo tar xzf daemontools-0.76.tar.gz
$ sudo wget http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/daemontools-0.76.errno.patch
$ cd admin/daemontools-0.76
$ sudo patch -p1 < ../../daemontools-0.76.errno.patch
$ sudo rm ../../daemontools-0.76.errno.patch ../../daemontools-0.76.tar.gz
$ sudo ./package/install
...
...
Adding svscanboot to inittab...
init should start svscan now.

Wednesday, March 14, 2012

MP4box install on centos

yum install zlib*
yum install gcc

wget http://sourceforge.net/projects/gpac/files/GPAC/GPAC%200.4.5/gpac-0.4.5.tar.gz/download
wget http://sourceforge.net/projects/gpac/files/GPAC%20extra%20libs/GPAC%20extra%20libs%200.4.5/gpac_extra_libs-0.4.5.tar.gz/download
[ me: ~ ]# tar -xzf gpac-0.4.5.tar.gz 
[ me: ~ ]# tar -xzf gpac_extra_libs-0.4.5.tar.gz 
[ me: ~ ]# cd gpac_extra_libs
[ me: gpac_extra_libs ]# cp -rf * ../gpac/extra_lib/
[ me: gpac_extra_libs ]# cd ../gpac
[ me: gpac ]# chmod +x configure 
[ me: gpac ]# ./configure 
[ me: gpac ]# make lib
If we have a problem with (make) /usr/bin/ld cannot find lglut
so 
yum install mesa-libGL-devel
yum install mesa-libGLU-devel
yum install libXi-devel
yum install libXmu-devel
yum install freeglut-devel
then:
[ me: gpac ]# make apps
[ me: gpac ]# make install lib [ me: gpac ]# make install [ me: gpac ]# cp bin/gcc/libgpac.so /usr/lib/
MP4Box -version
MP4Box - GPAC version 0.4.5 (build 33)
GPAC Copyright: (c) Jean Le Feuvre 2000-2005
                (c) ENST 2005-200X