for i in $(cat file.txt); do
    if rpm -qa | grep -qw $i; then
        echo "$i is installed."
    else
        echo "$i is not installed."
    fi
done

'나는 노동자 > LINUX' 카테고리의 다른 글

ansible extra vars  (0) 2023.02.13
ansible 물리서버, 가성서버 확인  (0) 2023.02.07
ansible facts device check  (0) 2023.02.04
리눅스 임시 포트 오픈  (0) 2023.01.12
xfs volume extend  (0) 2020.07.10



# add host to your ssh known_hosts
ssh server-name-01
#
# note the setup:
# 1. Playbook.yml, 2. -i (inventory), 3. pass common vars, including password vault, 4. pass extra vars, including hostname and environment, 5. unlock the password vault
#
ansible-playbook configure-apt.yml -i "server-name-01," -e @common_vars/common_vars.yml --extra-vars 'env=local variable_host=server-name-01' -v -C --vault-password-file ~/vars/.common.txt

 

 
---
- name: Test Playbook to run a shell command
hosts: "{{ variable_host | default('host-group-name')}}"
become: yes
tasks:
- name: run this command and ignore the result
  shell: /usr/bin/somecommand
  ignore_errors: True
...

Pass the host list as a variable:

hosts: "{{ variable_host | default('web')}}"
 
# command
ansible-playbook server.yml --extra-vars "variable_host=server-name-01"

'나는 노동자 > LINUX' 카테고리의 다른 글

rpm으로 패키지 설치 유무 확인  (0) 2023.05.09
ansible 물리서버, 가성서버 확인  (0) 2023.02.07
ansible facts device check  (0) 2023.02.04
리눅스 임시 포트 오픈  (0) 2023.01.12
xfs volume extend  (0) 2020.07.10
:: 실서버 
# systemd-detect-virt
none

:: 가상서버 
 # systemd-detect-virt
kvm

root@DESKTOP-F4T7TCG:/home/ansible# cat vm.yml
---
- name: test
  hosts: vm
  tasks:
  - name: server check
    shell: systemd-detect-virt
    register: check

  - name: dfasf
    shell: echo " testesrsfd" > /home/ansible/a.txt
    when: '"wsl" in check.stdout'

'나는 노동자 > LINUX' 카테고리의 다른 글

rpm으로 패키지 설치 유무 확인  (0) 2023.05.09
ansible extra vars  (0) 2023.02.13
ansible facts device check  (0) 2023.02.04
리눅스 임시 포트 오픈  (0) 2023.01.12
xfs volume extend  (0) 2020.07.10
- hosts: localhost
  gather_facts: true
  tasks:
    - debug:
        msg: Disk nvme0n1 exists.
      when: "'nvme0n1' in ansible_devices.keys()|list"
    - debug:
        msg: Disk sdb does not exist.
      when: "'sdb' not in ansible_devices.keys()|list"

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_conditionals.html

 

```bash
root@DESKTOP-F4T7TCG:/home/ansible# more disk.yml
---
- name: test disk information check
  hosts: vm
  tasks:
  - name: disk check
    debug:
      msg: "{{ ansible_facts['devices'] }}"
  - name: check True or not
    debug:
      msg: Disk sdb doest not exist
    when: "'sdb' not in ansible_devices.keys()|list"
  - name: check disk not
    copy:
      content: "{{ ansible_facts['devices']['sdb']['size'] }}"
      dest: "/home/{{ansible_fqdn}}-diskinfo.txt"
    delegate_to: localhost
    when: "'sdb' in ansible_devices.keys()| list"

```

 

============

  - name: chel
    shell: |
            echo "
            node_kernel_size(name='{{ ansible_hostname }}')  '{{ ansible_kernel }}'
            node_disk_size(name='{{ ansible_hostname }}')  '{{ ansible_facts.devices.sdb.size }}'
            " >> /home/ansible/info.txt
#      dest: "/home/ansible/{{ansible_fqdn}}-info.txt"
#    delegate_to: localhost
    when: "'sdb' in ansible_devices.keys()| list"

 

=========== prom으로 사용할려면 ========= \"를 앞뒤 추가해줘야한다

 

systemctl restart node_exporter
journalctl -eu node_exporter

 

