docker
Posted kuailewangzi1212
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker相关的知识,希望对你有一定的参考价值。
git常用
git clone https://github.com/kuailewangzi1212/WeApp-Demo.git
查看令牌
docker swarm join-token manager
节点升级manager
docker node promote docker-118
节点降级为worker
docker node demote docker-118
----------linux常用命令
复制文件 cp a.txt b.txt
复制文件夹 cp -r a b
---------从现有镜像中创建image
--在原有的image上新建一个tag是svc的镜像
docker tag imageid docker.codedev.top:88/nginx:svc
--将容器提交为镜像
docker commit -a "[email protected]" -m "add cert files" f890096bfc87 docker.codedev.top:88/nginx:svc1.2
--将镜像提交
docker push docker.codedev.top:88/nginx:svc1.2
------------nginx部署
docker service create --name nginxhost -p 80:80 -p 443:443 --network wl-network docker.codedev.top:88/nginx:svc1.2
docker service update --mount-add type=bind,source=/home/conf/ng,destination=/home/source nginxhost
----------信息记录
112.16.93.184:23389 端口3389外网为23389,6025、6026
Linux设置端口转发:-----------------------------------------------------------------------------------------------
https://blog.csdn.net/gobitan/article/details/50696641
编辑/etc/sysctl.conf文件,将net.ipv4.ip_forward=1前面的#注释去掉,保存文件,然后执行sudo sysctl -p使其生效
场景三:在外网直接访问内网的mysql数据库
案例:很多时候数据库在内网机,外网不能直接访问,但做运维的时候可能需要通过图形界面工具直接连上去。做端口映射就可以解决这个问题。例如:将外网机192.168.2.61的3001端口转发到内网机192.168.2.70的MySQL的3306端口
sudo iptables -t nat -A PREROUTING -d 172.22.31.25 -p tcp --dport 21433 -j DNAT --to-destination 172.22.32.12:1433
sudo iptables -t nat -A POSTROUTING -d 172.22.32.12 -p tcp --dport 1433 -j SNAT --to 172.22.31.25
查看端口转发列表信息的指令
iptables -t nat --list 检查nat列表信息:
删除一个端口转发的指令
iptables -t nat -D PREROUTING 2 //序号从1开始,一定小心要删除错误了
-----------------------------------------------------------------
linux创建用户
--创建用户
sudo useradd -d /home/test test
--修改密码
sudo passwd test
---git----------------------
---工作区-----(git add .)----->暂存区---(git commit -m ‘memo‘)-->本地版本库----(git push)--->远程版本库
--删除暂存区
git rm -rf --cached 文件名
--例如:git rm -rf --cached */target/*
--压缩、解压
压缩:tar -czf sgmw02.bak.tar.gz sgmw02.bak
解压缩:tar -xzf sgmw.bak.tar.gz
----------------
--查询锁表
----------------
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName
from sys.dm_tran_locks where resource_type=‘OBJECT‘
order by request_session_id
SELECT TOP 20
[session_id],
[request_id],
[start_time] AS ‘开始时间‘,
[status] AS ‘状态‘,
[command] AS ‘命令‘,
dest.[text] AS ‘sql语句‘,
DB_NAME([database_id]) AS ‘数据库名‘,
[blocking_session_id] AS ‘正在阻塞其他会话的会话ID‘,
[wait_type] AS ‘等待资源类型‘,
[wait_time] AS ‘等待时间‘,
[wait_resource] AS ‘等待的资源‘,
[reads] AS ‘物理读次数‘,
[writes] AS ‘写次数‘,
[logical_reads] AS ‘逻辑读次数‘,
[row_count] AS ‘返回结果行数‘
FROM sys.[dm_exec_requests] AS der CROSS APPLY sys.[dm_exec_sql_text](der.[sql_handle]) AS dest
WHERE [session_id] =64 AND DB_NAME(der.[database_id]) = ‘sgmw_dp‘
ORDER BY [cpu_time] DESC
SELECT wt.blocking_session_id AS BlockingSessesionId ,
sp.program_name AS ProgramName ,
COALESCE(sp.LOGINAME, sp.nt_username) AS HostName ,
ec1.client_net_address AS BlockedClientIpAddress ,
ec2.client_net_address AS BlockingClientIpAddress ,
db.name AS DatabaseName ,
wt.wait_type AS WaitType ,
ec1.connect_time AS BlockingStartTime ,
wt.WAIT_DURATION_MS / 1000 AS WaitDuration ,
ec1.session_id AS BlockedSessionId ,
h1.TEXT AS BlockedSQLText ,
h2.TEXT AS BlockingSQLText ,
getdate() as dt
FROM sys.dm_tran_locks AS tl
INNER JOIN sys.databases db ON db.database_id = tl.resource_database_id
INNER JOIN sys.dm_os_waiting_tasks AS wt ON tl.lock_owner_address = wt.resource_address
INNER JOIN sys.dm_exec_connections ec1 ON ec1.session_id = tl.request_session_id
INNER JOIN sys.dm_exec_connections ec2 ON ec2.session_id = wt.blocking_session_id
LEFT OUTER JOIN master.dbo.sysprocesses sp ON SP.spid = wt.blocking_session_id
CROSS APPLY sys.dm_exec_sql_text(ec1.most_recent_sql_handle) AS h1
CROSS APPLY sys.dm_exec_sql_text(ec2.most_recent_sql_handle) AS h2;
-----------------------------------
SELECT
DB_NAME(Blocked.database_id) AS ‘database‘,
Blocked.Session_ID AS ‘blocked SPID‘,
Blocked_SQL.TEXT AS ‘blocked SQL‘,
Waits.wait_type AS ‘wait resource‘,
Blocking.Session_ID AS ‘blocking SPID‘,
Blocking.client_net_address,
Blocking_SQL.TEXT AS ‘blocking SQL‘,
sess.status AS ‘blocking status‘,
sess.total_elapsed_time AS ‘blocking elapsed time‘,
sess.logical_reads AS ‘blocking logical reads‘,
sess.memory_usage AS ‘blocking memory usage‘,
sess.cpu_time AS ‘blocking cpu time‘,
sess.program_name AS ‘blocking program‘,
GETDATE() AS ‘timestamp‘
FROM sys.dm_exec_connections AS Blocking
INNER JOIN sys.dm_exec_requests AS Blocked ON Blocked.Blocking_Session_ID = Blocking.Session_ID
INNER JOIN sys.dm_os_waiting_tasks AS Waits ON waits.Session_ID = Blocked.Session_ID
INNER JOIN sys.dm_exec_sessions sess ON sess.session_id = Blocking.Session_ID
CROSS APPLY sys.dm_exec_sql_text(Blocking.most_recent_sql_handle) AS Blocking_SQL
CROSS APPLY sys.dm_exec_sql_text(Blocked.sql_handle) AS Blocked_SQL
---https://www.cnblogs.com/datazhang/p/4773823.html
------------------------------------
select *
from
(
SELECT
est.text AS batchtext,
SUBSTRING(est.text, (eqs.statement_start_offset / 2) + 1,
(CASE eqs.statement_end_offset
WHEN -1
THEN DATALENGTH(est.text)
ELSE eqs.statement_end_offset END -
((eqs.statement_start_offset / 2) + 1))) AS querytext,
eqs.creation_time,
eqs.last_execution_time,
eqs.execution_count,
eqs.total_worker_time,
eqs.last_worker_time,
eqs.min_worker_time,
eqs.max_worker_time,
eqs.total_physical_reads,
eqs.last_physical_reads,
eqs.min_physical_reads,
eqs.max_physical_reads,
eqs.total_elapsed_time,
eqs.last_elapsed_time,
eqs.min_elapsed_time,
eqs.max_elapsed_time,
eqs.total_logical_writes,
eqs.last_logical_writes,
eqs.min_logical_writes,
eqs.max_logical_writes,
eqs.query_plan_hash,
total_rows,
min_rows,
max_rows
FROM
sys.dm_exec_query_stats AS eqs
CROSS APPLY sys.dm_exec_sql_text(eqs.sql_handle) AS est
) a
where a.querytext like ‘select%‘
ORDER BY total_worker_time DESC
--执行最慢的SQL语句
SELECT
(total_elapsed_time / execution_count)/1000 N‘平均时间ms‘
,total_elapsed_time/1000 N‘总花费时间ms‘
,total_worker_time/1000 N‘所用的CPU总时间ms‘
,total_physical_reads N‘物理读取总次数‘
,total_logical_reads/execution_count N‘每次逻辑读次数‘
,total_logical_reads N‘逻辑读取总次数‘
,total_logical_writes N‘逻辑写入总次数‘
,execution_count N‘执行次数‘
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) N‘执行语句‘
,creation_time N‘语句编译时间‘
,last_execution_time N‘上次执行时间‘
FROM
sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
WHERE
SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) not like ‘%tch%‘
ORDER BY
total_elapsed_time / execution_count DESC;
--总耗CPU最多的前个SQL
SELECT TOP 20
total_worker_time/1000 AS [总消耗CPU 时间(ms)],execution_count [运行次数],
qs.total_worker_time/qs.execution_count/1000 AS [平均消耗CPU 时间(ms)],
last_execution_time AS [最后一次执行时间],max_worker_time /1000 AS [最大执行时间(ms)],
SUBSTRING(qt.text,qs.statement_start_offset/2+1,
(CASE WHEN qs.statement_end_offset = -1
THEN DATALENGTH(qt.text)
ELSE qs.statement_end_offset END -qs.statement_start_offset)/2 + 1)
AS [使用CPU的语法], qt.text [完整语法],
qt.dbid, dbname=db_name(qt.dbid),
qt.objectid,object_name(qt.objectid,qt.dbid) ObjectName
FROM sys.dm_exec_query_stats qs WITH(nolock)
CROSS apply sys.dm_exec_sql_text(qs.sql_handle) AS qt
WHERE execution_count>1
ORDER BY total_worker_time DESC
--平均耗CPU最多的前个SQL
SELECT TOP 20
total_worker_time/1000 AS [总消耗CPU 时间(ms)],execution_count [运行次数],
qs.total_worker_time/qs.execution_count/1000 AS [平均消耗CPU 时间(ms)],
last_execution_time AS [最后一次执行时间],min_worker_time /1000 AS [最小执行时间(ms)],
max_worker_time /1000 AS [最大执行时间(ms)],
SUBSTRING(qt.text,qs.statement_start_offset/2+1,
(CASE WHEN qs.statement_end_offset = -1
THEN DATALENGTH(qt.text)
ELSE qs.statement_end_offset END -qs.statement_start_offset)/2 + 1)
AS [使用CPU的语法], qt.text [完整语法],
qt.dbid, dbname=db_name(qt.dbid),
qt.objectid,object_name(qt.objectid,qt.dbid) ObjectName
FROM sys.dm_exec_query_stats qs WITH(nolock)
CROSS apply sys.dm_exec_sql_text(qs.sql_handle) AS qt
WHERE execution_count>1
ORDER BY (qs.total_worker_time/qs.execution_count/1000) DESC
---------------
SELECT *,ec1.client_net_address FROM
[Master].[dbo].[SYSPROCESSES] as der
INNER JOIN sys.dm_exec_connections ec1 ON ec1.session_id = der.spid
CROSS APPLY sys.[dm_exec_sql_text](der.[sql_handle]) AS dest
where DB_NAME(der.dbid) = ‘sgmw_dp‘
ORDER BY [cpu] DESC
---------------------------------------------------------------------------------------
ubuntu扩容 参考:https://www.aliyun.com/jiaocheng/128522.html
步骤如下:
1:fdisk -l
2:fdisk /dev/vdb新
3:m--提示命令
4:g--格式化为gpt
5:n--新建分区
6:e--扩展
7:回车
8:回车
9:w
10:shutdown -r now-启动
11:mkfs.ext3 /dev/vdb新 --格式化
12:mkdir data --根目录上创建一个文件夹,用于挂载磁盘
13:mount /dev/vdb新 /data --挂载磁盘
14:df -h可以查看到磁盘
15:vi /etc/fstab --配置到此文件里,系统重启,自动挂载
----------------------------------------------------------------
----------------
flink部署
--https://hub.docker.com/_/flink?tab=description
--指令:docker-compose up -d
以上是关于docker的主要内容,如果未能解决你的问题,请参考以下文章