AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / user-268006

pyramid13's questions

Martin Hope
pyramid13
Asked: 2018-07-07 21:37:47 +0800 CST

ansible e esperar problema

  • 0

Eu quero usar as ferramentas de espera no script bash por ansible. primeiro, passo meu script de shell. Verificando a $JAVA_HOMEvariável. Eu configurei, $JAVA_HOMEmas no Ansible, recebo um erro.

Meu envpara $JAVA_HOME:

[root@portal bin]# env | grep JAVA
JAVA_HOME=/usr/java/jdk1.8.0_161

e minha concha:

#!/usr/bin/expect -f

set timeout 1    
spawn /opt/install.sh

expect  "\[input\] Are you installing the application at the central data center? \[yes/no default: yes\]? \[yes\]\r"
send    "yes\r"

expect  "\[input\] What is the code of central data center \[default: 01\]? \[01\]\r"
send    "01\r"

expect  "What is ip or hostname of your server \[default: localhost\]? \[localhost\]\r"
send     "portal\r"

minha cartilha:

- name: --- run portal expect ---
  shell: |
    cd /opt/
    chmod +x portal
    ./portal

Finalmente Erro no Ansible:

TASK [ansible-portal : --- run portal expect ---]
****************************************************************************************************
fatal: [portal]: FAILED! => {"changed": true, "cmd": "cd /opt/installer/bin/\n chmod +x portal\n ./portal", "delta": "0:00:00.015509", "end": "2018-07-07 14:01:57.971794",
"msg": "non-zero return code", "rc": 1, "start": "2018-07-07 14:01:57.956285", "stderr": "send: spawn id exp6 not open\n    
while executing\n\"send    \"yes\\r\"\"\n    (file \"./portal\" line 8)", "stderr_lines": ["send: spawn id exp6 not open", "    
while executing", "\"send    \"yes\\r\"\"", "    (file \"./portal\" line 8)"], "stdout": "spawn /opt/installer/bin/install.sh\r\nChecking input tasks\r\nSetting 
ANT_HOME\r\nChecking Java\r\nError: No JAVA_HOME is set", "stdout_lines": 
["spawn /opt/installer/bin/install.sh", "Checking input tasks", "Setting ANT_HOME",
 "Checking Java", "Error: No JAVA_HOME is set"]}

Não há problema ao executar o script como de costume.

shell-script shell
  • 1 respostas
  • 2517 Views
Martin Hope
pyramid13
Asked: 2018-05-19 22:44:26 +0800 CST

Verifique se algum valor é zero usando jq e retorne 0 para o shell script de chamada

  • 3

Eu tenho este arquivo JSON:

{ "key11":1010, "key12":12120, "key13":12103 }

Como posso usar jqpara verificar se algum dos valores correspondentes a a key[0-9][0-9]é zero, fazendo com que jqsaia com sucesso se algum for e não o contrário?

Eu tenho esse script de uma pergunta anterior

#!/bin/bash
json=$(cat <<EOF
{"key11":12120,"key11_":13,"key11_yes":12107,
"key12":13492,"key12_no":9,"key12_yes":13483,
"key13":10200,"key13_no":9,"key13_yes":10191,
"key21":16756,"key21_no":30,"key21_yes":16726,
"key22":17057,"key22_no":34,"key22_yes":17023,
"key23":16798,"key23_no":25,"key23_yes":16773,
"key31":2733,"key31_yes":2733,
"key32":2561,"key32_yes":2561,
"key33":2570,"key33_yes":2570}
EOF
)
json2=$(echo ${json}|jq 'with_entries(if (.key|test("key[0-9][0-9]$")) then ( {key: .key, value: .value } ) else empty end )')

O resultado é:

{ "key11": 12120, "key12": 13492, "key13": 10200, "key21": 16756, "key22": 17057, "key23": 16798, "key31": 2733, "key32": 2561, "key33": 2570 }

Agora, quero verificar o valor anexado a todas as chaves $json2e, se o valor de qualquer uma das entradas for zero, retorne 0.

shell-script json
  • 1 respostas
  • 10936 Views
Martin Hope
pyramid13
Asked: 2018-03-07 07:46:05 +0800 CST

saída while loop no script bash

  • 0

Tenho ipsarquivo com conteúdo:

192.168.10.10 3306
192.168.10.20 3306

e meu roteiro é:

1 #!/bin/bash
  2
  3 p=0
  4 cat /root/ips | while read host port
  5  do
  6    check_up=$(bash -c 'exec 3<> /dev/tcp/'$host'/'$port';echo $?' 2>/dev/null)
  7     if [ $check_up != 0 ]
  8         then
  9           p=$[$p+1]
 10           echo "(1):p in loop = $p"
 11     fi
 12         echo "(2):p in loop = $p"
 13  done
 14      echo "(3):p out loop = $p"
 15
 16     if [ $p % 2 != 0 ]
 17        then
 18             exit 1
 19      fi
~

e saída é:

