#20230407

eeapbh·2023년 4월 7일
0

MZC

목록 보기
23/61

어제 에러난 인스턴스 지우기

mysql -u root
show databases;
use nova;

update instances set deleted='1', vm_state='deleted', deleted_at=now() where uuid='e7b9ab28-c9fd-48db-887f-00bb8db10745' and project_id='975cf0dfa1894e30b64231a9987acc96';

Select uuid, hostname, vm_state, task_state, power_state, deleted from instances where uuid='e7b9ab28-c9fd-48db-887f-00bb8db10745';

centos@webserver

sudo yum install wget -y
sudo wget https://ko.wordpress.org/wordpress-4.8.2-ko_KR.zip
sudo yum install -y httpd php php-mysql php-gd php-mbstring wget unzip

cd /var/www/html
sudo unzip /home/centos/wordpress-4.8.2-ko_KR.zip
sudo mv index.html index.html.bak
sudo mv ./wordpress/* .
sudo chown -R apache:apache /var/www/*
sudo setenforce 0
sudo vi /etc/selinux/config
sudo systemctl restart httpd
sudo systemctl enable httpd

ubuntu@dbserver

sudo cp /etc/apt/sources.list ~/sources.list.old
sudo sed -i 's/nova.clouds.archive.ubuntu.com/mirror.kakao.com/g' /etc/apt/sources.list
sudo apt update -y
sudo apt-get install -y mariadb-server

OpenStack (root@localhost)

Project

source keystonerc_admin
openstack project create --domain Default --description "cli-project" cli-project
openstack project list

User

openstack user create --domain Default --project cli-project --password-prompt cli-user # 비번 Kosa0220!

openstack user list

openstack role add --project cli-project --user cli-user _member_

  • 현재경로에 이미지 업로드 (centos7랑 bionic)

Image

openstack image create --file CentOS-7-x86_64-GenericCloud.qcow2 \
--disk-format qcow2 --container-format bare --public centos7

qemu-img info bionic-server-cloudimg-amd64.img

openstack image create --file bionic-server-cloudimg-amd64.img \
--disk-format qcow2 --container-format bare --public ubuntu18

Flavor

openstack flavor create --vcpus 1 --ram 1024 --disk 10 --id 6 m1.micro
# --id 6 추가안하면 id 임의로 지저분하게 만들어짐

openstack network create --project cli-project --provider-network-type flat \
--provider-physical-network extnet --external external-network

openstack subnet create --network external-network \
--project cli-project --subnet-range 192.168.0.0/21 \
--allocation-pool start=192.168.5.101,end=192.168.5.150 \
--gateway 192.168.0.1 --no-dhcp external-subnet

Token

vi keystonerc_cli-user

unset OS_SERVICE_TOKEN
    export OS_USERNAME=cli-user
    export OS_PASSWORD='Kosa0220!'
    export OS_REGION_NAME=RegionOne
    export OS_AUTH_URL=http://192.168.1.81:5000/v3
    export PS1='[\u@\h \W(keystone_cli-user)]\$ '

Internal Network

vi /etc/neutron/policy.yaml

"create_network:provider:network_type": "role:admin or project_id:%(project_id)s"
"create_floatingip:floating_ip_address": "role:admin or project_id:%(project_id)s"

Router

source keystonerc_admin

openstack router list

openstack router create router
openstack router set --external-gateway external-network router
   (external-gateway와external-network를 라우터로 연결)
openstack router add subnet router internal-subnet

Security Group

source keystonerc_cliuser

openstack security group create open-sg-web
openstack security group rule create --protocol icmp --ingress open-sg-web
openstack security group rule create --protocol tcp --dst-port 22:22 open-sg-web # 22번포트부터 22번 포트 까지라는 뜻 마치 범위
openstack security group rule create --protocol tcp --dst-port 80:80 open-sg-web

KeyPair

openstack keypair create --public-key ~/.ssh/id_rsa.pub open-key

Floating IP

openstack floating ip create external-network
openstack floating ip create --floating-ip-address 192.168.5.138 external-network # 내가 안쓰는거 임의로 지정해줄수도 잇음
openstack server create --flavor m1.micro --image centos7 --security-group open-sg-web \
--network internal-network --boot-from-volume 10 --key-name open-key webserver

--user-data httpd.file

vi httpd.file
#!/bin/bash
yum install -y httpd
systemctl enable --now httpd
openstack server list
openstack floating ip list
openstack server add floating ip webserver 192.168.5.132 # floating ip 만든거 2개중에 아무거나 ㄱ
  • floating ip가 잘붙은거 확인 가능
ssh -i .ssh/id_rsa centos@192.168.5.132
  • webserver가 잘들어가진다

Volume

openstack volume create --size 1 web-add
openstack volume list
openstack server list
openstack server add volume webserver web-add

ssh -i .ssh/id_rsa centos@192.168.5.132
lsblk
sudo mkfs -t xfs /dev/vdb # 포멧
sudo mount /dev/vdb /mnt # 이미있는 폴더에 마운트
df -h

Security Group - ubuntu18

openstack security group create open-sg-db
openstack security group rule create --protocol icmp --ingress open-sg-db
openstack security group rule create --protocol tcp --dst-port 22:22 open-sg-db
openstack security group rule create --protocol tcp --dst-port 3306 open-sg-db

openstack server create --flavor m1.micro --image ubuntu18 --security-group open-sg-db \
--network internal-network --boot-from-volume 10 --key-name open-key --user-data mysqld.file dbserver
openstack floating ip list
openstack server add floating ip dbserver 192.168.5.137 # floating ip 만든거 2개중에 아무거나 ㄱ
openstack server list # 붙은거 확인
ssh -i .ssh/id_rsa ubuntu@192.168.5.137

MariaDB 설치

우분투 들어가서
sudo mysql_secure_installation
sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
#bind-address           = 127.0.0.1 주석처리

sudo systemctl restart mysql
sudo mysql -u root -p
CREATE USER 'wpuser'@'%' IDENTIFIED BY 'wppass';
CREATE DATABASE IF NOT EXISTS wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'%';
quit

webserver 가서

sudo yum install -y httpd php php-mysql php-gd php-mbstring wget unzip

wget https://ko.wordpress.org/wordpress-4.8.2-ko_KR.zip
cd /var/www/html
sudo unzip /home/centos/wordpress-4.8.2-ko_KR.zip
sudo mv ./wordpress/* .
sudo chown -R apache:apache /var/www/*
sudo systemctl restart httpd
sudo systemctl enable httpd

0개의 댓글