forked from supermy/mytools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
208 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
# filename: bind_addr.sh | ||
# docker默认使用’bridge’来设置container的网络模式(即从与docker0同网段的未使用的IP中取一个作为container的IP),我们这里使用’none‘来实现自己手动配置container的网络。 | ||
|
||
if [ `id -u` -ne 0 ];then | ||
echo '必须使用root权限' | ||
exit | ||
fi | ||
|
||
if [ $# != 2 ]; then | ||
echo "使用方法: $0 容器名字 IP" | ||
exit 1 | ||
fi | ||
|
||
container_name=$1 | ||
bind_ip=$2 | ||
|
||
container_id=`docker inspect -f '{{.Id}}' $container_name 2> /dev/null` | ||
if [ ! $container_id ];then | ||
echo "容器不存在" | ||
exit 2 | ||
fi | ||
bind_ip=`echo $bind_ip | egrep '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'` | ||
if [ ! $bind_ip ];then | ||
echo "IP地址格式不正确" | ||
exit 3 | ||
fi | ||
|
||
container_minid=`echo $container_id | cut -c 1-10` | ||
container_netmask=`ip addr show docker0 | grep "inet\b" | awk '{print $2}' | cut -d / -f2` | ||
container_gw=`ip addr show docker0 | grep "inet\b" | awk '{print $2}' | cut -d / -f1` | ||
|
||
bridge_name="veth_$container_minid" | ||
container_ip=$bind_ip/$container_netmask | ||
pid=`docker inspect -f '{{.State.Pid}}' salt-master 2> /dev/null` | ||
if [ ! $pid ];then | ||
echo "获取容器$container_name的id失败" | ||
exit 4 | ||
fi | ||
|
||
if [ ! -d /var/run/netns ];then | ||
mkdir -p /var/run/netns | ||
fi | ||
|
||
ln -sf /proc/$pid/ns/net /var/run/netns/$pid | ||
|
||
ip link add $bridge_name type veth peer name X | ||
brctl addif docker0 $bridge_name | ||
ip link set $bridge_name up | ||
ip link set X netns $pid | ||
ip netns exec $pid ip link set dev X name eth0 | ||
ip netns exec $pid ip link set eth0 up | ||
ip netns exec $pid ip addr add $container_ip dev eth0 | ||
ip netns exec $pid ip route add default via $container_gw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#hive 集成 hbase | ||
#hive 建表 | ||
|
||
|
||
#采集数据,传输给kafka | ||
flume1: | ||
image: myflume_base:latest | ||
environment: | ||
FLUME_AGENT_NAME: a1 | ||
FLUME_CONF_DIR: /opt/flume/conf | ||
FLUME_CONF_FILE: /var/tmp/flume.conf.hbase | ||
ports: | ||
- "44449:44444" | ||
hostname: flume1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
printjson(1); | ||
config={_id: 'rs1', members:[{_id: 0,host:'172.17.4.41:27017'},{_id:1,host:'172.17.4.39:27017'},{_id:2,host:'172.17.4.40:27017'}]} | ||
config={_id: 'rs1', members:[{_id: 0,host:'172.17.0.32:27017'},{_id:1,host:'172.17.0.30:27017'},{_id:2,host:'172.17.0.31:27017'}]} | ||
rs.initiate(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
printjson(1); | ||
config={_id: 'rs1', members:[{_id: 0,host:'172.17.4.41:27017'},{_id:1,host:'172.17.4.39:27017'},{_id:2,host:'rs13:27017'}]} | ||
config={_id: 'rs1', members:[{_id: 0,host:'172.17.0.32:27017'},{_id:1,host:'172.17.0.30:27017'},{_id:2,host:'rs13:27017'}]} | ||
rs.initiate(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
printjson(1); | ||
config={_id: 'rs2', members:[{_id: 0,host:'172.17.4.36:27017'},{_id:1,host:'172.17.4.37:27017'},{_id:2,host:'172.17.4.38:27017'}]} | ||
config={_id: 'rs2', members:[{_id: 0,host:'172.17.0.27:27017'},{_id:1,host:'172.17.0.28:27017'},{_id:2,host:'172.17.0.29:27017'}]} | ||
rs.initiate(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
printjson(1); | ||
config={_id: 'rs1', members:[{_id: 0,host:'172.17.4.36:27017'},{_id:1,host:'172.17.4.37:27017'},{_id:2,host:'172.17.4.38:27017'}]} | ||
config={_id: 'rs1', members:[{_id: 0,host:'172.17.0.27:27017'},{_id:1,host:'172.17.0.28:27017'},{_id:2,host:'172.17.0.29:27017'}]} | ||
rs.initiate(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
db = db.getSiblingDB("test"); | ||
for(var i=1;i<=1000;i++) db.c1.save({id:i,value1:"你好"}); | ||
db.c1.stats(); | ||
|
||
//插入五百万数据 | ||
for(var i=0; i<5000000; i++){ | ||
db.test1.insert({name : "mongodb_test" + i,seq : i}); | ||
} | ||
db.test1.stats(); | ||
|
||
//插入一千万数据 | ||
for(var i=0; i<10000000; i++){ | ||
db.test2.insert({name : "mongodb_test"+ i,seq : i}); | ||
} | ||
db.test2.stats(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import time,pymongo,multiprocessing,random,string | ||
class SqlToMongo: | ||
def m_sql(self,x,y): | ||
server="mongodb://python:[email protected]:27017/syslog" | ||
conn=pymongo.Connection(server) | ||
db=conn.syslog | ||
col=db.thing | ||
start=x*y | ||
end=start+x | ||
for i in xrange(start,end): | ||
d=random.randint(start,end) | ||
val=col.find({"user_id":d}) | ||
a=list(val) | ||
def gen_load(x,taskid): | ||
task=SqlToMongo() | ||
print "task %s start!" % taskid | ||
task.m_sql(x,taskid) | ||
if __name__ == "__main__": | ||
inser_number=2500000 | ||
pro_pool = multiprocessing.Pool(processes=101) | ||
print time.strftime('%Y-%m-%d:%H-%M-%S',time.localtime(time.time())) | ||
start_time=time.time() | ||
manager = multiprocessing.Manager() | ||
for i in xrange(40): | ||
taskid=i | ||
pro_pool.apply_async(gen_load,args=(inser_number,taskid)) | ||
pro_pool.close() | ||
pro_pool.join() | ||
elapsed = time.time()-start_time | ||
print elapsed | ||
time.sleep(1) | ||
print "Sub-process(es) done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
time mongo 192.168.59.103:27017/test --quiet test-performance.js |