workshop_student_is_happy{campus="campusX"} 1
curl localhost:9100/metrics
curl -s localhost:9100/metrics | grep workshop

  - name: chel
    shell: |
            echo "
            node_kernel_size{name=\""{{ ansible_hostname }}"\",output=\""{{ ansible_kernel }}"\"} 0
            node_disk_size{name=\""{{ ansible_hostname }}"\",size=\""{{ ansible_facts.devices.sdb.size }}"\"} 0
            " >> /home/ansible/info.txt
#      dest: "/home/ansible/{{ansible_fqdn}}-info.txt"
#    delegate_to: localhost
    when: "'sdb' in ansible_devices.keys()| list"

 

 

==============================================================

----
- name: test disk information check
  hosts: vm
  tasks:
  - name: disk check if yes
    shell: |
         echo "
         node_kernel_size{name=\""{{ ansible_hostname }}"\",output=\""{{ ansible_kernel }}"\",disk=\""{{ ansible_facts.devices.sdb.size}} "\"} 0
         " > /home/ansible/info.txt
#      dest: "/home/ansible/{{ansible_fqdn}}-info.txt"
#    delegate_to: localhost
    when: "'sdb' in ansible_devices.keys()| list"

  - name: disk check if no
    shell: |
         echo "
         node_kernel_size{name=\""{{ ansible_hostname }}"\",output=\""{{ ansible_kernel }}"\",disk=\""0"\"} 0
         " > /home/ansible/info.txt
#      dest: "/home/ansible/{{ansible_fqdn}}-info.txt"
#    delegate_to: localhost
    when: "'sdcxb' not in ansible_devices.keys()| list"                 

 

https://dywang.csie.cyut.edu.tw/dywang/ansible/node132.html                                                                    

'나는 노동자 > LINUX' 카테고리의 다른 글

ansible extra vars  (0) 2023.02.13
ansible 물리서버, 가성서버 확인  (0) 2023.02.07
리눅스 임시 포트 오픈  (0) 2023.01.12
xfs volume extend  (0) 2020.07.10
Log Rate Limitimg in Linux  (0) 2018.09.17

nc 명령어를 사용하여 서버에 임시 포트 오픈 및 확인을 할 수 있다.



서버 1은 임시로 포트를 open

서버 2는 서버1의 오픈된 포트로 접근시도



* 서버1 192.168.10.10

$ nc -lk [port]

예: nc -lk 8080



* 서버2 192.168.20.10

$ nc -v [서버1 IP] [port]

예: nc -v 192.168.10.10 8080

'나는 노동자 > LINUX' 카테고리의 다른 글

ansible 물리서버, 가성서버 확인  (0) 2023.02.07
ansible facts device check  (0) 2023.02.04
xfs volume extend  (0) 2020.07.10
Log Rate Limitimg in Linux  (0) 2018.09.17
repo_download and sync  (0) 2018.04.26

lvextend /dev/mapper~~~ -L +20G
xfs_growfs /var

vgs

vgextend vg /dev/sdc or /dev/sdc1

vg는 vg이름이다

'나는 노동자 > LINUX' 카테고리의 다른 글

ansible facts device check  (0) 2023.02.04
리눅스 임시 포트 오픈  (0) 2023.01.12
Log Rate Limitimg in Linux  (0) 2018.09.17
repo_download and sync  (0) 2018.04.26
linux http_proxy 설정하기 (웹사용을 위해)  (0) 2018.04.19

How To Change Log Rate Limiting In Linux
Posted by Jarrod on March 23, 2016 Leave a comment (0)Go to comments
By default in Linux there are a few different mechanisms in place that may rate limit logging. These are primarily the systemd journal and rsyslog rate limits that are in place by default.

Here we cover modifying or removing rate limiting for logging.


Why Rate Limiting?

Rate limitations on logging are in place to prevent logging from using excessive levels of system resources. To log an event, it needs to be written to disk which uses system resources. If there are too many of these events coming in that need to be recorded to disk they can overwhelm a system and cause more important services to respond slowly or fail.

For this reason it is generally not recommended to completely disable rate limiting, but to tweak it as required. At the same time we do not want to drop important messages that may be required to generate a critical alert, so a balance needs to be found.

Systemd Journal Rate Limiting

How do we know if the journal limits are actually causing us to drop log messages? Generally you will see similar messages in the log files as below.

Jan 9 09:18:07 server1 journal: Suppressed 7124 messages from /system.slice/named.service
In this particular case we have a DNS server running Bind which is logging all DNS queries. 7124 messages were suppressed and dropped (not logged) because they were coming in too fast in this example.

By default systemd allows 1,000 messages within a 30 second period.

The limits are controlled in the /etc/systemd/journald.conf file.

RateLimitInterval=30s
RateLimitBurst=1000
If more messages than the amount specified in RateLimitBurst are received within the time defined by RateLimitInterval, all further messages within the interval are dropped until the interval is over.

You can modify these values as you see fit, you can completely disable systemd journal logging rate limiting by setting both to 0.

If you make any changes to /etc/systemd/journald.conf you will need to restart the systemd-journald service to apply the changes.

systemctl restart systemd-journald
Rsyslog Rate Limiting

The systemd journal limit is hit before any default rsyslog limits as its default limits are smaller. By default rsyslog will accept 20,000 messages within a 10 minute period.

Therefore if you increase the rate limiting of the systemd journal logging as shown above you may then start to receive similar messages in your syslog logs as shown below.

....
Jan 9 22:42:35 server1 rsyslogd-2177: imjournal: begin to drop messages due to rate-limiting
Jan 9 22:51:26 server1 rsyslogd-2177: imjournal: 143847 messages lost due to rate-limiting
...
The first message states that messages will be dropped as the limit has been reached, and once the interval is over (after 10 minutes by default) the amount of messages that were lost due to rate limiting will then be logged.

The limits are controlled in the /etc/rsyslog.conf file.

$ModLoad imjournal
$imjournalRatelimitInterval 600
$imjournalRatelimitBurst 20000
For further information see the imjournal rsyslog documentation.

Again you can modify these values as you like, and they can be completely disabled by setting both to 0.

If you make any changes to the /etc/rsyslog.conf file you will need to restart the rsyslog service to apply the changes.

systemctl restart rsyslog
Summary

As shown we can check our log files to find out if logs are being dropped due to either systemd journal or syslog rate limits. The systemd journal default rate limit is much lower than the syslog default rate limit so it will be triggered first. Once you increase the rate limiting on the systemd journal logging you may then start to experience additional rate limiting by syslog, which can then also be increased if required.

'나는 노동자 > LINUX' 카테고리의 다른 글

리눅스 임시 포트 오픈  (0) 2023.01.12
xfs volume extend  (0) 2020.07.10
repo_download and sync  (0) 2018.04.26
linux http_proxy 설정하기 (웹사용을 위해)  (0) 2018.04.19
CentOS 커널 업그레이드 다운그레이드  (0) 2018.04.19
download repo
and repolist
reposync --repoid=dockerrepo-2 --dlownload_path=/data/RESOURCE/YUMREPO-SOURCE/TEST
tar cf
and then
createrepo DOCKERREPO2


'나는 노동자 > LINUX' 카테고리의 다른 글

xfs volume extend  (0) 2020.07.10
Log Rate Limitimg in Linux  (0) 2018.09.17
linux http_proxy 설정하기 (웹사용을 위해)  (0) 2018.04.19
CentOS 커널 업그레이드 다운그레이드  (0) 2018.04.19
HANA WEB LOGIN  (0) 2018.02.13

우선, 설정값을 확인한다.

[]# echo $http_proxy


만약 아무것도 설정되어 있지 않으면, 프록시 서버의 URI를 설정한다.

[]# export  http_proxy='http://proxy:8080'



만일 인증이 필요한 경우에는 다음과 같이 설정한다.

[]# export  http_proxy='http://username:password@proxy:8080' 



설정 유지를 위하여 아래 파일중 하나에 추가해 두는것도 잊지 말자.

/etc/environment
~/.bashrc
~/.profile 


프록시 변수 값 초기화는 


# unset http_proxy


요렇게 하면 초기화됩니다 


'나는 노동자 > LINUX' 카테고리의 다른 글

Log Rate Limitimg in Linux  (0) 2018.09.17
repo_download and sync  (0) 2018.04.26
CentOS 커널 업그레이드 다운그레이드  (0) 2018.04.19
HANA WEB LOGIN  (0) 2018.02.13
HANA DB START/STOP  (0) 2018.02.12

커널업그레이드를 하기전에 

dhclient 업그레이드를 먼제 해주도록 할께요

dhclient 업그레이드를 하지 않고 커널업그레이드를 할시 인터넷이 안되는 현상이 발생할수 있습니다


#yum list dhclient

#yum instasll dhclient   <-- 업그레이드 가능한 dhclient설치


이제 커널 차례~


#uname -r  <--커널 버젼 확인

# uname -a   <-- 호스트 네임, 커널 버젼 등 확인

#yum list kernel


설치된 커널과 업데이트 가능한 커널이 나옴

Installed Packages

~~~~~~~~~~~~~~~~~~~~~~~~~~

Avaliable Packages

커널 이름                       updates


#yum install kernel   <-- 업그레이드 가능한 커널 설치


완료후 재부팅은 필수


## 다운그레이드 방법 #########

grub.conf를 통한 방법


#vi /etc/grub.conf


default = 0


hiddenmenu

## 바로 하단것이 업그레이드 후 버젼, 0 ###

title CentOS (2.6.32-358~)

   root (hd0,0) 

    kerrnel /vmliuz-2.6.32.358 ~


## 아래 것이 엡그레이드 이전 버전, 1 ####

title CentOS (2.6.32-220~)

  root (hd0,0)

   kernel/vmliuz-2.6.32-220~


해당 파일에서 default 값이 현재 0 업그레이드된 버젼을 가리키고 있으므로

원복하기 위해서는 default값을 1로 변경해주면 된다


이후  리부팅 .. 리부팅후에는 커널 버젼 확인하세요 

'나는 노동자 > LINUX' 카테고리의 다른 글

repo_download and sync  (0) 2018.04.26
linux http_proxy 설정하기 (웹사용을 위해)  (0) 2018.04.19
HANA WEB LOGIN  (0) 2018.02.13
HANA DB START/STOP  (0) 2018.02.12
RHEL7.X NFS MOUNT  (0) 2018.01.18

+ Recent posts