Docker
文章目录
- Docker
- Docker命令
- Linux命令
- 设置代理
- 设置全局代理
- 查看端口
- 查看进程
- 修改apt-get源
- 配置yum源
- Nginx安装
- Docker安装
- Docker Swarm
- Docker命令
- Registry
- Superset安装
- Nacos
- Nacos单机
- Nacos持久化配置
- Nacos集群
- Nginx反向代理
- Portainer
- Mysql
- Neo4j
- Kylin
- canal
- RabbitMQ
- Kafka
- Zookeeper
- Hadoop
- hadoop1
- hadoop2
- GitLab
- hadoop2
- GitLab
Docker命令
进入容器
docker exec -it -u root 64b0988c85d7 /bin/bash
Linux命令
设置代理
export http_proxy=http://10.228.0.116:8080
export https_proxy=https://10.228.0.116:8080
设置全局代理
vi /etc/profile
source /etc/profile
https_proxy=
http_proxy=
ftp_proxy=
export https_proxy
export http_proxy
export ftp_proxy
查看端口
netstat -ntulp | grep cd docker
查看进程
ps -ef
ps -aux
修改apt-get源
cat /etc/apt/sources.list
cp /etc/apt/sources.list /etc/apt/sources.list.bak
echo "" > /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian buster main" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/debian buster-updates main" >> /etc/apt/sources.list
apt-get update -y
配置yum源
1、打开centos的yum文件夹
cd /etc/yum.repos.d/
2、用wget下载repo文件
wget http://mirrors.aliyun.com/repo/Centos-7.repo
或
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
如果wget命令不生效,说明还没有安装wget工具,输入yum -y install wget 回车进行安装。
当前目录是/etc/yum.repos.d/,刚刚下载的Centos-7.repo也在这个目录上
或者
1)安装sz rz工具,用于以后用rz sz上传下载文件
yum install -y lrzsz
2)下载 repo 文件
文件下载地址: http://mirrors.aliyun.com/repo/Centos-7.repo
3)用 rz 将下载的 Centos-7.repo 文件上传到Linux系统的某个目录下
3、备份系统原来的repo文件 即是重命名 CentOs-Base.repo -> CentOs-Base.repo.bak
mv CentOS-Base.repo CentOS-Base.repo.bak
4、替换系统原理的repo文件 即是重命名 Centos-7.repo -> CentOs-Base.repo
mv Centos-7.repo CentOS-Base.repo
5、执行yum源更新命令
yum clean all
yum makecache
yum update -y
Nginx安装
yum -y install gcc
yum install -y pcre pcre-devel
yum install -y pcre pcre-devel
yum install -y pcre pcre-devel
wget http://nginx.org/download/nginx-1.9.9.tar.gz
tar -zxvf nginx-1.9.9.tar.gz
./configure
make
make install
/usr/local/nginx/conf/nginx.conf
./usr/local/nginx/sbin/nginx
ps -ef | grep nginx
Docker安装
export http_proxy=http://10.228.0.116:8080
export https_proxy=https://10.228.0.116:8080
yum update -y
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
创建或修改 /etc/docker/daemon.json 文件,修改为如下形式
# y
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
vi /usr/lib/systemd/system/docker.service
#修改ExecStart为:ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
#重新加载配置文件,重启docker
systemctl daemon-reload
systemctl restart docker.service
docker run hello-world
Job for docker.service failed because the control process exited with error code
创建或修改 /etc/docker/daemon.json 文件,修改为如下形式
{
"exec-root": "/path/to/docker/run",
"storage-driver": "overlay",
"graph": "/path/to/docker/lib"
}
设置代理
mkdir -p /etc/systemd/system/docker.service.d
vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://10.228.0.116:8080"
vi /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTPS_PROXY=https://10.228.0.116:8080"
vi /etc/systemd/system/docker.service.d/no-proxy.conf
[Service]
Environment="NO_PROXY=node2:5000"
Docker Swarm
初始化第一个管理节点
docker swarm init \
--advertise-addr 192.168.142.201:2377 \
--listen-addr 192.168.142.201:2377
列出所有节点
docker node ls
获取token
docker swarm join-token worker
docker swarm join-token manager
worker 接入命令
docker swarm join --token SWMTKN-1-5vck9ibo3j6v5envzhd0frwmw53kkzlctc4w9jxfg1lcdl6inu-cs56h9w04pf237iqelg9zhp0o 192.168.142.201:2377 \
--advertise-addr 192.168.142.205:2377 \
--listen-addr 192.168.142.205:2377
manager 接入命令
docker swarm join --token SWMTKN-1-5vck9ibo3j6v5envzhd0frwmw53kkzlctc4w9jxfg1lcdl6inu-3egz7ubl1q0fwy2iux2og6pkn 192.168.142.201:2377 \
--advertise-addr 192.168.142.203:2377 \
--listen-addr 192.168.142.203:2377
Docker命令
查看容器网络地址
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
创建桥接网络:
docker network create --driver bridge --subnet=172.18.0.0/16 --gateway=172.18.0.1 zookeeper-net
查看网络:
docker network ls
docker network inspect 26b8cbf5b4c9
查看docker空间占用
docker system df
开机自启动
systemctl enable docker
Registry
docker pull registry:2
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --name myregistry registry:2
docker tag nginx:latest localhost:5000/nginx:latest
docker push localhost:5000/nginx:latest
docker pull localhost:5000/nginx:latest
其他节点设置:
vi /etc/docker/daemon.json
{ "insecure-registries":["node2:5000"] }
Superset安装
docker pull amancevice/superset
docker run -d -p 8088:8088 -v /opt/docker/superset:/home/superset --name superset amancevice/superset
进入docker镜像:
docker exec -it superset /bin/bash
数据库初始化:
superset db upgrade
superset初始化:
superset init
设置管理员账号:
export FLASK_APP=superset
flask fab create-admin
/usr/local/lib/python3.8/site-packages/
superset runserver
superset load_examples
mysql+mysqlclient://root:root@localhost:3306/superset
Nacos
Nacos单机
docker pull nacos/nacos-server
docker run --name nacos --restart=always -v /var/run/docker.sock:/var/run/docker.sock -d -p 8848:8848 nacos/nacos-server
用户名密码:nacos/nacos
Nacos持久化配置
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info */
/******************************************/
CREATE TABLE `config_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(255) DEFAULT NULL,
`content` longtext NOT NULL COMMENT 'content',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
`src_user` text COMMENT 'source user',
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
`app_name` varchar(128) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
`c_desc` varchar(256) DEFAULT NULL,
`c_use` varchar(64) DEFAULT NULL,
`effect` varchar(64) DEFAULT NULL,
`type` varchar(64) DEFAULT NULL,
`c_schema` text,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_aggr */
/******************************************/
CREATE TABLE `config_info_aggr` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(255) NOT NULL COMMENT 'group_id',
`datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
`content` longtext NOT NULL COMMENT '内容',
`gmt_modified` datetime NOT NULL COMMENT '修改时间',
`app_name` varchar(128) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_beta */
/******************************************/
CREATE TABLE `config_info_beta` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL COMMENT 'content',
`beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
`src_user` text COMMENT 'source user',
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_tag */
/******************************************/
CREATE TABLE `config_info_tag` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
`tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL COMMENT 'content',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
`src_user` text COMMENT 'source user',
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_tags_relation */
/******************************************/
CREATE TABLE `config_tags_relation` (
`id` bigint(20) NOT NULL COMMENT 'id',
`tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
`tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
`nid` bigint(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`nid`),
UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = group_capacity */
/******************************************/
CREATE TABLE `group_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = his_config_info */
/******************************************/
CREATE TABLE `his_config_info` (
`id` bigint(64) unsigned NOT NULL,
`nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`data_id` varchar(255) NOT NULL,
`group_id` varchar(128) NOT NULL,
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL,
`md5` varchar(32) DEFAULT NULL,
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`src_user` text,
`src_ip` varchar(50) DEFAULT NULL,
`op_type` char(10) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
PRIMARY KEY (`nid`),
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`),
KEY `idx_did` (`data_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = tenant_capacity */
/******************************************/
CREATE TABLE `tenant_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
CREATE TABLE `tenant_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`kp` varchar(128) NOT NULL COMMENT 'kp',
`tenant_id` varchar(128) default '' COMMENT 'tenant_id',
`tenant_name` varchar(128) default '' COMMENT 'tenant_name',
`tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
`create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
`gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
`gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
CREATE TABLE `users` (
`username` varchar(50) NOT NULL PRIMARY KEY,
`password` varchar(500) NOT NULL,
`enabled` boolean NOT NULL
);
CREATE TABLE `roles` (
`username` varchar(50) NOT NULL,
`role` varchar(50) NOT NULL,
UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
);
CREATE TABLE `permissions` (
`role` varchar(50) NOT NULL,
`resource` varchar(255) NOT NULL,
`action` varchar(8) NOT NULL,
UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
);
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
修改conf/application.properties文件
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://172.17.0.3:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=root
Nacos集群
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gegJiWBH-1627015148597)(Docker.assets/1149398-20190903094418578-707914480.png)]
修改cluster.conf
172.17.0.6:8848
172.17.0.7:8848
172.17.0.8:8848
Nginx反向代理
修改/usr/local/nginx/conf/nginx.conf
upstream nacos-cluster {
server 172.17.0.6:8848;
server 172.17.0.7:8848;
server 172.17.0.8:8848;
}
server {
listen 80;
server_name 172.17.0.9;
location / {
proxy_pass http://nacos-cluster;
}
}
Portainer
docker pull portainer/portainer
docker run -d -p 9000:9000 --restart=always --name portainer portainer/portainer
docker run -d -p 1111:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name portainer docker.io/portainer/portainer
vi /usr/lib/systemd/system/docker.service
#修改ExecStart为:ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
#重新加载配置文件,重启docker
systemctl daemon-reload
systemctl restart docker.service
39.105.163.99:9000
Mysql
docker run -d -p 3306:3306 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --name mysql -e MYSQL_ROOT_PASSWORD=root docker.io/mysql:5.7
docker exec -it mysql /bin/bash
Neo4j
docker run -d --name neo4j -p 7474:7474 -p 7687:7687 -e NEO4J_AUTH=neo4j/123456 neo4j:lastest
Kylin
docker pull apachekylin/apache-kylin-standalone:3.1.0
docker run -d -m 8G -p 7070:7070 -p 8088:8088 -p 51111:51111 -p 8032:8032 -p 8042:8042 -p 16010:16010 apachekylin/apache-kylin-standalone:3.1.0
Kylin 页面:http://127.0.0.1:7070/kylin/
Hdfs NameNode 页面:http://127.0.0.1:51111
Yarn ResourceManager 页面:http://127.0.0.1:8088
HBase 页面:http://127.0.0.1:60010
ADMIN/KYLIN
canal
mysql开启binlog
mysql -uroot -proot
SHOW VARIABLES LIKE '%log_bin%';
apt-get update
apt-get -y install vim
vi /etc/my.cnf
加入:
[mysqld]
log-bin=mysql-bin
binlog-format=ROW
server_id=1
create user canal@'%' IDENTIFIED by 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT,SUPER ON *.* TO 'canal'@'%';
FLUSH PRIVILEGES;
docker restart mysql
canal
docker pull canal/canal-server:latest
docker run -p 11111:11111 --name canal -id canal/canal-server
docker exec -it canal /bin/bash
cd /home/admin/canal-server/conf/example
RabbitMQ
docker run --name rabbitmq -p 5672:5672 -p 15672:15672 -d rabbitmq
vim /mydata/canal/conf/canal.properties
### tcp, kafka, rocketMQ, rabbitMQ
canal.serverMode = rabbitMQ
##################################################
######### RabbitMQ #############
##################################################
rabbitmq.host = 121.36.33.154
rabbitmq.virtual.host = /
rabbitmq.exchange = canal.exchange
rabbitmq.username = guest
rabbitmq.password = guest
Kafka
version: '2'
networks:
default:
external:
name: zookeeper_default
services:
kafka1:
image: wurstmeister/kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 10.228.80.163 ## 修改:宿主机IP
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://10.228.80.163:9092 ## 修改:宿主机IP
KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181"
KAFKA_ADVERTISED_PORT: 9092
KAFKA_BROKER_ID: 1
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
container_name: kafka1
kafka2:
image: wurstmeister/kafka
ports:
- "9093:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 10.228.80.163 ## 修改:宿主机IP
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://10.228.80.163:9093 ## 修改:宿主机IP
KAFKA_ZOOKEEPER_CONNECT: "zoo1:2181"
KAFKA_ADVERTISED_PORT: 9093
KAFKA_BROKER_ID: 2
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
container_name: kafka2
kafka-manager: # Kafka 图形管理界面
image: sheepkiller/kafka-manager:latest
restart: unless-stopped
container_name: kafka-manager
hostname: kafka-manager
ports:
- "9111:9000"
environment:
ZK_HOSTS: 10.228.80.163:2181
docker run -d --name kfk-manager --network=zookeeper_default --restart always -p 9111:9000 -e ZK_HOSTS=<10.228.80.163:2181> sheepkiller/kafka-manager
查看kafka版本:
find / -name \*kafka_\* | head -1 | grep -o '\kafka[^\n]*'
#创建topic
docker exec kafka1 \
kafka-topics.sh \
--create --topic topic001 \
--partitions 1 \
--zookeeper zoo1:2181 \
--replication-factor 1
#获取topic列表
kafka-topics.sh --list \
--zookeeper zoo1:2181
#进入kafka消费者
kafka-console-consumer.sh \
--topic topic001 \
--bootstrap-server kafka1:9092,kafka2:9092
进入kafka生产者
kafka-console-producer.sh \
--topic topic001 \
--broker-list kafka1:9092,kafka2:9092
Zookeeper
version: '3'
services:
zoo1:
image: zookeeper
container_name: zoo1
restart: always
hostname: zoo1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
zoo2:
image: zookeeper
container_name: zoo2
restart: always
hostname: zoo2
ports:
- 2182:2181
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=0.0.0.0:2888:3888;2181 server.3=zoo3:2888:3888;2181
zoo3:
image: zookeeper
container_name: zoo3
restart: always
hostname: zoo3
ports:
- 2183:2181
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=0.0.0.0:2888:3888;2181
docker-compose up
Hadoop
hadoop1
docker run -i -t -p 40070:50070 -p 9100:9000 -p 8088:8088 -p 8040:8040 -p 8042:8042 -p 49707:49707 -p 40010:50010 -p 40075:50075 -p 40090:50090 sequenceiq/hadoop-docker:latest /etc/bootstrap.sh -bash
cd /usr/local/hadoop-2.7.0
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.0.jar grep input output 'dfs[a-z.]+'
hadoop2
GitLab
docker run -detach `
--publish 8443:443 --publish 8880:80 --publish 8222:22 `
--name gitlab `
--restart always `
--volume /usr/local/gitlab/config:/etc/gitlab `
--volume /usr/local/gitlab/logs:/var/log/gitlab `
--volume /usr/local/gitlab/data:/var/opt/gitlab `
--privileged=true `
gitlab/gitlab-ce:latest
oop1
docker run -i -t -p 40070:50070 -p 9100:9000 -p 8088:8088 -p 8040:8040 -p 8042:8042 -p 49707:49707 -p 40010:50010 -p 40075:50075 -p 40090:50090 sequenceiq/hadoop-docker:latest /etc/bootstrap.sh -bash
cd /usr/local/hadoop-2.7.0
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.0.jar grep input output 'dfs[a-z.]+'
hadoop2
GitLab
docker run -detach `
--publish 8443:443 --publish 8880:80 --publish 8222:22 `
--name gitlab `
--restart always `
--volume /usr/local/gitlab/config:/etc/gitlab `
--volume /usr/local/gitlab/logs:/var/log/gitlab `
--volume /usr/local/gitlab/data:/var/opt/gitlab `
--privileged=true `
gitlab/gitlab-ce:latest