Monday, April 7, 2014
Thursday, March 6, 2014
Setup the Memcached server to accept the connection other than localhost
In Multiserver Architecture sometimes we require to store some information in a centralized location for some time, in this situation Memcached comes in picture. In Ubuntu you can setup the Memcached by
sudo apt-get install memcached
Memcached has its own configuration file (/etc/memcached.conf). Here you find a option -l 127.0.0.1 you can the change it to the ip of the system and thats it all the other machine now can make the connection to Memcached machine.
sudo apt-get install memcached
Memcached has its own configuration file (/etc/memcached.conf). Here you find a option -l 127.0.0.1 you can the change it to the ip of the system and thats it all the other machine now can make the connection to Memcached machine.
Thursday, February 6, 2014
Open mysql to accept connection other then localhost
My current project have a multi layer architecture in which mysql is running on a machine and all the other machines have to take connection on that.
By default Mysql allow connection to localhost(127.0.0.1) only. So i need to open for others as well. I need to change the configuration file of mysql
we can found that file at /etc/mysql/my.cnf (in ubuntu)
We need to change a property(bind address)
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
bind-address = 0.0.0.0
Now restart the Mysql service
sudo service mysql restart
It may be possible that after doing all this you might not be able to login from different machine. For make that working you have to reset the root user password by
By default Mysql allow connection to localhost(127.0.0.1) only. So i need to open for others as well. I need to change the configuration file of mysql
we can found that file at /etc/mysql/my.cnf (in ubuntu)
We need to change a property(bind address)
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
bind-address = 0.0.0.0
Now restart the Mysql service
sudo service mysql restart
It may be possible that after doing all this you might not be able to login from different machine. For make that working you have to reset the root user password by
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;
Thursday, January 23, 2014
Multiple operation on pdf in ubuntu using pdftk package
Pdftk package provides a lot of options to work on Pdf, like concatenation, bursting, bursting selected number of pages, Encryption , Decryption
Examples:-
Examples:-
- Decrypt a PDF
pdftk secured.pdf input_pw foopass output unsecured.pdf
- Encrypt a PDF using 128-bit strength (the default), withhold all per- missions (the default)
pdftk 1.pdf output 1.128.pdf owner_pw foopass
- Same as above, except password 'baz' must also be used to open output PDF
pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz
- Join in1.pdf and in2.pdf into a new PDF, out1.pdf
pdftk in1.pdf in2.pdf cat output out1.pdf
or (using handles):
pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
or (using wildcards):
pdftk *.pdf cat output combined.pdf
- Remove 'page 13' from in1.pdf to create out1.pdf
pdftk in.pdf cat 1-12 14-end output out1.pdf
or:
pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf
- Join two files, one of which requires the password 'foopass'. The out- put is not encrypted.
pdftk A=secured.pdf 2.pdf input_pw A=foopass cat output 3.pdf
- Uncompress PDF page streams for editing the PDF in a text editor (e.g., vim, emacs)
- Burst a single PDF document into pages and dump its data to doc_data.txt
pdftk in.pdf burst
- Burst a single PDF document into encrypted pages. Allow low-quality printing
pdftk in.pdf burst owner_pw foopass allow DegradedPrinting
- Rotate the first PDF page to 90 degrees clockwise
pdftk in.pdf cat 1E 2-end output out.pdf
- Rotate an entire PDF document to 180 degrees
pdftk in.pdf cat 1-endS output out.pdf
Thursday, January 16, 2014
Ruby clone, dup vs Rails deep_dup
In Ruby:
dup and clone only duplicates the main object and leaves the inner object same.
for example
a= {'key1' => 1, 'key2' => {'key3' => 3, 'key4' => 4}}
b = a.dup
a.object_id == b.object_id # false
a['key2'].object_id == b['key2'].object_id #true
This means if i do something like
a['key2']['key5'] = 5
it will also add in b
b['key2']['key5'] # 5
In Rails:
for example
a= {'key1' => 1, 'key2' => {'key3' => 3, 'key4' => 4}}
b = a.deep_dup
a.object_id == b.object_id # false
a['key2'].object_id == b['key2'].object_id #false
This means if i do something like
a['key2']['key5'] = 5
it will not added in b
b['key2']['key5'] # nil
dup and clone only duplicates the main object and leaves the inner object same.
for example
a= {'key1' => 1, 'key2' => {'key3' => 3, 'key4' => 4}}
b = a.dup
a.object_id == b.object_id # false
a['key2'].object_id == b['key2'].object_id #true
This means if i do something like
a['key2']['key5'] = 5
it will also add in b
b['key2']['key5'] # 5
In Rails:
for example
a= {'key1' => 1, 'key2' => {'key3' => 3, 'key4' => 4}}
b = a.deep_dup
a.object_id == b.object_id # false
a['key2'].object_id == b['key2'].object_id #false
This means if i do something like
a['key2']['key5'] = 5
it will not added in b
b['key2']['key5'] # nil
Thursday, January 9, 2014
large parallel network file system using Glusterfs on ubuntu
To set up a high-availability storage with two storage servers (Ubuntu 11.10) that use GlusterFS.
Each storage server will be a mirror of the other storage server, and
files will be replicated automatically across both storage servers. The
client system (Ubuntu 11.10 as well) will be able to access the storage
as if it was a local filesystem.
GlusterFS is a clustered file-system capable of scaling to several
peta-bytes. It aggregates various storage bricks over Infiniband RDMA or
TCP/IP interconnect into one large parallel network file system.
Storage bricks can be made of any commodity hardware such as x86_64
servers with SATA-II RAID and Infiniband HBA.
All three systems should be able to resolve the other systems' hostnames. If this cannot be done through DNS, you should edit the /etc/hosts file so that it looks as follows on all three systems:
test by
glusterfsd --version
make the both servers peer with each other
on server2
sudo gluster peer probe server1
on server 1
sudo gluster peer probe server2
Check the status of peer by
sudo gluster peer
we create the share named testvol with two replicas (please note that the number of replicas is equal to the number of servers in this case because we want to set up mirroring) on server1 and server2 in the /gluster-fs-directory directory (this will be created if it doesn't exist)
sudo gluster volume create testvol replica 2 transport tcp server1:/gluster-fs-directory server2.example.com:/gluster-fs-directory
Start the volume
sudo gluster volume start testvol
You can check the status of the volume with the command
By default, all clients can connect to the volume. If you want to grant access to client1= 192.168.0.102) only, run:
Now you are done with glusterfs server
1 Preliminary Note
- server1: IP address 192.168.0.100 (server)
- server2: IP address 192.168.0.101 (server)
- client1: IP address 192.168.0.102 (client)
All three systems should be able to resolve the other systems' hostnames. If this cannot be done through DNS, you should edit the /etc/hosts file so that it looks as follows on all three systems:
vi /etc/hosts
127.0.0.1 localhost.localdomain 192.168.0.100 server1.example.com 192.168.0.101 server2.example.com 192.168.0.102 client1.example.com
2 Setting Up The GlusterFS Server
Setup GlusterFs on both machine. GlusterFS is available as a package for Ubuntu, therefore we can install it as follows:
sudo apt-get install glusterfs-server
test by
glusterfsd --version
make the both servers peer with each other
on server2
sudo gluster peer probe server1
on server 1
sudo gluster peer probe server2
Check the status of peer by
sudo gluster peer
we create the share named testvol with two replicas (please note that the number of replicas is equal to the number of servers in this case because we want to set up mirroring) on server1 and server2 in the /gluster-fs-directory directory (this will be created if it doesn't exist)
sudo gluster volume create testvol replica 2 transport tcp server1:/gluster-fs-directory server2.example.com:/gluster-fs-directory
Start the volume
sudo gluster volume start testvol
You can check the status of the volume with the command
sudo gluster volume info
sudo gluster volume set testvol auth.allow 192.168.0.102
Please note that it is possible to use wildcards for the IP addresses (like 192.168.*) and that you can specify multiple IP addresses separated by comma (e.g. 192.168.0.102,192.168.0.103).
Now you are done with glusterfs server
Thursday, December 26, 2013
Mysql dump for a single table with data only, no drop and table creation commands
mysqldump -uroot -ppassword --compact -t papaya_development users > users.sql
for more detail type mysqldump --help command on terminal.
for more detail type mysqldump --help command on terminal.
Subscribe to:
Posts (Atom)