글

Kubernetes 3 masters on ceontos7

이미지
  ===========사전작업=========== hostnamectl set-hostname k8s-m01 vi /etc/hosts 10.0.2.221 k8s-m01 10.0.2.222 k8s-m02 10.0.2.223 k8s-m03 10.0.2.220 k8s-vip ============커널업데이트================== mkdir -p /etc/yum.repos.d/bak cd /etc/yum.repos.d mv *.repo ./bak curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo find . -name "*.repo" -exec sed -i 's/gpgcheck=1/gpgcheck=0/g' {} \; yum -y update rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm yum --enablerepo=elrepo-kernel install -y kernel-ml grub2-mkconfig -o /boot/grub2/grub.cfg grub2-set-default 0 reboot uname -a ======================소프트웨어 설치 준비========= yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager -y --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo cat <<EOF ...

Centos7 시간 동기화 (NTP)

 yum install ntp firewall-cmd --add-service=ntp --permanent firewall-cmd --reload systemctl start ntpd systemctl enable ntpd

postgres docker 설치

docker search postgres docker pull postgres docker run --name pgsql -d -p 5432:5432 -e POSTGRES_PASSWORD=비밀번호 postgres docker exec -it pgsql bash psql -U postgres CREATE DATABASE first; alter user postgres with password '비밀번호'; l c first ufw allow 5432

Docker 설치 on CentOS8

  dnf install docker-ce docker-ce-cli containerd.io --nobest

Local 과 Remote 저장소 연결 및 작업

cd c:\workdspace  [로컬과 원격저장소 연결] git remote add 별칭 https://github.com/inet815/study.git git remote -v    연결확인 ===========로컬에서 작업======== git push origin --all   로컬 작업의 모든 브랜치를 push ==========리모트와 로컬의 같은 파일을 로컬에서 변경 git push origin master   로컬 작업을 리모트에 푸쉬 하면 충돌 발생 git fetch    리모트의 커밋정보를 가져옮 git merge origin/master    로컬의 마스터와 리모트의 msater를 통합 git diff vim 수정 git commit -a -m "confict resolved GitHub" fetch와 merge를 한번에 하는 Pull 명령어

Remote 저장소를 Local 저장소로 복제

 cd c:\workspace [원격저장소를 로컬로 복제해서 작업] git clone https://gihub.com/inet815/study.git cd study git status

Local Git 사용법

PC에 git 설치 http://git-scm.com git bash 실행 git config --global user.name "이름" git config --global user.email "이메일" c:\ mkdir workspace cd workspace git init   로컬 저장소 초기화    vim hello.py git status   깃 상태 git add hello.py   깃에서 파일 추적하도록 추가 git status   깃 상태 git commit   수정사항 커밋 git branch   브랜치 조회 git branch hotfix   hofix 브랜치 생성 git checkput (-b) hotfix    브랜치 이동   git commit -a    저장소 파일 모두 커밋 git checkout master git merge hotfix    마스터에 hotfix를 병합 touch .gitignore    http://www.gitignore.io/ 에서 OS 별로 생성되는 내용을 복사해서 붙혀넣기 git add .gitignore git commit -m ''added '.gitignore' file"    깃에서 추적이 불필요한 파일/폴더 무시 git checkout master git merge hotfix git commit -a -m "conflict resolved"    충동 발생시 vim으로 수정후 다시 커밋 git log --graph git log --stat

redis sentinel 설치 on Centos 8

