首页 文章 精选 留言 我的

精选列表

搜索[主数据平台],共10000篇文章
优秀的个人博客,低调大师

Docker自动化双主MySQL-01:安装docker并使用docker 获取镜像

nstall with yum1.shell>sudo yum update2.添加dockeryum$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'[dockerrepo]name=Docker Repositorybaseurl=https://yum.dockerproject.org/repo/main/centos/7/enabled=1gpgcheck=1gpgkey=https://yum.dockerproject.org/gpgEOF 3.安装docker的包shell>sudo yum install docker-engine4.将docker加到服务里面$ sudo systemctl enable docker.service5.启动docker$ sudo systemctl start docker6.在容器中运行镜像看docker是否安装成功 $ sudo docker run --rm hello-world 二、使用docker 获取镜像:1.查看docker是否运行:[root@localhost ~]# ps aux | grep dockerroot 8229 1.6 0.6 944968 49924 ? Ssl 10:54 0:13 /usr/bin/dockerdroot 8235 0.0 0.1 367832 12216 ? Ssl 10:54 0:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runcroot 8827 0.0 0.0 112652 960 pts/1 S+ 11:07 0:00 grep --color=auto docker2.使用docker获取镜像: 可以使用 docker pull 命令来从仓库获取所需要的镜像 [root@localhost ~]#docker pull centos[root@localhost ~]# docker images 有哪些镜像REPOSITORY TAG IMAGE ID CREATED SIZEcentos latest 0584b3d2cf6d 6 weeks ago 196.5 MBhello-world latest c54a2cc56cbb 5 months ago 1.848 kB3.查看后台运行docker镜像[root@localhost ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe793eb3f32c2 centos "/bin/bash" 3 minutes ago Up 3 minutes alisql4.进入docker里面[root@localhost ~]# docker exec -it e793eb3f32c2 /bin/bash[root@e793eb3f32c2 /]# 查看容器:[root@localhost opt]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe793eb3f32c2 centos "/bin/bash" 6 hours ago Up 6 hours alisql将容器提交为镜像[root@localhost opt]# docker commit -m "install alisql" -a "wjj" e793eb3f32c2 alisql/m:5.6.32sha256:3dff1697293ac450627ce4d6283c215315dcef3256d00206be5cabb831314780 其中, -m 来指定提交的说明信息,跟我们使用的版本控制工具一样; -a 可以指定更新的用户信息;之后是用来创建镜像的容器的 ID;最后指定目标镜像的仓库名和 tag 信息。创建成功后会返回这个镜像的 ID 信息。使用 docker images 来查看新创建的镜像。 [root@localhost opt]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEalisql/m 5.6.32 3dff1697293a About a minute ago 2.181 GB 之后,可以使用新的镜像来启动容器 导出镜像:[root@localhost opt]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEalisql_m 5.6.32 e1b266255ad5 2 minutes ago 2.181 GB 3dff1697293a 8 minutes ago 2.181 GB 53c6ea2f5444 30 minutes ago 5.117 GBcentos latest 0584b3d2cf6d 6 weeks ago 196.5 MBhello-world latest c54a2cc56cbb 5 months ago 1.848 kB [root@localhost docker_images]# docker save -o alisql_m.tar alisql/m:5.6.32[root@localhost docker_images]# docker save -o alisql_s.tar alisql/s:5.6.32 save opt/alisql_m.tar的意思是把image 保存在opt目录里并命令为alisql_m.tar 使用新的镜像来启动容器:[root@localhost docker_images]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEalisql/s 5.6.32 f502d6c3c562 3 minutes ago 2.456 GBalisql/m 5.6.32 ee0aea15ad83 4 minutes ago 2.497 GB docker run 就是运行容器的命令,具体格式我们会在后面的章节讲解,我们这里简要的说明一下上面用到的参数-ti:这是两个参数,一个是 -i:交互式操作,一个是 -t 终端。我们这里打算进入 bash 执行一些命令并查看返回结果,因此我们需要交互式终端。使用新的镜像来启动容器:[root@localhost ~]# docker run -t -i alisql_s:5.6.32 /bin/bash 827 docker ps -a 828 docker rm -f 79cab3e7e30a 829 docker rmi bc9edf41d6b2docker exec -it 容器名 执行脚本或者获取脚本位置 docker build -t ma . [root@localhost docker_mysql_5.6]# docker ps -aq0de7852c69928e3134e3ed0c4cbd4c39e33267f51a8e755b56d33b2836ea88dd6a8cf960d38476a689b658bfe5f40850d5c9fbe08387[root@localhost docker_mysql_5.6]# docker ps -aq | xargs docker rm -f0de7852c69928e3134e3ed0c4cbd4c39e33267f51a8e755b56d33b2836ea88dd6a8cf960d38476a689b658bfe5f40850d5c9fbe08387

