Friday, October 31, 2014
Disable iptables in a whole cluster
for node in mynode{03,04,05,06,07,08,09,10,11,12}; do ssh root@$node '/etc/init.d/iptables stop; chkconfig iptables off'; done
Monday, October 27, 2014
Scala console
Start with 'sbt console'
scala> import sys.process._ import sys.process._ scala> "ls -al" ! total 64 drwxr-xr-x 10 Al staff 340 May 18 18:00 . drwxr-xr-x 3 Al staff 102 Apr 4 17:58 .. -rw-r--r-- 1 Al staff 118 May 17 08:34 Foo.sh -rw-r--r-- 1 Al staff 2727 May 17 08:34 Foo.sh.jar res0: Int = 0
Monday, October 20, 2014
Interactive debugging in Scala Play
Start with:
sbt console. At prompt, enter:
scala>
import java.io.Fileimport play.api._import play.api.Playval application = new DefaultApplication(new File("."), this.getClass.getClassLoader, None, Mode.Dev)Play.start(application)import play.api.Play.currentPlay context becomes available on the console:
scala> conf.Global.esClient.search("mazda")
EmbeddedESServer.search: Setting future
res6: String = {"took":218,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":246,"max_score":null,"hits":[{"_shard":0,"_node":"qffjZhZWTqObiZaTqQB7WA","_index":"twitter","_type":"tweet","_id":"523156744353370112","_score":null,"_source":{"filter_level":"medium","retweeted":false,"in_reply_to_screen_name":null,"possibly_sensitive":false,"truncated":false,"lang":"en","in_reply_to_status_id_str":null,"id":523156744353370112,"in_reply_to_user_id_str":null,"timestamp_ms":"1413565262298","in_reply_to_status_id":null,"created_at":"Fri Oct 17 17:01:02 +0000 2014","favorite_count":0,"place":null,"coordinates":null,"text":"New Mazda MX-5 - exclusive studio pictures http://t.co/mqUhp8Wf2w","contributors":null,"geo":null,"entities":{"trends":[],"symbols":[],"urls":[{
Also may use:
new play.core.StaticApplication(new java.io.File("."))
Thursday, October 16, 2014
Passwordless SSH
# on client:
user=root
[[ ! -f ~/.ssh/id_rsa.pub ]] && ssh-keygen
for n in $CLUSTER_NODES; do ssh-copy-id -i ~/.ssh/id_rsa.pub $root@$n; done
The code above is roughly equivalent to the code below, which is included only to explain roughly what ssh-copy-id does under the covers. The first approach is strongly recommended.
CLUSTER_NODES="39.96.64.13 39.96.64.15 39.96.64.17"
for node in $CLUSTER_NODES
do
cat ~/.ssh/id_rsa.pub |
ssh $user@${node} 'cat >> ~/.ssh/authorized_keys;
chmod go-w ~/;
chmod 700 ~/.ssh;
chmod 600 ~/.ssh/authorized_keys ~/.ssh/id_rsa;
chmod 644 ~/.ssh/id_rsa.pub' # ~/.ssh/known_hosts
done
# on server:
chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub ~/.ssh/known_hosts
Tuesday, October 14, 2014
Set up SSH tunnel
Tunnel firewalled Elasticsearch port (9200) through SSH
Tunnel service out with access to server host:
ssh -N -f remoteuser@remotehost -L 19200:localhost:9200Options:
- -N: Do not execute command (optional, mostly for security)
- -f: Go into background (otherwise remote prompt comes into terminal)
- -L: Local port mapping (local port 19200 will tunnel into remote 9200)
SOCKS proxy
-D 8080: Dynamic SOCKS server
-f : Fork into background
-C : Turn on compression
-q : Quiet mode
-N : No commands (required by -f)
Wednesday, October 08, 2014
Test host name resolution (python)
python -c 'import socket; print socket.getfqdn(), socket.gethostbyname(socket.
VirtualBox, CentOS eth0: transmit timed out; status 0073, resetting.
Error seemed due to unused virtual adapters having 'Cable Connected' checked:
1. Clear 'Cable Connected' in all unused adapters
2. Set 'Attached to:' to 'Not attached' in all unused adapters
3. service network restart
Hello Neo4j
service neo4j-service stop
service neo4j-service start
// all Page nodes named Automobile
match (n:Page{name:'Automobile'}) return count(*);
// = 24 // should be 1
match (n:Page) return n.id, n.name, count(*) limit 10;
n.id | n.name | count(*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
null | European_Car_of_the_Year | 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
null | Hamm_AG | 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
null | Ford_Motors | 1 |
Set up static IP address
vi /etc/sysconfig/network/ifcfg-eth0 (SLES)
vi /etc/sysconfig/network-scripts/ifcfg-eth0 (CentOS)
vi /etc/sysconfig/networking/devices/ifcfg-eth0 (CentOS?), set values to:
BOOTPROTO=static
IPADDR=10.1.1.100
NETMASK=255.255.255.0
BROADCAST=10.1.0.255
NETWORK=10.1.0.0
IPADDR=10.1.1.100
NETMASK=255.255.255.0
BROADCAST=10.1.0.255
NETWORK=10.1.0.0
Also, set up DNS server:
vi /etc/resolv.conf
search home
nameserver 10.1.1.1
search home
nameserver 10.1.1.1
May need to :
route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.1.1.1
and
1. rm -f /etc/udev/rules.d/70-persistent-net.rules
2. Edit ifcfg-eth0 and remove the UUID and MACADDR (HWADDR):
vi /etc/sysconfig/networking/devices/ifcfg-eth0
vi /etc/sysconfig/networking/devices/ifcfg-eth0
3. Reboot (init 6)
Centos error on VirtualBox (Device eth0 does not seem to be present, delaying initialization)
1. rm -f /etc/udev/rules.d/70-persistent-net.rules
2. Edit ifcfg-eth0 and remove the UUID and MACADDR (HWADDR):
vim /etc/sysconfig/networking/devices/ifcfg-eth0
vim /etc/sysconfig/networking/devices/ifcfg-eth0
3. Reboot (init 6)
Tuesday, October 07, 2014
Install Elasticsearch on CentOS
Install RPM
sudo rpm -i https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.4.noarch.rpm
ES is installed under /usr/share/elasticsearch
Config at /etc/elasticsearch/elasticsearch.yml
Start automatically
sudo /sbin/chkconfig --add elasticsearch
Start now
sudo service elasticsearch start
Disable IPv6 on CentOS
Method #1 (recommended)
Permanent: Edit /etc/sysctl.conf to:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
Runtime only:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
Method #2 (discouraged: it may interfere with SELinux and other components)
Add the following to /etc/sysconfig/network-scripts/ for the device
IPV6INIT=no
SCRIPT (caution!):
echo -e "net.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1" | while read f; do if [ $(grep -c "$f" /etc/sysctl.conf) -eq 0 ]; then echo -e "\n$f" >> /etc/sysctl.conf; fi; done
Mount block device
How to mount a new block device (CentOS)
# Check current status: shows no partition info and disk ID=0x0
sudo fdisk -l
Disk /dev/xvdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 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
# Create a partition. Answer prompts as indicated
sudo fdisk /dev/xvdc
n # new partition
p # primary
1 # partition no.
<enter> # accept start cyclinder default
<enter> # accept end cyclinder default (take whole device!)
w # write partition
# Verify. fdisk should show new partition info
sudo fdisk -l
Disk /dev/xvdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 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: 0xb7719266
Device Boot Start End Blocks Id System
/dev/xvdc1 1 26108 209712478+ 83 Linux
# Format new device
sudo mkfs -t ext3 /dev/xvdc1
# Mount it
[ ! -d /data ] && sudo mkdir /data
sudo mount /dev/xvdc1 /data
# Make permanent
sudo nano /etc/fstab
# edit to add:
/dev/xvdc1 /data ext3 defaults,noatime,barrier=0 1 1
# Check current status: shows no partition info and disk ID=0x0
sudo fdisk -l
Disk /dev/xvdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 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
# Create a partition. Answer prompts as indicated
sudo fdisk /dev/xvdc
n # new partition
p # primary
1 # partition no.
<enter> # accept start cyclinder default
<enter> # accept end cyclinder default (take whole device!)
w # write partition
# Verify. fdisk should show new partition info
sudo fdisk -l
Disk /dev/xvdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 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: 0xb7719266
Device Boot Start End Blocks Id System
/dev/xvdc1 1 26108 209712478+ 83 Linux
# Format new device
sudo mkfs -t ext3 /dev/xvdc1
# Mount it
[ ! -d /data ] && sudo mkdir /data
sudo mount /dev/xvdc1 /data
# Make permanent
sudo nano /etc/fstab
# edit to add:
/dev/xvdc1 /data ext3 defaults,noatime,barrier=0 1 1
Thursday, October 02, 2014
Generate Elasticsearch test documents
for i in $(seq 1 100); do echo curl -XPUT \''http://roadrunner2:9200/test-001/doc/'${i}''\' -d \''{"sentence":"'$(head -c 56 < /dev/urandom | base64)'"}'\'; done | bash
Subscribe to:
Posts (Atom)