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
15 changed files
with
162 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM alpine:edge | ||
MAINTAINER JamesMo <[email protected]> | ||
RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ | ||
apk upgrade --update && \ | ||
apk add mongodb@testing | ||
|
||
COPY ./gosu-amd64 /usr/local/bin/gosu | ||
COPY docker-entrypoint.sh /entrypoint.sh | ||
|
||
RUN chmod a+x /usr/local/bin/gosu | ||
RUN chmod a+x /entrypoint.sh | ||
|
||
EXPOSE 27017 | ||
VOLUME /var/lib/mongodb | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["mongod","--bind_ip","0.0.0.0","--dbpath","/var/lib/mongodb","--nounixsocket","--journal","--cpu","--noprealloc"] |
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,27 @@ | ||
2016-03-18 | ||
|
||
# MongoDB in a box | ||
|
||
(!!! mongodb@testing over alpine:edge !!!) AlpineLinux-base Docker image with MongoDB | ||
|
||
|
||
docker build -t supermy/docker-mongodb:ap -f mymongodb/alpine/Dockerfile mymongodb/alpine | ||
|
||
|
||
## Usage | ||
|
||
as Server: | ||
|
||
docker run -d --name mongodb -p 27017:27017 -v /data/mongodb:/var/lib/mongodb supermy/docker-mongodb:ap | ||
|
||
as Client: | ||
|
||
docker run -it --rm supermy/docker-mongodb:ap mongo --help | ||
|
||
## Configuration | ||
|
||
You may pass config options via command line, as you normally would: | ||
|
||
docker run -d -p 27017:27017 \ | ||
-v /data/mongodb:/var/lib/mongodb \ | ||
supermy/docker-mongodb:ap --storageEngine wiredTiger |
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,19 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- mongod "$@" | ||
fi | ||
|
||
if [ "$1" = 'mongod' ]; then | ||
chown -R mongodb /var/lib/mongodb | ||
|
||
numa='numactl --interleave=all' | ||
if $numa true &> /dev/null; then | ||
set -- $numa "$@" | ||
fi | ||
|
||
exec gosu mongodb "$@" | ||
fi | ||
|
||
exec "$@" |
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,9 @@ | ||
mymongodb: | ||
image: supermy/docker-mongodb:ap | ||
# volumes_from: | ||
# - data4master | ||
ports: | ||
- "27017:27017" | ||
environment: | ||
ulimit: nofile=20480:40960 | ||
net: "host" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
FROM jamesmo/debian:7 | ||
FROM supermy/docker-debian:7 | ||
|
||
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added | ||
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb | ||
|
||
#RUN export http_proxy=http://172.16.71.25:8087 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
ca-certificates curl \ | ||
numactl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# grab gosu for easy step-down from root | ||
#RUN gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 | ||
#RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \ | ||
|
@@ -17,12 +20,13 @@ RUN apt-get update \ | |
# && rm /usr/local/bin/gosu.asc \ | ||
# && chmod +x /usr/local/bin/gosu | ||
|
||
|
||
# gpg: key 7F0CEB10: public key "Richard Kreuter <[email protected]>" imported | ||
RUN apt-key adv --keyserver pool.sks-keyservers.net --recv-keys 492EAFE8CD016A07919F1D2B9ECBEC467F0CEB10 | ||
RUN gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | ||
|
||
ENV MONGO_MAJOR 3.0 | ||
ENV MONGO_VERSION 3.0.1 | ||
ENV MONGO_VERSION 3.0.4 | ||
|
||
RUN echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/$MONGO_MAJOR main" > /etc/apt/sources.list.d/mongodb-org.list | ||
|
||
|
@@ -37,6 +41,7 @@ RUN mkdir -p /data/db && chown -R mongodb:mongodb /data/db | |
VOLUME /data/db | ||
|
||
COPY docker-entrypoint.sh /entrypoint.sh | ||
RUN chmod a+x entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
|
||
EXPOSE 27017 | ||
|
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 +1,2 @@ | ||
docker build -t supermy/docker-mongodb:3.0.4 . | ||
#!/usr/bin/env bash | ||
docker build -t supermy/docker-mongodb:3.2.4 . |
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 @@ | ||
awk -f random_function.awk -f random_db.awk >db.txt |
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,3 @@ | ||
printjson(1); | ||
config={_id: 'rs1', members:[{_id: 0,host:'172.17.0.94:27017'},{_id:1,host:'172.17.0.91:27017'},{_id:2,host:'172.17.0.92: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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
printjson(1); | ||
config={_id: 'rs2', members:[{_id: 0,host:'172.17.0.88:27017'},{_id:1,host:'172.17.0.89:27017'},{_id:2,host:'172.17.0.90: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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
printjson(1); | ||
sh.addShard("rs1/172.17.0.94:27017"); | ||
sh.addShard("rs2/172.17.0.88:27017"); | ||
sh.status(); | ||
|
||
db.runCommand( { listshards : 1 } ); | ||
db.runCommand( { enablesharding:"test" }); | ||
db.runCommand( { shardcollection : "test.c1",key : {id: 1} } ); | ||
db = db.getSiblingDB("test"); | ||
for(var i=1;i<=2000;i++) db.c1.save({id:i,value1:"12345678"}); | ||
db.c1.stats(); | ||
|
||
|
||
|
||
// | ||
//#创建用户 | ||
//db = db.getSiblingDB("admin"); | ||
//db.createUser( { | ||
// user: "user1", | ||
// pwd: "111111", | ||
// roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] | ||
//}); | ||
//db.createUser( { | ||
// user: "root1", | ||
// pwd: "111111", | ||
// roles: [ { role: "root", db: "admin" } ] | ||
//}); |
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,10 @@ | ||
BEGIN { | ||
# 设置AWK程序输出时各列的分隔符 | ||
OFS = ","; | ||
srand(); | ||
#COUNT = 100000000; | ||
COUNT = 10000000; | ||
for (i=1; i<COUNT; i++) { | ||
print random_int(10, 100), random_float(3, 2), random_string("upper", 10), random_time("2009 06 01 12 30 30", "2011 07 15 23 59 59", "%Y-%m-%d %H:%M:%S"); | ||
} | ||
} |
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,35 @@ | ||
#所有的服务器要通过IP地址进行通讯 | ||
#mac sed修改强制要求备份 | ||
|
||
#初始化复制集1 | ||
cp -f initdb.js initdbi-1.js | ||
|
||
sed -i bak "s/rs11/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs11_1)/g" initdbi-1.js | ||
sed -i bak "s/rs12/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs12_1)/g" initdbi-1.js | ||
sed -i bak "s/rs13/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs13_1)/g" initdbi-1.js | ||
|
||
cat initdbi-1.js | ||
mongo 192.168.59.103:27018/test --quiet initdbi-1.js | ||
sleep 3 | ||
|
||
#初始化复制集2 | ||
cp -f initdb.js initdbi-2.js | ||
|
||
sed -i bak "s/rs11/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs21_1)/g" initdbi-2.js | ||
sed -i bak "s/rs12/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs22_1)/g" initdbi-2.js | ||
sed -i bak "s/rs13/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs23_1)/g" initdbi-2.js | ||
#更换复制集名称 | ||
sed -i bak 's/rs1/rs2/g' initdbi-2.js | ||
cat initdbi-2.js | ||
mongo 192.168.59.103:27019/test --quiet initdbi-2.js | ||
sleep 3 | ||
|
||
## 初始化Shard | ||
cp -f initdbs.js initdbi.js | ||
|
||
sed -i bak "s/rs11/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs11_1)/g" initdbi.js | ||
sed -i bak "s/rs21/$(docker inspect -f '{{.NetworkSettings.IPAddress}}' mymongodb_rs21_1)/g" initdbi.js | ||
cat initdbi.js | ||
mongo 192.168.59.103:27017/admin --quiet initdbi.js | ||
|
||
## |
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,4 @@ | ||
#!/usr/bin/env bash | ||
sh datadir.sh | ||
fig stop && fig rm --force && fig up -d &&fig ps | ||
sh initdb.sh |