优秀的个人博客,低调大师

目前本博主发现,功能最好用,免费的,云主机控制面板

vpsmate 安装需求 操作系统:CentOS/Redhat 5.4 或 5.4 以上版本,32位或64位均可,推荐使用 CentOS 6.2 64位。 内存大小:运行时占用约 20MB 左右的服务器内存。 请使用现代浏览器访问面板(IE8+、Firefox 14+、Chrome 21+),推荐使用 Chrome。 在线安装步骤 使用 SSH 连接工具,如 PuTTY、XShell、SecureCRT 等,连接到您的 Linux 服务器。 执行以下命令开始安装:# wget http://www.vpsmate.org/tools/install.py# python install.py 如下图所示: 安装完成后请设置管理员用户名和密码,如果直接回车,则使用默认的用户名admin和密码admin。 设置完后,打开给定的链接地址即可访问您的 VPSMate 面板。 如下图所示: 本文转自 技术花妞妞 51CTO博客,原文链接: http://blog.51cto.com/xiaogongju/2068328

优秀的个人博客,低调大师

Reroute Unassigned Shards——遇到主shard 出现的解决方法就是重新路由

Red Cluster! 摘自:http://blog.kiyanpro.com/2016/03/06/elasticsearch/reroute-unassigned-shards/ There are 3 cluster states: green: All primary and replica shards are active yellow: All primary shards are active, but not all replica shards are active red: Not all primary shards are active When cluster health is red, it means cluster is dead. And that means you can do nothing until it’s recovered, which is very bad indeed. I will share with you how to deal with one common situation:when cluster is red due to unassigned shards. Steps The general idea is pretty simple: find those shards which are unassigned, manually assign them to a node with reroute API. Let’s see how we can do that step by step. Then we can combine them into a configurable simple script. Step 1: Check Unassigned Shards To get cluster information, we usually use cat APIs. There is aGET /_cat/shardsendpoint to show a detailed view of what nodes contain which shards[1]. Cat shards 1 2 3 4 5 6 7 8 9 # cat shards verbose curl "http://your.elasticsearch.host.com:9200/_cat/shards?v" # cat shards index curl "http://your.elasticsearch.host.com:9200/_cat/shards/wiki2" # example return # wiki2 0 p STARTED 197 3.2mb 192.168.56.10 Stiletto # wiki2 1 p STARTED 205 5.9mb 192.168.56.30 Frankie Raye # wiki2 2 p STARTED 275 7.8mb 192.168.56.20 Commander Kraken By piping cat shards to fgrep, we can get all unassigned shards. Get unassigned shards 1 2 3 4 5 6 # cat shards with fgrep curl "http://your.elasticsearch.host.com:9200/_cat/shards" | fgrep UNASSIGNED # example return # wiki1 0 r UNASSIGNED ALLOCATION_FAILED # wiki1 1 r UNASSIGNED ALLOCATION_FAILED # wiki1 2 r UNASSIGNED ALLOCATION_FAILED If you don’t want to deal with shell script, you can also find these unassigned shards using another endpointPOST /_flush/synced[2]. This endpoint is actually not just some information. It allows an administrator to initiate a synced flush manually. This can be particularly useful for a planned (rolling) cluster restart where you can stop indexing and don’t want to wait the default 5 minutes for idle indices to be sync-flushed automatically. It returns with a json response. _flush/synced 1 curl -XPOST "http://your.elasticsearch.host.com:9200/twitter/_flush/synced" If there are failed shards in the response, we can iterate through a failures array to get all unassigned ones. Example response with failed shards 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 { "_shards": { "total":4, "successful":1, "failed":1 }, "twitter": { "total":4, "successful":3, "failed":1, "failures": [ { "shard":1, "reason":"unexpected error", "routing": { "state":"STARTED", "primary":false, "node":"SZNr2J_ORxKTLUCydGX4zA", "relocating_node":null, "shard":1, "index":"twitter" } } ] } } Step 2: Reroute The reroute command allows to explicitly execute a cluster reroute allocation command including specific commands[3]. An unassigned shard can be explicitly allocated on a specific node. Reroute example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 curl -XPOST 'localhost:9200/_cluster/reroute' -d'{ "commands" : [ { "move" : { "index" : "test", "shard" : 0, "from_node" : "node1", "to_node" : "node2" } }, { "allocate" : { "index" : "test", "shard" : 1, "node" : "node3" } } ] }' There are 3 kinds of commands you can use: move: Move a started shard from one node to another node. Accepts index and shard for index name and shard number, from_node for the node to move the shard from, and to_node for the node to move the shard to. cancel: Cancel allocation of a shard (or recovery). Accepts index and shard for index name and shard number, and node for the node to cancel the shard allocation on. It also accepts allow_primary flag to explicitly specify that it is allowed to cancel allocation for a primary shard. This can be used to force resynchronization of existing replicas from the primary shard by cancelling them and allowing them to be reinitialized through the standard reallocation process. allocate: Allocate an unassigned shard to a node. Accepts the index and shard for index name and shard number, and node to allocate the shard to. It also accepts allow_primary flag to explicitly specify that it is allowed to explicitly allocate a primary shard (might result in data loss). Combining step 2 with the unassigned shards from Step 1, we can reroute all unassigned shards 1 by 1, thus getting faster cluster recovery from red state. Example Solutions Python Below is a python script I wrote usingPOST /_flush/syncedandPOST /reroute Shell Script Below is a shell script I found elsewhere in a blog post[4] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 for shardin $(curl -XGET http://localhost:9200/_cat/shards | grep UNASSIGNED | awk'{print $2}');do curl -XPOST 'localhost:9200/_cluster/reroute' -d'{ "commands" : [ { "allocate" : { "index" : "t37", # index name "shard" : $shard, "node" : "datanode15", # node name "allow_primary" : true } } ] }' sleep 5 done EDIT: Based on Vincent’s comment I updated the shell script: Possible Unassigned Shard Reasons FYI, these are the possible reasons for a shard be in a unassigned state[1]: Name Comment INDEX_CREATED Unassigned as a result of an API creation of an index CLUSTER_RECOVERED Unassigned as a result of a full cluster recovery INDEX_REOPENED Unassigned as a result of opening a closed index DANGLING_INDEX_IMPORTED Unassigned as a result of importing a dangling index NEW_INDEX_RESTORED Unassigned as a result of restoring into a new index EXISTING_INDEX_RESTORED Unassigned as a result of restoring into a closed index REPLICA_ADDED Unassigned as a result of explicit addition of a replica ALLOCATION_FAILED Unassigned as a result of a failed allocation of the shard NODE_LEFT Unassigned as a result of the node hosting it leaving the cluster REROUTE_CANCELLED Unassigned as a result of explicit cancel reroute command REINITIALIZED When a shard moves from started back to initializing, for example, with shadow replicas REALLOCATED_REPLICA A better replica location is identified and causes the existing replica allocation to be cancelled References ElasticSearch Document Cat Shards ElasticSearch Document Synced Flush ElasticSearch Document Cluster Reroute How to fix your elasticsearch cluster stuck in initializing shards mode? 本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/7459408.html,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册