이미지
뭐가 문제인지 Virtualbox 3대로 아무리 테스트해봐도 안되다가 /etc/redis-sentinel.conf 를 null로 날리고 아래 내용만 깔끔하게 넣었다 근데 된다. failover 잘된다. ㅠ.ㅠ  bind 0.0.0.0 port 26379 sentinel monitor mymaster 192.168.56.201 6379 2 sentinel down-after-milliseconds mymaster 5000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 180000 sentinel auth-pass mymaster 비번 daemonize yes pidfile /var/run/sentinel.pid logfile /var/log/redis/sentinel.log ============== /etc/redis.conf에 아래 내용 반드시 넣자 mastersauth 비밀번호 requirepass 비빌번호 ================= 1번서버에서 redis-cli auth 비번 info replication 하면 아래와 같이 마스터로 보인다 이상태에서 shutdown 하거나 서버를 끄거나 systemctl stop redis 하거나 하면 마스터가 죽고 2번이나 3번 서버에서 tail -f /var/log/redis/sentinel.log 를 보면 failover 되는것이 보인다

network 수정 및 재설정 (Centos 7 & Centos 8)

  cd /etc/sysconfig/network-scripts vi ifcfg-인터페이스면 수정후 # Centos 7 systemctl restart network    # Centos 8 systemctl restart Networkmanager.service 하라고하는데 잘 안먹히는것 같음 그냥 GUI에서 껐다 키니깐 됨 nmcli con show 하면 인터페이스 정보가 나옴

redis 설치 CentOS 8.3 Master1-Slave2 (3대의 서버에 나누어 설치)

yum install epel-release yum install redissystemctl start redis systemctl enable redisredis-cli ping ===확인==== netstat -npat | grep redis ===컨피그================== vim /etc/redis.conf bind 0.0.0.0  (접속이 필요한 아이피들 0.0.0.0은 전부다 접속) port 포트번호 (포트변경할때 사용) requirepass 비밀번호 (비밀번호 적용할때 redis-cli에서는 auth 비번) masterauth 비밀번호 (slave에 설정해서 master랑 연결됨) #appenonly yes #save 900 1 #save 300 10 #save 60 1000 ==================== ==============Master 1, Slave 2 설치============ Master Node      192.168.56.201 : 6379  Slave Node - 1   192.168.56.202 : 6379  Slave Node - 2   192.168.56.203 : 6379  Master 서버에서 /etc/redis.conf bind 0.0.0.0 port 6379 requirepass 비밀번호 daemonize  yes Slave 1번 서버에서 /etc/redis-slave1.conf bind 0.0.0.0 port 6379 slaveof 192.168.56.201 6379 masterauth 비밀번호 daemonize yes Slave 2번 서버에서 /etc/redis.conf bind 0.0.0.0 port 6379 slaveof 192.168.56.201 6379 masterauth 비밀번호 daemonize yes =====재시작 및 확인===== systemctl stop firewalld s...

git server centos8에 설치

 server============== yum install git git --version useradd git passwd git git init --bare /home/git client============= 탐색기에서 디렉토리를 만들어서  오른쪽 클릭해서 git bash 실행 mkdir .ssh cd .ssh ssh-keygen -t rsa scp id_rsa.pub git@192.168.56.202 /home/git server============== su -git mkdir /home/git/.ssh cat /home/git/id_rsa.pub >> /home/git/.ssh/authorized_keys client============ ssh -v git@192.168.56.202 (접속확인) server============== /etc/passwd git:x:1002:1003::/home/git:/usr/bin/git-shell 변경 vi /etc/shells 마지막 줄에 /bin/git-shell 추가 client==================== 적정한 디렉토리에서 git-bash 실행 git clone ssh://git@192.168.56.201:/home/git cd git touch test.txt echo "test" >> test.txt git add . git commit --message "msg" git push origin master

Windows에서 Linux로 ssh 키인증 안될때

cd /etc/ssh/sshd_config 아래 항목 주석 제거후 no로 변경 StrictModes no

CentOS7 재설치후 멀티부팅 안될때

리눅스 부팅 해서 아래 명령어로 grub.cfg 만들기 grub2-mkconfig -o /boot/grub2/grub.cfg 재기동하고 grub상태에서 c 누르고 아래 프롬프트에서 명령어로 NTFS찾기 grub> ls 다시 리눅스 부팅해서 grub2.cfg에 아래 내용 추가 menuentry "Windows"{ insmod chain insmod drivemap set root=(hd0,msdos1) chainloader +1 }

