"Life is too important to be taken seriously"
Monday, February 27, 2012
How to write init script to start your own application
/etc/init.d/httpd start or service httpd start
So, if you have a task to run 3(three) mongod at different port, and you want to run them using service, you will have to write the script in those directory mentioned above.
example:
#!/bin/bash
#description: Mongo Arbiter Servers
#Get function from functions library
. /etc/init.d/functions
prog="mongod arbiter servers"
#Start the service
start(){
initlog -c "echo -n Starting Mongo Arbiter Servers: "
/usr/bin/mongod --rest --replSet kdbsearch1 --dbpath /dbs/data1 --fork --logpath /var/log/mongodb1 --port 10001 &
/usr/bin/mongod --rest --replSet kdbsearch2 --dbpath /dbs/data2 --fork --logpath /var/log/mongodb2 --port 10002 &
/usr/bin/mongod --rest --replSet kdbsearch3 --dbpath /dbs/data3 --fork --logpath /var/log/mongodb3 --port 10003 &
#create the lock file
touch /var/lock/subsys/mongod
success $"mongo arbiter servers startup"
echo
}
stop(){
#initlog -c "echo -n Stopping mongo arbiter servers: "
echo -n $"Shutting down $prog: "
killproc mongod
#now, delete the lock file#
rm -f /var/lock/subsys/mongod
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status mongod
;;
esac
exit 0
Sunday, February 19, 2012
"service" is replaced with "systemctl" in fedora 16
| sysvinit Command | systemd Command | Notes |
|---|---|---|
| service frobozz start | systemctl start frobozz.service | Used to start a service (not reboot persistent) |
| service frobozz stop | systemctl stop frobozz.service | Used to stop a service (not reboot persistent) |
| service frobozz restart | systemctl restart frobozz.service | Used to stop and then start a service |
| service frobozz reload | systemctl reload frobozz.service | When supported, reloads the config file without interrupting pending operations. |
| service frobozz condrestart | systemctl condrestart frobozz.service | Restarts if the service is already running. |
| service frobozz status | systemctl status frobozz.service | Tells whether a service is currently running. |
| ls /etc/rc.d/init.d/ | ls /lib/systemd/system/*.service /etc/systemd/system/*.service systemctl list-units --all | Used to list the services that can be started or stopped Used to list all the services and other units |
| chkconfig frobozz on | systemctl enable frobozz.service | Turn the service on, for start at next boot, or other trigger. |
| chkconfig frobozz off | systemctl disable frobozz.service | Turn the service off for the next reboot, or any other trigger. |
| chkconfig frobozz | systemctl is-enabled frobozz.service | Used to check whether a service is configured to start or not in the current environment. |
| chkconfig frobozz --list | ls /etc/systemd/system/*.wants/frobozz.service | Used to list what levels this service is configured on or off |
| chkconfig frobozz --add | systemctl daemon-reload | Used when you create a new service file or modify any configuration |
Friday, February 10, 2012
How to compile libhdfs
at your .bashrc
export LD_LIBRARY_PATH=/usr/lib/jvm/java-6-sun/jre/lib/amd64/server:/usr/lib/jvm/java-6-sun/jre/lib/amd64/server/libjvm.so:/usr/local/hadoop/c++/Linux-amd64-64/lib
export CLASSPATH=/usr/local/hadoop/lib:/usr/local/hadoop
Thursday, February 09, 2012
Shared Library
To run a program linked with the shared version of the library the operating system must be able to locate the corresponding .so file at runtime. If the library cannot be found, the following error will occur:
$ ./a.out ./a.out: error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory
To avoid this error, either modify the system dynamic linker configuration1 or define the shell variable LD_LIBRARY_PATH to include the directory where the library is installed.
For example, in the Bourne shell (/bin/sh or /bin/bash), the library search path can be set with the following commands:
$ LD_LIBRARY_PATH=/usr/local/lib $ export LD_LIBRARY_PATH $ ./example
In the C-shell (/bin/csh or /bin/tcsh) the equivalent command is,
% setenv LD_LIBRARY_PATH /usr/local/lib
The standard prompt for the C-shell in the example above is the percent character ‘%’, and should not be typed as part of the command.
To save retyping these commands each session they can be placed in an individual or system-wide login file.
To compile a statically linked version of the program, use the -static flag in gcc,
$ gcc -static example.o -lgsl -lgslcblas -lm
Tuesday, February 07, 2012
Dell system won't boot after ubuntu maverick server installation
### BEGIN /etc/grub.d/10_linux ### menuentry 'Ubuntu, with Linux 2.6.32-21-generic' --class ubuntu --class gnu-linux --class gnu --class os { recordfail insmod ext2 set root='(hd0,1)' search --no-floppy --fs-uuid --set c00fadde-f7e8-45e7-a4da-0235c605f756 linux /boot/vmlinuz-2.6.32-21-generic root=UUID=c00fadde-f7e8-45e7-a4da-0235c605f756 ro rootdelay=90
initrd /boot/initrd.img-2.6.32-21-generic }
Sunday, February 05, 2012
Set Up NTP Server and Client
Setting Up NTP Server
Since servers in the data center is not able to synchronize with any external time server, we have to set up our standalone time server.
192.168.37.183 as Time Server
a. Make sure ntpd server is installed.
sudo apt-get install ntp
b. Since we are not going to synchronize with any external server. Edit /etc/ntp.conf:
# You do need to talk to an NTP server or two (or three).
server 127.127.1.0
fudge 127.127.1.0 stratum 10
c. Permit access for other servers in 192.168.37.0 network to synchronize
restrict 192.168.37.0 mask 255.255.255.0 nomodify notrap
broadcast 192.168.37.255
d. Star the ntp:
sudo service ntp start
At Client
a. Get ntpd server installed.
b. Synchronize to 192.168.37.183
#You do need to talk to an NTP server or two (or three).
server 192.168.37.183 iburst
c. Start the ntp:
sudo service ntp start
d. Command to check the ntp activity:
tail –f /var/log/syslog
ntpq –c lpeer
ntpd –q 192.168.37.183
Wednesday, February 01, 2012
Blog Archive
-
►
2011
(24)
-
►
March
(13)
- setTimeOut Doesn't Work in IE
- Perl Dancer Interesting Functions
- How to Upload File using Web Form in Perl Dancer
- Multi Cloud Storage API
- DBD::mysql installation
- File upload to http server
- create container using curl
- cdmi server access using curl
- What is Cloud Storage?
- Using Curl to DELETE (delete entry)
- Using Curl to POST (create new entry)
- Using Curl to PUT Rest Web Service
- Using Curl to Access Rest Web Service
-
►
March
(13)