Monday, July 28, 2014

CentOS 7 RAID5

Too tired with SmartOS (probably because of the disk failure, then decided to go with CentOS 7). Do love ZFS, will come back later.

Got good points from

dd if=/dev/zero of=/dev/sda5 bs=1M count=1024
dd if=/dev/zero of=/dev/sdb5 bs=1M count=1024
dd if=/dev/zero of=/dev/sdc5 bs=1M count=1024

http://ubuntuforums.org/showthread.php?t=1681924

Tried with 3 disks only (1TB each disk), took about 4 hours for rebuilding ....


Mainly follow instruction from https://www.grumpyland.com/blog/183/installing-software-raid-on-centos-567-via-ssh/

Considering number of dedicated server rentals that just gives JBOD, setting up your own software raid is quite handy. This tutorial goes over the very basic of how it’s done.
All of this should be done under root.
Let’s say you have 3 disks: sda, sdb & sdc. The OS is mounted on the sda, so we’ll leave that alone and make a raid 1 with sdb or sdc.

Use mdadm to create your software raid

First, make sure mdadm is installed.
yum install mdadm
Assuming that the disks sdb & sdc are unmounted & unused, we can create a raid with the two of them by telling mdadm to create the partition.
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
If you have more disks, adjust the raid devices parameter and more devices listed at the end. Other levels of RAID can be setup as well like 0, 10, etc just by changing the –level parameter. So, if you were making a raid0 of 3 disks, you could call
mdadm --create /dev/md0 --level=0 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
for example.
You can confirm the setup by looking at mdstat.
cat /proc/mdstat
Now we add the device information to a configuration file for mdadm so that they’re always available.
echo "DEVICE /dev/sdb /dev/sdc" > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
mdadm -As /dev/md0

mdmonitor for your RAID

Now that we have a RAID array, they need to be monitored. This can be done through the mdmonitor service.
service mdmonitor start
chkconfig mdmonitor on
If you’re on Centos 7, you’ll need to use the new systemctl instead.
systemctl start mdmonitor
systemctl enable mdmonitor

Making the file system & mounting it

Next, we’ll create the file system that uses this raid array and call it /dev/md0 with the file system ext4
mkfs -t ext4 /dev/md0
You can now mount md0 to any folder you want. Like…
mount /dev/md0 /home/grumpyland
The new mount point should now appear when you call df
df
We want the mount to be always there when we start up the server, so, we need to add it to fstab too using your favorite editor. I always found nano to be the most newbie friendly with the instruction on the bottom.
nano /etc/fstab
There, you’ll want to add a line about the md0 we just made.
/dev/md0                /home/grumpyland           ext4    defaults        0 0
That’s it! I hope this simplified tutorial was helpful. For further information on mdadm, check out its man pages.

Also took a look on http://vlinux-freak.blogspot.com/2011/01/how-to-implement-and-configure-raid-5.html 


Some more info about mdadm in Redhat site https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s2-raid-manage-extending.html 




Friday, April 25, 2014

Cacti on Nginx on CentOS 6

http://forums.cacti.net/viewtopic.php?f=6&t=49363

http://better.blog.51cto.com/1886029/1199143


1. Setup Webserver (nginx-1.4.7) see file compile_nginx.txt
2. Setup mysql
3. Setup cacti
- Setup service snmp
#yum install net-snmp net-snmp-utils net-snmp-devel

- compile rrdtool
#yum install cairo-devel pango-devel libxml2-devel
#cd /data/tools
#wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz
#tar -zxvf rrdtool.tar.gz
#cd rrdtool-4.8
#./configure
#make && make install

#cd ..
#wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz
#tar -zxvf cacti-0.8.8b.tar.gz
copy source cacti-0.8.8b to folder documentroot of webserver
#mv cacti-0.8.8b /zserver/nginx-1.4.7/html/cacti