CentOS7에 utorrent 설치

yum install -y wget glibc openssl* libgcc unzip ln -s /usr/lib64/libcrypto.so.0.9.8e /usr/lib64/libcrypto.so.0.9.8 ln -s /usr/lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8 cd /mnt && wget -qO - http://download.utorrent.com/linux/utorrent-server-3.0-ubuntu-10.10-27079.x64.tar.gz |tar xvzf - chmod -Rf 777 /mnt/utorrent-server-v3_0/ ln -s /mnt/utorrent-server-v3_0/utserver /usr/bin/uts uts -settingspath /mnt/utorrent-server-v3_0/ 접속 localhost:8080/gui id : admin pw :

CentOS 7에 Virtualbox 설치

cd /etc/yum.repos.d/ wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo yum repolist yum list VirtualBox* yum install 위의 리스트

HUE 사용자에게 HIVE에서 생성한 DB에 대한 권한 주기

이미지
DB에 대한 권한 주는 방법 HUE에서 그룹을 만든다 HUE에서 계정을 만들고 HUE에서 만든 그룹에 넣는다 OS에서 HUE에서 생성한 그룹 이름과 동일한 그룹을 만든다 OS에서 HUE에서 생성한 계정 이름과 동일한 계정을 만들고 위에 생성한 그룹에 넣는다. 중요한건 계정과 그룹 명이  HUE와 OS에서 동일하고 계정이 그룹에 속해있어야 한다. HUE에서 DB를 생성하고 ROLE에서 그룹에 권한을 준다. ======= 이때 HUE를 통해서 CSV를 HDFS에 올리면서 TABLE을 만드는 기능을 사용하고자 하면 위의 DB의 ROLE을 생성할때 /users/사용자 -> CSV를 올릴 HDFS에 권한을 줘야 한다.

쿠버네티스 대쉬보드 설치 (모니터링 및 관리)

쿠버네티스 대쉬보드 설치 (모니터링 및 관리) curl -O https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml vi kubernetes-dashboard.yaml dashboard 1.10.1 -> dashboard 1.10.0 (인증 skip) kubectl create -f kubernetes-dashboard.yaml 파드 보기 kubectl get pods --all-namespaces cat > dashboard-admin.yaml apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata:    name: kubernetes-dashboard    labels:      k8s-app: kubernetes-dashboard roleRef:    apiGroup: rbac.authorization.k8s.io    kind: ClusterRole    name: cluster-admin subjects:  - kind: ServiceAccount    name: kubernetes-dashboard    namespace: kube-system ctrl + d kubectl create -f dashboard-admin.yaml 기동 nohup kubectl proxy --address="10.100.0.104" -p 443 --accept-hosts='^*$' & dashboard 접속용 토큰 확인 kubectl -n kube-system describe secret...

쿠버네티스 노드 추가 방법

마스터노드에서 토큰 생성 kubeadm token list (확인) kubeadm token delete 토큰명 (지난것 지우기) kubeadm token create (새로 생성) =========== 노드로 접속 도커 설치 쿠버네티스 설치 기존 노드였으면 리셋 필요 kubeadm reset 컨피그 파일 복사 (기존 노드였으면 복사 필요없음) mkdir ~/.kube scp 10.100.0.104:/etc/kubernettes/admin.cof $HOME/.kube/config 조인 (마스터에서 위에 생성한 토큰 필요) kubeadm join 10.100.0.104:6443 --token q0lyfj.bt5lnuhcc50w5za8 --discovery-token-unsafe-skip-ca-verification

쿠버네티스 명령어 자동완성

source <(kubectl completion bash) echo "source <(kubectl completion bash)" >> ~/.bashrc

클러스터 마스터 노드 쿠버네티스 설치 URL

https://github.com/cookeem/kubeadm-ha/blob/master/README.md