[root@centos6 ~]# salt-key Accepted Keys: Denied Keys: Unaccepted Keys: centos6.6-mupan minion.saltstack.com Rejected Keys: [root@centos6 ~]# salt-key -a minion.saltstack.com ####允许客户端连入服务器。 The following keys are going to be accepted: Unaccepted Keys: minion.saltstack.com Proceed? [n/Y] y Key for minion minion.saltstack.com accepted. [root@centos6 ~]#
salt '*' test.ping salt '*.example.net' test.ping salt '*.example.*' test.ping salt 'web?.example.net' test.ping salt 'web[1-5]' test.ping salt 'web[1,3]' test.ping salt 'web-[x-z]' test.ping
[root@master files]# salt '*' state.highstate agent.niu.com: Data failed to compile: ---------- Rendering SLS init.limit failed, render error: expected '<document start>', but found '<block mapping start>' in "<unicode string>", line 2, column 1: limit-conf-config: ^ Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/salt/state.py", line 2509, in render_state sls, rendered_sls=mods File "/usr/lib/python2.7/site-packages/salt/template.py", line 79, in compile_template ret = render(input_data, saltenv, sls, **render_kwargs) ▽ File "/usr/lib/python2.7/site-packages/salt/renderers/yaml.py", line 50, in render data = load(yaml_data, Loader=get_yaml_loader(argline)) File "/usr/lib64/python2.7/site-packages/yaml/__init__.py", line 71, in load return loader.get_single_data() File "/usr/lib64/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data node = self.get_single_node() File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 39, in get_single_node if not self.check_event(StreamEndEvent): File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 98, in check_event self.current_event = self.state() File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 174, in parse_document_start self.peek_token().start_mark) ParserError: expected '<document start>', but found '<block mapping start>' in "<unicode string>", line 2, column 1: limit-conf-config: ^
解决办法:
配置文件的路径配置错误。导致报错。修改配置文件,问题解决。
报错:saltstack 执行后CPU占用率为百分之百。
1 2
[root@10-10-121-200 ~]# salt 'linux-backup-saltminion' test.ping Salt request timed out. The master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
解决办法:
使用top 查看CPU占用率为百分之百。 降低salt的线程数。
报错:配置完return后,不能向数据库写入数据:
1 2
mysql> select * from salt_returns; Empty set (0.00 sec)
解决思路:
当遇到问题是可以将log的级别更改为debug模式来调试。
解决办法:
因为是客户端直接返回给数据库,所有客户端需要数据库的连接权限。顾所有数据库都需要添加如下内容:
1 2 3 4 5 6 7 8 9 10 11
vim /etc/salt/minion mysql.host: '192.168.2.150' mysql.user: 'salt' mysql.pass: 'salt' mysql.db: 'salt' mysql.port: 3306 [root@centos6 ~]# /etc/init.d/salt-minion restart Stopping salt-minion daemon: [ OK ] Starting salt-minion daemon: [ OK ] [root@centos6 ~]#
报错: 执行state.sls 报错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
root@10.10.121.200 files]# salt '*.service' state.sls ssh.config env=prod chuye.backup1.service: Data failed to compile: ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary chuye.logstash1.service: Data failed to compile: ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary chuye.logstash2.service: Data failed to compile: ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary ---------- Requisite declaration file.sshd-files in SLS ssh.config is not formed as a single key dictionary
Options: -f, --file FILE Specify an alternate compose file (default: docker-compose.yml) -p, --project-name NAME Specify an alternate project name (default: directory name) --verbose Show more output -v, --version Print version and exit -H, --host HOST Daemon socket to connect to
--tls Use TLS; implied by --tlsverify --tlscacert CA_PATH Trust certs signed only by this CA --tlscert CLIENT_CERT_PATH Path to TLS certificate file --tlskey TLS_KEY_PATH Path to TLS key file --tlsverify Use TLS and verify the remote --skip-hostname-check Don't check the daemon's hostname against the name specified in the client certificate (for example if your docker host is an IP address)
Commands: build Build or rebuild services bundle Generate a Docker bundle from the Compose file config Validate and view the compose file create Create services down Stop and remove containers, networks, images, and volumes events Receive real time events from containers exec Execute a command in a running container help Get help on a command kill Kill containers logs View output from containers pause Pause services port Print the public port for a port binding ps List containers pull Pulls service images push Push service images restart Restart services rm Remove stopped containers run Run a one-off command scale Set number of containers for a service start Start services stop Stop services unpause Unpause services up Create and start containers version Show the Docker-Compose version information
[root@linux kafka]# docker-compose up -d Creating kafka_zk_1 Creating kafka_kafka_1
4、查看运行的服务
1 2 3 4 5 6
[root@linux kafka]# docker-compose ps Name Command State Ports -------------------------------------------------------------- kafka_kafka_1 bin/kafka-server-start.sh ... Up kafka_zk_1 bin/zookeeper-server-start ... Up [root@linux kafka]#
#### 获取容器Id docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4e52a6a5db69 kafka:v1 "bin/zookeeper-server" 2 hours ago Up About an hour kafka_zk_1 446cd224ed6f kafka:v1 "bin/kafka-server-sta" 2 hours ago Exited (1) About an hour ago kafka_kafka_1 #### 获取完整得ID值 [root@linux src]# docker inspect -f '{{.ID}}' 446cd224ed6f 446cd224ed6f5d6fd14a65f80264156c074bd2cf9af34910d7123b7dda1d3926 #### 拷贝文件到容器中 cp /data/scripts/docker_in.sh /var/lib/docker/devicemapper/mnt/446cd224ed6f5d6fd14a65f80264156c074bd2cf9af34910d7123b7dda1d3926/rootfs/root
编写docker file
1 2 3 4 5 6 7 8 9 10
FROM #指定基础镜像 MAINTAINER #镜像的作者 RUN #在shell或者exec的环境中执行的命令。 ADD #docker镜像中添加文件。 WORKDIR #指定RUN,CMD,ENTERPOINT命令的工作目录。 VOLUME #授权访问物理机的目录 EXPOSE#指定容器运行时的监听端口。 CMD #提供容器默认的执行命令。 ENV #设置环境变量。 USER # 给镜像设置一个UID。
cd /data/dockerfile/nginx/ vim Dockerfile ##首字母必须大小 # this is my first Dockerfile #Version 1.0 #Author: niuhengbo #Base images From centos #MAINTAINER MAINTAINER biglittleant #ADD ADD nginx-1.10.1.tar.gz /usr/local/src #RUN RUN yum install -y wget gcc gcc-c++ make openssl-devel pcre pcre-devel RUN useradd -s /sbin/nologin -M www #WORKDIR WORKDIR /usr/local/src/nginx-1.10.1 RUN ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module &&make && make install RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
解决办法:
1 2
[root@localhost ~]# vim /etc/sysconfig/docker-storage DOCKER_STORAGE_OPTIONS="--storage-opt dm.no_warn_on_loop_devices=true"
File "1.py", line 6, in <module> tar = tarfile.open("sample.tar.gz", "w:gz") File "/usr/local/python3/lib/python3.5/tarfile.py", line 1580, inopen return func(name, filemode, fileobj, **kwargs) File "/usr/local/python3/lib/python3.5/tarfile.py", line 1624, in gzopen raise CompressionError("gzip module is not available") tarfile.CompressionError: gzip module isnot available