linux部署docker以及常用容器部署
前言
本文主要教大家linux安装部署docker以及常用容器部署
1. docker部署
1.1. 依次运⾏以下命令添加yum源
代码如下
yum update
yum install epel-release -y
yum clean all
yum list
1.2. 安装并运⾏Docker。
代码如下
yum install docker-io -y
systemctl start docker
1.3. 检查安装结果。
代码如下
docker info
1.4. 启动使⽤Docker
代码如下
systemctl start docker #运⾏Docker守护进程
systemctl stop docker #停⽌Docker守护进程
systemctl restart docker #᯿启Docker守护进程
1.5. 修改镜像仓库
代码如下
vim /etc/docker/daemon.json
#改为下⾯内容,然后重启docker
{
"debug":true,"experimental":true,"registry-mirrors":
["https://pb5bklzr.mirror.aliyuncs.com","https:
//hub
mirror.c.163.com","https://docker.mirrors.ustc.
edu.cn"]
}
1.6. 查看信息
代码如下
docker info
2. docker部署mysql
本例子部署的为mysql5.7的版本
代码如下
## start mysql in container
docker run -itd \
--name falcon-mysql \
-v /home/work/mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=test123456 \
-p 3306:3306 \
mysql:5.7
3. dokcer部署redis
代码如下
docker run --name falcon-redis -p6379:6379 -d redis:4-alpine3.8
注意 公网redis 部署的时候要注意端口映射和增加密码 防止黑客恶意伤害redis端口
番外篇:centos7安装源地址http://mirrors.aliyun.com/centos/7/os/x86_64/
4. docker部署open-falcon
代码如下
docker run --name falcon-redis -p6379:6379 -d redis:4-alpine3.8
4.1 Running open-falcon container
4.1.1 Start mysql and init the mysql table before the first running
代码如下
## start mysql in container
docker run -itd \
--name falcon-mysql \
-v /home/work/mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=test123456 \
-p 3306:3306 \
mysql:5.7
## init mysql table before the first running
cd /tmp && \
git clone --depth=1 https://github.com/open-falcon/falcon-plus.git && \
cd /tmp/falcon-plus/ && \
for x in `ls ./scripts/mysql/db_schema/*.sql`; do
echo init mysql table $x ...;
docker exec -i falcon-mysql mysql -uroot -ptest123456 < $x;
done
rm -rf /tmp/falcon-plus/
4.1.2. Start redis in container
代码如下
docker run --name falcon-redis -p6379:6379 -d redis:4-alpine3.8
4.1.3. Start falcon-plus modules in one container
代码如下
## pull images from hub.docker.com/openfalcon
docker pull openfalcon/falcon-plus:v0.3
## run falcon-plus container
docker run -itd --name falcon-plus \
--link=falcon-mysql:db.falcon \
--link=falcon-redis:redis.falcon \
-p 8433:8433 \
-p 8080:8080 \
-e MYSQL_PORT=root:test123456@tcp\(db.falcon:3306\) \
-e REDIS_PORT=redis.falcon:6379 \
-v /home/work/open-falcon/data:/open-falcon/data \
-v /home/work/open-falcon/logs:/open-falcon/logs \
openfalcon/falcon-plus:v0.3
## start falcon backend modules, such as graph,api,etc.
docker exec falcon-plus sh ctrl.sh start \
graph hbs judge transfer nodata aggregator agent gateway api alarm
## or you can just start/stop/restart specific module as:
docker exec falcon-plus sh ctrl.sh start/stop/restart xxx
## check status of backend modules
docker exec falcon-plus ./open-falcon check
## or you can check logs at /home/work/open-falcon/logs/ in your host
ls -l /home/work/open-falcon/logs/
4.1.4 Start falcon-dashboard in container
代码如下
docker run -itd --name falcon-dashboard \
-p 8081:8081 \
--link=falcon-mysql:db.falcon \
--link=falcon-plus:api.falcon \
-e API_ADDR=http://api.falcon:8080/api/v1 \
-e PORTAL_DB_HOST=db.falcon \
-e PORTAL_DB_PORT=3306 \
-e PORTAL_DB_USER=root \
-e PORTAL_DB_PASS=test123456 \
-e PORTAL_DB_NAME=falcon_portal \
-e ALARM_DB_HOST=db.falcon \
-e ALARM_DB_PORT=3306 \
-e ALARM_DB_USER=root \
-e ALARM_DB_PASS=test123456 \
-e ALARM_DB_NAME=alarms \
-w /open-falcon/dashboard openfalcon/falcon-dashboard:v0.2.1 \
'./control startfg'
4.1.5. Start falcon-agent in container
代码如下
sudo docker run -d --restart always --name falcon-agent \
-e NUX_ROOTFS=/rootfs \
-v /:/rootfs:ro \
openfalcon/falcon-plus:v0.3 \
./agent/bin/falcon-agent -c /open-falcon/agent/config/cfg.json
4.2 Building open-falcon images from source code
4.2.1 Building falcon-plus
代码如下
cd /tmp && \
git clone https://github.com/open-falcon/falcon-plus.git && \
cd /tmp/falcon-plus/ && \
docker build -t falcon-plus:v0.3 .
4.2.2 Building falcon-dashboard
代码如下
cd /tmp && \
git clone https://github.com/open-falcon/dashboard.git && \
cd /tmp/dashboard/ && \
docker build -t falcon-dashboard:v0.2.1 .
5. docker 安装部署Prometheus Server
代码如下
docker run -p 9090:9090 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
6. docker 安装部署grafana
代码如下
docker run -d -p 3000:3000 grafana/grafana
总结
以上就是linux安装部署docker以及常用容器部署的全部内容,如果对你有所帮助的话请点个关注,我会不定时更新技术分享,对于文章中内容有问题的地方可以在下面留言,看到我会及时回复。
标签:部署,linux,--,plus,mysql,falcon,docker,open From: https://blog.51cto.com/u_16142959/6740005