Closed ksh0165 closed 4 years ago
apt-get install ufw ufw allow 21/tcp
sudo sed -i 's/archive.ubuntu.com/ftp.daum.net/g' /etc/apt/sources.list rm -rfv /var/lib/apt/lists/ && sed -i 's/# (.multiverse$)/\1/g' /etc/apt/sources.list && apt-get update && apt-get -y upgrade sed -i 's/ftp.daum.net/ftp.neowiz.com/g' /etc/apt/sources.list deb http://archive.ubuntu.com/ubuntu bionic main deb http://archive.ubuntu.com/ubuntu bionic-security main deb http://archive.ubuntu.com/ubuntu bionic-updates main deb http://cz.archive.ubuntu.com/ubuntu bionic main universe
우분투에서 apt-get update 명령어 실행 시 아래와 같이 오류가 발생하며 작동하지 않았다.
lucifer@ubuntu:~$ sudo vi /etc/resolv.conf
rm -rf /var/lib/apt/lists/* -vf
nameserver 8.8.8.8 nameserver 8.8.4.4
root@e21ec52b24c6:/# find / -name "network" /lib/systemd/network /etc/systemd/network /etc/network
root@e21ec52b24c6:/etc/systemd# service webmin restart Stopping Webmin server in /usr/share/webmin Starting Webmin server in /usr/share/webmin
168.124.63.1 systemctl restart network
docker stop [id]
root@e21ec52b24c6:/etc/systemd# service --status-all
root@e21ec52b24c6:/# service webmin stop Stopping Webmin server in /usr/share/webmin root@e21ec52b24c6:/# service webmin start root@e21ec52b24c6:/#
docker 안으로 복사 docker cp sources.list e21ec52b24c6:/root
rm /var/lib/apt/lists/lock apt-get update
/sbin/reboot -f
deb http://mirror.kakao.com/ubuntu/ bionic main restricted
SELECT orderNumber, status, orderDate, requiredDate, comments FROM orders WHERE status = 'Cancelled' INTO OUTFILE 'C:/tmp/cancelled_orders.csv' FIELDS ENCLOSED BY '"' TERMINATED BY ';' ESCAPED BY '"' LINES TERMINATED BY '\n';
sed -i -e 's/archive.ubuntu.com\ |security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
grep -r "archive.ubuntu.com" /etc/apt/sources.list.d/
deb http://82.archive.ubuntu.com/ubuntu/ bionic main deb-src http://82.archive.ubuntu.com/ubuntu/ bionic main
deb http://82.archive.ubuntu.com/ubuntu/ bionic-updates main deb-src http://82.archive.ubuntu.com/ubuntu/ bionic-updates main
grep -r "archive.ubuntu.com" /etc/apt/
apt-get update
크롤링 참고 url : https://inasie.tistory.com/43
apt-get install -y net-tools apt-get install -y iputils-ping apt-get update
docker exec -t webmin ping 172.17.x.x (webmin-> ansible)
[root@localhost ~]# docker exec -t webmin cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.17.0.2 e21ec52b24c6 [root@localhost ~]# docker exec -t ansible cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.17.0.3 7e78ccf80610
[root@localhost ~]# docker exec -t webmin df -h Filesystem Size Used Avail Use% Mounted on overlay 184G 26G 149G 15% / tmpfs 16G 0 16G 0% /dev tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/md126 184G 26G 149G 15% /etc/hosts shm 64M 0 64M 0% /dev/shm tmpfs 16G 0 16G 0% /proc/acpi tmpfs 16G 0 16G 0% /proc/scsi tmpfs 16G 0 16G 0% /sys/firmware [root@localhost ~]# docker exec -t ansible df -h Filesystem Size Used Avail Use% Mounted on overlay 184G 26G 149G 15% / tmpfs 16G 0 16G 0% /dev tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/md126 184G 26G 149G 15% /etc/hosts shm 64M 0 64M 0% /dev/shm tmpfs 16G 0 16G 0% /proc/acpi tmpfs 16G 0 16G 0% /proc/scsi tmpfs 16G 0 16G 0% /sys/firmware
[root@localhost ~]# docker inspect -f "{{ .HostsPath }}" webmin /var/lib/docker/containers/e21ec52b24c6703f07a5360d95c5382407b95225c76aa548dd22131b3e702e09/hosts [root@localhost ~]# docker inspect -f "{{ .HostsPath }}" ansible /var/lib/docker/containers/7e78ccf80610cd5efc80ac36af44cf1e6def063d38dc632d0673f4230d00ac7a/hosts
docker exec e21ec52b24c6 ifconfig
root@e21ec52b24c6:/# service --status-all [ - ] cron [ - ] dbus [ ? ] hwclock.sh [ - ] procps [ - ] ssh [ - ] ufw [ - ] unattended-upgrades [ + ] webmin root@e21ec52b24c6:/# service ssh start
ssh-copy-id -i 172.17.0.3
출처: https://bluese05.tistory.com/54 [ㅍㅍㅋㄷ]
rm -rf /var/lib/apt/lists/* -vf
root@e21ec52b24c6:/etc/apt# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.2 LTS Release: 18.04 Codename: bionic root@e21ec52b24c6:/etc/apt# ^C root@e21ec52b24c6:/etc/apt# vi sources.list root@e21ec52b24c6:/etc/apt# apt-get clean root@e21ec52b24c6:/etc/apt# apt-get autoclean
docker rename webmin webminold
echo "deb http://ftp.daumkakao.com/ubuntu/ bionic main restricted" >> sources.list
echo $(hostname -I | cut -d\ -f1) $(hostname) | tee -a /etc/hosts
sed -i -re 's/([a-z]{2}.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
docker run -it -p 55:55/tcp -p 10000:10000/tcp --name webmin --dns 8.8.8.8 --name webminold --cap-add=NET_ADMIN --link ansible:ansible docker.io/ubuntu:18.04
docker run -it -p 55:55/tcp -p 10000:10000/tcp --name webmin -v /etc/localtime:/etc/localtime:ro -e TZ=Asia/Seoul --dns 8.8.8.8 --name webminold --cap-add=NET_ADMIN --link ansible:ansible docker.io/ubuntu:18.04
sysctl -a | wc -l
systemctl restart docker
[root@localhost ~]# docker run --privileged --cap-add=NET_ADMIN docker.io/ubuntu sysctl -w net.ipv4.ip_forward=1 && echo ok net.ipv4.ip_forward = 1 ok
실행중인 프로세스 보기 root@e21ec52b24c6:/etc/systemd# service --status-all
root@e21ec52b24c6:/# service webmin stop Stopping Webmin server in /usr/share/webmin root@e21ec52b24c6:/# service webmin start root@e21ec52b24c6:/#
cat /etc/sysctl.conf
sysctl -a | grep ip_forward
root@a1c71cd39706:/# sysctl net.ipv4.ip_forward net.ipv4.ip_forward = 0
sysctl -p # 반영 echo "net.ipv4.ip_forward=1" >> sysctl.conf
docker 컨테이너 재시작
root@e21ec52b24c6:/# /sbin/sysctl -w net.ipv4.ip_forward=1 sysctl: setting key "net.ipv4.ip_forward": Read-only file system
sysctl -w net.ipv4.ip_forward=1
docker 서비스 재시작으로 문제 해결
apt-get remove ufw
apt-get -y install software-properties-common apt-get -y install ansible apt-get install -y ansible ansible
ANSIBLE_INVENTORY 환경 변수에 설정 echo "192.168.x.xx" > ~/.ansible/hosts export ANSIBLE_INVENTORY=~/.ansible/hosts ansible 실행시 -i 옵션과 파일 경로 지정 ansible all -m ping -k -i ~/.ansible/hosts
Config 파일 생성 http://docs.ansible.com/ansible/intro_configuration.html ansible 동작을 제어하는 설정 파일은 /etc/ansible/ansible.cfg 이며 ANSIBLE_CONFIG 환경 변수를 통해 설정할 수 있다. export ANSIBLE_CONFIG=~/.ansible/ansible.cfg 정상 설정 여부는 다음과 같이 --version 을 주고 실행하면 된다. 앤서블 정상 접속확인 > 명령어 > ansible all -m ping -k SSH password: 192.168.x.xx | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" }
docker cp /root/HMS.tar e21ec52b24c6:/root
ansible-playbook install_packages.yml
vi .bashrc alias python='/root/HMS_FILE/bin/python3'
date '+%y-%m-%d_%T'
관련파일 HMS_Install.sh activate hms_root.conf install_package_root.yml hosts start_parser.py Parser_root1.py ~/.ssh/authorized_keys hms.sql (HMS_FILE_DIR 밑에 두기 cp /root/hms.sql /root/HMS_FILE/.)
[.] root@e21ec52b24c6:~/.ssh# cat id_rsa.pub >> ~/.ssh/authorized_keys [.] root@e21ec52b24c6:~/.ssh# chmod 700 ~/.ssh/authorized_keys
wget https://centos7.iuscommunity.org/ius-release.rpm apt-get -y install rpm
root@e21ec52b24c6:~/HMS_FILE# rpm -ivh ius-release*.rpm rpm: RPM should not be used directly install RPM packages, use Alien instead! rpm: However assuming you know what you are doing... warning: ius-release.rpm: Header V4 RSA/SHA256 Signature, key ID 4b274df2: NOKEY error: Failed dependencies: epel-release = 7 is needed by ius-release-2-1.el7.ius.noarch
apt-get install yum apt autoremove apt-get update apt-get install python3-dev apt-get install -qy python python-dev python-distribute python-pip ipython pip install --upgrade pip apt-get -y install python3-pip
virtualenv --python=python3.6 /root/HMS_FILE 2> /dev/null chown root.hms /root/HMS_FILE
apt-get -y install php apt-get install python-pika
dpkg: dependency problems prevent configuration of php: php depends on php7.2; however: Package php7.2 is not configured yet.
dpkg: error processing package php (--configure): dependency problems - leaving unconfigured Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.24) ... Errors were encountered while processing: php7.2-common php7.2-readline php7.2 php7.2-cli php7.2-json libapache2-mod-php7.2 php7.2-opcache php
apt-get install -y mariadb-server -> docker mariadb 따로 설치하기
apt-get remove php7.2-mysql apt-get remove php7.2-opcache apt-get remove libapache2-mod-php7.2 apt-get remove php7.2-json apt-get remove php7.2-cli apt-get remove php7.2 apt-get remove php7.2-readline apt-get remove php7.2-common
apt-get install python3-venv
apt-get install yum*
docker run -it -p 3308:3306/tcp --name mysql --dns 8.8.8.8 --net kafka-docker_default --net-alias nipa -e MYSQL_ALLOW_EMPTY_PASSWORD=true --cap-add=NET_ADMIN --link webmin --link kafka docker.io/mariadb
docker exec -it mysql /bin/bash mysql -uroot -p -e 'CREATE DATABASE hms;' (패스워드 없음)
source hms.sql;
mysql -uroot -p hms < hms.sql
-e 옵션 붙일것
오류 : 데이터베이스가 초기화되지 않았고 비밀번호 옵션이 지정되지 않았습니다. MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD 및 MYSQL_RANDOM_ROOT_PASSWORD 중 하나를 지정해야합니다.
apt-get install -y net-tools apt-get -y install vim apt-get install -y ssh apt-get install dialog apt-utils -y apt install unzip apt install git apt install apache2 apt-get install -y inetutils-ping apt-get install python3-dev libmysqlclient-dev gcc pip install mysqlclient (mysql 붙을 경우, pip 모듈 위치 찾기)
(HMS) root@e21ec52b24c6:~# find / -name pika
/usr/lib/python2.7/dist-packages/pika /usr/lib/python3/dist-packages/pika /root/HMS/lib/python3.6/site-packages/pika /root/HMS_FILE/lib/python3.6/site-packages/pika
(HMS) root@e21ec52b24c6:~/HMS_FILE# apt-get -y install httpd (apt-get -y install apache2 2.4.29-1ubuntu4.8) Reading package lists... Done Building dependency tree Reading state information... Done Package httpd is a virtual package provided by: nginx-light 1.14.0-0ubuntu1.3 nginx-full 1.14.0-0ubuntu1.3 nginx-extras 1.14.0-0ubuntu1.3 lighttpd 1.4.45-1ubuntu3.18.04 nginx-core 1.14.0-0ubuntu1.3 apache2 2.4.29-1ubuntu4.8 yaws 2.0.4+dfsg-2 webfs 1.21+ds1-12 tntnet 2.2.1-3build1 mini-httpd 1.23-1.2build1 micro-httpd 20051212-15.1 ebhttpd 1:1.0.dfsg.1-4.3build1 aolserver4-daemon 4.5.1-18.1 aolserver4-core 4.5.1-18.1
설치할 항목을 명시적으로 선택해야 한다.
밑 내용으로 설치 생략
다음 패키지가 자동으로 설치되었으며 더 이상 필요하지 않음: libsodium23 php-common tzdata
apt-get purge php7.2-common apt-get purge php7.2-gd apt autoremove apt-get remove "패키지명" apt-get update
docker cp php7.2-gd_7.2.19-0ubuntu0.18.04.1_amd64.deb 618ed967b636:/root apt-get install ./php7.2-gd_7.2.19-0ubuntu0.18.04.1_amd64.deb
apt-get install -y php7.2-common apt-get install -y php7.2 apt-get install -y php-mysql
installed php7.2-common package post-installation script subprocess returned error exit status 10
apt-get purge php7.2-common apt-get purge php7.2-gd apt autoremove apt-get remove "패키지명" apt-get update
apt-get purge php7.2-common apt-get purge php7.2-curl apt-get purge php-curl
apt list --installed dpkg --get-selections | grep -v deinstall
apt-get install php-common
docker cp php7.2-opcache_7.2.19-0ubuntu0.18.04.1_amd64.deb e21ec52b24c6:/root apt-get install ./php7.2-opcache_7.2.19-0ubuntu0.18.04.1_amd64.deb
apt-get dist-upgrade apt-get install -f
apt-get install ./php7.2-opcache_7.2.19-0ubuntu0.18.04.1_amd64.deb apt-get install -f apt-get install php7.2-common
dpkg --configure -a
apt remove --purge php7.2-common apt remove --purge php7.1-common apt remove --purge php7.0-common apt remove --purge php7.3-common apt remove --purge php5.6-common php7.2-common php7.3-common php5.6-common php7.0-common
apt list --upgradable
docker ps -a | grep webmin // 컨테이너가 존재하는지 확인 docker commit webmin webmin1 // webmin 컨테이너를 'webmin1' 이라는 이미지로 저장 docker save webmin1 > webmin.tar // '' 라는 이름으로 백업
docker images
docker load < webmin.tar // oracle_xx.tar 로 부터 oracle_backup 이미지 복원 docker images | grep webmin // 이미지가 복원되었는지 확인
docker run -it -p 15000:10000/tcp --name web --dns 8.8.8.8 --net kafka-docker_default --net-alias nipa --cap-add=NET_ADMIN --link mysql --link kafka webmin
vi .bashrc alias python='/root/HMS_FILE/bin/python3' alias pip='python -m pip -v' pip install virtualenv virtualenvwrapper pip install --upgrade pip virtualenv --python=python3.6 /root/HMS_FILE 2> /dev/null groupadd hms chown root.hms /root/HMS_FILE pip install -y pika
apt-get install libmariadbclient-dev apt-get install mariadb-client-10.1 apt-get install libssl-dev
root@c302a87a38f8:/usr/bin# mkdir /var/run/mysqld root@c302a87a38f8:/usr/bin# touch /var/run/mysqld/mysqld.sock
docker exec -t webmin cat /etc/hosts
root@c7f6a093809a:/usr/bin# netstat -tnlp
mysql -h172.20.0.2 -P 3306 -uroot -p
docker exec -t mysql ping 172.20.0.3
apt-get install nmap apt-get install netcat nmap 172.20.0.3 -p 3308 -Pn nc -z 172.20.0.3 3308
netcat -v 172.20.0.2 3306 nmap 172.20.0.2 -p 3306 -Pn
mysql -h mysql -P 3306 -uroot -p
root@c302a87a38f8:/# netcat -v 172.20.0.3 3308 mysql.kafka-docker_default [172.20.0.3] 3308 (?) : Connection refused
포트를 확인해 봐라
apt-get install telnet
root@c302a87a38f8:/# telnet 172.20.0.3 3308 Trying 172.20.0.3... telnet: Unable to connect to remote host: Connection refused
netstat -antp |grep mysql
cat /etc/mysql/my.cnf | grep bind-address
sysctl -a | grep net.ipv6.conf.all.disable_ipv6 sysctl net.ipv6.conf.all.disable_ipv6 docker run --privileged --cap-add=NET_ADMIN docker.io/mariadb sysctl -w net.ipv6.conf.all.forwarding=1 && echo ok
docker restart c7f6a093809a
[root@localhost ~]# docker commit mysql hms docker save hmssha256:2d526e74c802751f0f0dc009f8fa5624796a117b2e76ce6ca250e5e831b33a8b [root@localhost ~]# docker save hms > hmsdb.tar
docker container port c302a87a38f8 10000/tcp -> 0.0.0.0:15000
apt-get -y install software-properties-common apt-add-repository ppa:ansible/ansible apt-get update apt-get -y install ansible ansible
root@c302a87a38f8:~# service --status-all [ - ] ssh root@c302a87a38f8:~# service ssh start
mkdir /etc/ansible/ ANSIBLE_INVENTORY 환경 변수에 설정 echo "192.168.x.xx" > /.ansible/hosts export ANSIBLE_INVENTORY=/.ansible/hosts ansible 실행시 -i 옵션과 파일 경로 지정 ansible all -m ping -k -i ~/.ansible/hosts
http://docs.ansible.com/ansible/intro_configuration.html ansible 동작을 제어하는 설정 파일은 /etc/ansible/ansible.cfg 이며 ANSIBLE_CONFIG 환경 변수를 통해 설정할 수 있다. export ANSIBLE_CONFIG=~/.ansible/ansible.cfg 정상 설정 여부는 다음과 같이 --version 을 주고 실행하면 된다.
명령어 > ansible all -m ping -k SSH password: 192.168.x.xx | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" }
ansible-playbook install_packages.yml
ansible 환경 구성
mysql 접속 확인 (hms db생성 후 권한 부여)
pip , mysql client 설치
HMS, HMS_FILE 디렉토리 업로드
HMS_FILE/HMS_Install.sh
HMS_FILE/WebUI/api/db.php 수정
HMS_FILE/bin/actviate 실행 (conf위치 변경)
source bin/activate(/root/HMS_FILE 위치에서 실행)
~/HMS_FILE/HMS_Engine/Bin/parser_root1.sh 경로 수정
:~/HMS_FILE/HMS_Engine/Parser/install_packages_root.yml 수정
ansible-playbook install_packages_root.yml
(HMS) root@c302a87a38f8:~/.ssh# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.0.00 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.x.00's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.0.00'" and check to make sure that only the key(s) you wanted were added.
(HMS) root@c302a87a38f8:~/.ssh#
나. tar 명령어 tar czvf hms.gz mymodule
다. xxx 웹페이지에서 모듈 업로드 xxx > xxx configration > xxx modules > From uploaded file 선택하고 클립모양을 눌러 파일 업로드 > install module
상황 설명:
webmin : debian webmin 실행
webmin 실행 상태
[root@lwa1 ~]# ps -ef | grep webmin root 1589 1 0 May24 ? 00:01:37 /usr/bin/perl /usr/local/webmin/miniserv.pl /etc/webmin/miniserv.conf