#cd ..
#wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8b.tar.gz
#tar -zxvf cacti-spine-0.8.8b.tar.gz
#cd cacti-spine-0.8.8b
#./configure
#make && make install
- Config db for spine
#vi /usr/local/spine/etc/spine.conf
-----config db--------
:wq!

- setting spine
Into "Console" --> "Setting" --> "Paths" --> "Spine Poller File Path" = "/usr/local/spine/bin/spine" --> "Save"


- Test
#snmpwalk -v 1 -c cmn -O e 10.0.0.200

- Install plugins
http://docs.cacti.net/plugin

1. monitor
#cd /data/tools
#wget http://docs.cacti.net/_media/plugin:monitor-v1.3-1.tgz
#mv plugin:monitor-v1.3-1.tgz monitor-v1.3-1.tgz
#tar -zxvf monitor-v1.3-1.tgz
#mv monitor /zserver/nginx-1.4.7/html/cacti/plugins/
- Into "Plugin Management" to install

2. realtime
#cd /data/tools
#wget http://docs.cacti.net/_media/plugin:realtime-v0.5-2.tgz
#mv plugin:realtime-v0.5-2.tgz realtime-v0.5-2.tgz
#tar -zxvf realtime-v0.5-2.tgz
#mv realtime /zserver/nginx-1.4.7/html/cacti/plugins/
#cd /zserver/nginx-1.4.7/html/cacti
#mkdir realtime-image-cache
#chown nginx.nginx realtime-image-cache
- Into "Setting" --> tab "Misc" --> text-box "Cache Directory" with path: "/zserver/nginx-1.4.7/html/cacti/realtime-image-cache"

3. errorimage
4.

Streaming with nginx & rtmp module

on CentOS 6

vi /etc/yum.repos.d/nginx.repo
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

yum --enablerepo=remi  install php-pecl-apc php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-fpm php-common nginx  -y

yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel libxml2-devel libxslt-devel git

mkdir nginx-build
cd nginx-build/
wget http://nginx.org/download/nginx-1.5.13.tar.gz
tar zxvf nginx-1.5.13.tar.gz 
git clone https://github.com/arut/nginx-rtmp-module.git

cd nginx-1.5.13

./configure --user=nginx --group=nginx --add-module=../nginx-rtmp-module/ --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-http_ssl_module -–with-http_xslt_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6

make
make install

chkconfig --add nginx
chkconfig --level 345 nginx on
rpm -Uvh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
yum install ffmpeg
wget -O /etc/init.d/nginx http://pastebin.com/raw.php?i=XhNPr6Y7
vi /etc/init.d/nginx 
chmod +x /etc/init.d/nginx 
cd /etc/nginx/
vi rtmp.conf

vi nginx.conf
vi vhls.conf
service nginx restart

on SmartOS - Solaris 10

pkgin search gcc   

pkgin install gcc47-4.7.3nb2
pkgin search git
pkgin install scmgit-2.0
pkgin search gmake
pkgin install gmake-4.0

wget http://nginx.org/download/nginx-1.6.0.tar.gz

git clone https://github.com/arut/nginx-rtmp-module.git

git clone https://github.com/nbs-system/naxsi.git

./configure --user=www --group=www --with-ld-opt='-L/opt/local/lib -Wl,-R/opt/local/lib' --prefix=/opt/local --sbin-path=/opt/local/sbin --conf-path=/opt/local/etc/nginx/nginx.conf --pid-path=/var/db/nginx/nginx.pid --lock-path=/var/db/nginx/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/db/nginx/client_body_temp --http-proxy-temp-path=/var/db/nginx/proxy_temp --http-fastcgi-temp-path=/var/db/nginx/fstcgi_temp --add-module=../naxsi/naxsi_src --add-module=../nginx-rtmp-module --with-mail_ssl_module --with-http_ssl_module --with-pcre-jit --with-http_dav_module --with-http_realip_module --with-ipv6 --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_secure_link_module --with-http_gzip_static_module

gmake install