[root@db1 ~]# ./new-script.sh
(1):p in loop = 1
(2):p in loop = 1
(1):p in loop = 2
(2):p in loop = 2
(3):p out loop = 0
./new-script.sh: line 16: [: too many arguments

por que echo "(3):p out loop = $p"retornar 0(primeiro valor $p)!? quando o último valor $pé 2? também, como corrigir o erro na linha 16?

shell-script shell
  • 1 respostas
  • 304 Views
Martin Hope
pyramid13
Asked: 2018-02-13 04:52:51 +0800 CST

valor separador da variável de fato em ansible

  • 0

Eu recebo conexão ssh da variável de fato de fato.

meu código no modelo (get-ip.j2):

nod= {{ ansible_env.SSH_CONNECTION }}

minha saída é:

nod= 192.168.231.115 55414 192.168.231.91 22

Agora, como posso separar 192.168.231.91disso?

ansible template
  • 1 respostas
  • 825 Views
Martin Hope
pyramid13
Asked: 2018-01-25 05:03:23 +0800 CST

erro zabbix_sender

  • 0

Qual é o significado desse erro?

[root@db2 zabbix]# zabbix_sender -z zabbix -s zabbix -k mysql[Threads_running] -o 100 -vv               
zabbix_sender [55944]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 1; total: 1; seconds spent: 0.000015"}]
info from server: "processed: 0; failed: 1; total: 1; seconds spent: 0.000015"
sent: 1; skipped: 0; total: 1
[root@db2 zabbix]# 

Além disso , este link explico completamente minha configuração e problemas.

perl mysql
  • 1 respostas
  • 1886 Views
Martin Hope
pyramid13
Asked: 2018-01-03 02:16:14 +0800 CST

Não foi possível localizar o compilador Javac em.ZKUI

  • 2

Quero instalar o zkui no centos 7.1, mas tenho esse erro.

[root@server-1 zkui]# mvn clean install
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building zkui 2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ zkui ---
[INFO] Deleting /root/zkui/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ zkui ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 29 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ zkui ---
[INFO] Compiling 20 source files to /root/zkui/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre/../lib/tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.680 s
[INFO] Finished at: 2018-01-02T08:17:00-05:00
[INFO] Final Memory: 11M/102M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project zkui: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR]   /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Versão do mvn:

[root@server-1 zkui]# mvn -v
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T03:58:13-04:00)
Maven home: /usr/local/maven3
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-229.el7.x86_64", arch: "amd64", family: "unix"

Também meu JAVA_HOME:

[root@server-1 zkui]# echo $JAVA_HOME  
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64/jre
java maven
  • 2 respostas
  • 1558 Views
Martin Hope
pyramid13
Asked: 2018-01-01 06:55:35 +0800 CST

WARN Nenhum anexo foi encontrado para logger (org.apache.zookeeper.ZooKeeper)

  • 1

Eu instalo o zookeeper neste caminho /opt/zookeeper.

meu zoo-1.cfgem /opt/zookeeper/conf/:

#Node1
 dataDir=/var/zookeeper/data-1
 clientPort=2181
 server.1=127.0.0.1:2888:3888
 server.2=127.0.0.1:2889:3889
 server.3=127.0.0.1:2890:3890

meu log4j.propertiesem /opt/zookeeper/conf/:

zookeeper.root.logger=DEBUG, SYSLOG8
log4j.rootLogger=${zookeeper.root.logger}
zookeeper.log.dir=/var/log/zookeeper
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=.
zookeeper.tracelog.file=zookeeper_trace.log
#-------------------------------------------------
log4j.appender.SYSLOG8=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG8.threshold=DEBUG
log4j.appender.SYSLOG8.syslogHost=192.168.26.16
log4j.appender.SYSLOG8.facility=USER
log4j.appender.SYSLOG8.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG8.layout.conversionPattern=[%p] %c:%L - %m$

Quando quero me conectar com um cliente, recebo este erro:

[root@server-1 bin]# sh zkCli.sh -server 127.0.0.1:2182
log4j:ERROR Could not find value for key log4j.appender.CONSOLE
log4j:ERROR Could not instantiate appender named "CONSOLE".
Connecting to 127.0.0.1:2182
log4j:WARN No appenders could be found for logger 
(org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for 
more info.
Welcome to ZooKeeper!
JLine support is enabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2182(CONNECTED) 0] 

meu rsyslog.cnf:

$ModLoad imudp
$UDPServerRun 514
$ModLoad imtcp
$InputTCPServerRun 514
*.*  @192.168.26.16:514

Explique o motivo do erro. Além disso, o que precisa ser feito para registrar os logs do zookeeper no syslog? Obrigado.

logs rsyslog
  • 2 respostas
  • 5373 Views

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Possível firmware ausente /lib/firmware/i915/* para o módulo i915

    • 3 respostas
  • Marko Smith

    Falha ao buscar o repositório de backports jessie

    • 4 respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    user12345 Falha ao buscar o repositório de backports jessie 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl Por que a maioria dos exemplos do systemd contém WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST

Hot tag

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve