์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” EntityGraph์˜ ์‚ฌ์šฉ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋ ค๊ณ  ํ•œ๋‹ค.

Entity๊ตฌ์„ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค

@Entity
class Team(
    var title: String,
) {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) // DB์—์„œ ์ž๋™์œผ๋กœ ID increment
    @Column(name = "team_id")
    var id: Long = 0L
    
    // Onwer Entity๋ฅผ Player๋กœ ์ง€์ •, Lazy type fetch, Persistence ์ „์ด ํƒ€์ž…
    @OneToMany(mappedBy="team", cascade=[CascaseType.ALL], fetch = FetchType.LAZY) 
    var players : MutableList<Player> = mutableListOf()
}

@Entity
class Player(
    var name : String,
    
    @ManyToOne
    @JoinColumn(name = "team_id") // ์™ธ๋ž˜ํ‚ค ๋งคํ•‘์„ ์œ„ํ•œ ์„ค์ •
    var game: Game
) {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) // DB์—์„œ ์ž๋™์œผ๋กœ ID increment
    @Column(name = "player_id")
    var id: Long = 0L
    
    var count : Long
}

Game <--> Player ์—”ํ‹ฐํ‹ฐ๊ฐ€ 1:N์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ๋‹ค.

ํ˜„์žฌ Team์˜ players๋Š” LAZY type์œผ๋กœ ๊ฐ€์ ธ์˜ค๊ฒŒ ๋˜์–ด์žˆ๋Š”๋ฐ,

ํ•˜๋‚˜์˜ team.players ์กฐํšŒ์‹œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด 2๊ฐœ์˜ query๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.

select 
team0_.team_id as team_id1_3_0_, 
team0_.name as name2_3_0_ 
from 
team team0_ 
where 
team0_.team_id=?

select 
players0_.team_id as team_id4_1_0_, 
players0_.player_id as player_i1_1_0_, 
players0_.player_id as player_i1_1_1_, 
players0_.count as count2_1_1_, 
players0_.name as name3_1_1_, 
players0_.team_id as team_id4_1_1_ 
from 
player players0_ 
where 
players0_.team_id=?

๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์˜ ๊ธ€๋“ค์„ ๋ณด๋‹ˆ, ์—ฌ๊ธฐ์—์„œ N + 1๊ฐœ์˜ Query๋ฌธ์ด ๋ฐœ์ƒํ•œ๋‹ค๊ณ  ํ•˜๋˜๋ฐ,

Fetch type์„ EAGER, LAZY๋กœ ๋ณ€๊ฒฝํ•˜๊ณ  ๋‹ค๋ฅธ ์˜ต์…˜๋“ค์„ ๋งŒ์ ธ๋ณด์•„๋„

Query๋ฌธ์€ ๋™์ผํ•˜๊ฒŒ 2๊ฐœ๋งŒ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

(์•„์ง JPA ORM๊ณผ ์นœ์ˆ™ํ•˜์ง€ ์•Š์•„์„œ ๋ชป๋‹ค๋ฃจ๋Š” ๊ฒƒ ์ผ์ˆ˜๋„ ์žˆ๋‹ค..)

 

ํ•˜์ง€๋งŒ ํ•˜๋‚˜์˜ request์— ๋Œ€ํ•ด 2๊ฐœ์˜ ์ฟผ๋ฆฌ๋ฌธ์ด ์ƒ๊ธฐ๋Š” ๊ฒƒ๋„ ์ด์ƒ์ ์ด์ง€๋Š” ์•Š๊ธฐ์—,

ํ•˜๋‚˜์˜ left outer join Query ๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์ž.

Team Repository์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด @EntityGraph๋ฅผ ์„ค์ •ํ•œ๋‹ค.

interface TeamRepository : CrudRepository<Team, Long> {
    @EntityGraph(attributePaths = ["players"])
    override fun findById(id: Long): Optional<Team>
}

๋ณ€๊ฒฝ ํ›„์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด Query๊ฐ€ ๋‚˜๊ฐ€๊ฒŒ ๋œ๋‹ค.

select 
team0_.team_id as team_id1_3_0_, 
team0_.name as name2_3_0_, 
players1_.team_id as team_id4_1_1_, 
players1_.player_id as player_i1_1_1_, 
players1_.player_id as player_i1_1_2_, 
players1_.count as count2_1_2_, 
players1_.name as name3_1_2_, 
players1_.team_id as team_id4_1_2_ 
from 
team team0_ 
left outer join 
player players1_ 
on 
team0_.team_id=players1_.team_id 
where 
team0_.team_id=?

 

์ด๋กœ ์ธํ•ด fetch type EAGER์™€๋„ ๋น„์Šทํ•œ ๊ฒฐ๊ณผ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

 

์˜ค๋Š˜์€ ์—ฌ๊ธฐ๊นŒ์ง€..

ํ‹€๋ฆฐ ๋‚ด์šฉ์— ๋Œ€ํ•œ ์ง€์ ์€ ์–ธ์ œ๋“ ์ง€ ํ™˜์˜์ž…๋‹ˆ๋‹ค

'Coding > SpringBoot' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[SpringBoot] Kotlin - Database Lock - 1  (0) 2021.04.21

์ตœ๊ทผ์— ์„œ๋ฒ„ ๊ฐœ๋ฐœ์„ ํ•˜๋Š” ์™€์ค‘์—.. ํฐ ์‹ค์ˆ˜๋ฅผ ์ €์งˆ๋Ÿฌ ๋ฒ„๋ ธ๋‹ค.

์„œ๋ฒ„์˜ ๊ตฌ์„ฑ ์š”๊ฑด์ด ์•„๋ž˜์™€ ๊ฐ™์•˜๋‹ค.


1. ์„œ๋ฒ„๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์ธ์Šคํ„ด์Šค์—์„œ ๋™์ž‘ํ•˜๋Š” ๊ฒƒ์„ ๊ฐ€์ •

2. ๋™์‹œ๋‹ค๋ฐœ์ ์ธ ์š”์ฒญ์—๋„ ๋ฌธ์ œ๊ฐ€ ์—†๋„๋ก ์„ค๊ณ„


์—ฌ๊ธฐ์—์„œ 1๋ฒˆ์€ ์–ด๋Š์ •๋„ ๊ฐ์•ˆ์„ ํ–ˆ์ง€๋งŒ 2๋ฒˆ์„ ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•ด์•ผ ํ•  ์ง€ ์ƒ๊ฐ์ง€๋„ ๋ชปํ–ˆ๋‹ค

์•„๋Š” ์‚ฌ๋žŒ์—๊ฒŒ๋Š” ๋ณด์ด๊ฒ ์ง€๋งŒ.. ๋‚ด๊ณต์ด ๋ถ€์กฑํ•˜์—ฌ ๋ชป๋ณด๊ณ  ์ง€๋‚˜๊ฐ”๋˜ ํƒ“์ธ๊ฒƒ ๊ฐ™๋‹ค..

์ด๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Database์˜ ๋™์‹œ์„ฑ์„ ํ•ด๊ฒฐํ•ด์•ผ ํ•˜๋Š”๋ฐ


1. Read/Write์—์„œ Lock์„ ๊ฑธ์–ด์ฃผ๊ฑฐ๋‚˜

2. insert / update query๋ฅผ ํ•  ๋•Œ database ๋ฅผ ๋ฐ”๋กœ ์ฐธ์กฐํ•˜๋„๋ก ํ•ด์•ผ ํ•˜๋Š” ๊ฒƒ์ด์—ˆ๋‹ค.


์ฆ‰, Controller๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” Service function์—์„œ

@Transactional์ด ๊ฑธ๋ ค์žˆ๋‹ค๊ณ  ํ•ด์„œ Database์˜ ๋™์‹œ์„ฑ์„ ๋งŒ์กฑํ•  ์ˆ˜ ์—†๊ณ ,

๋ณ„๋„์˜ ์„ค์ •์„ ํ•ด ์ฃผ๊ฑฐ๋‚˜ Query๋ฅผ ๋‚ ๋ ค์•ผ ํ•˜๋Š” ๊ฒƒ์ด์—ˆ๋‹ค.

Entity๊ตฌ์„ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค

@Entity
class Team(
    var title: String,
) {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) // DB์—์„œ ์ž๋™์œผ๋กœ ID increment
    @Column(name = "team_id")
    var id: Long = 0L
    
    // Onwer Entity๋ฅผ Player๋กœ ์ง€์ •, Lazy type fetch, Persistence ์ „์ด ํƒ€์ž…
    @OneToMany(mappedBy="team", cascade=[CascaseType.ALL], fetch = FetchType.LAZY) 
    var players : MutableList<Player> = mutableListOf()
}

@Entity
class Player(
    var name : String,
    
    @ManyToOne
    @JoinColumn(name = "team_id") // ์™ธ๋ž˜ํ‚ค ๋งคํ•‘์„ ์œ„ํ•œ ์„ค์ •
    var game: Game
) {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) // DB์—์„œ ์ž๋™์œผ๋กœ ID increment
    @Column(name = "player_id")
    var id: Long = 0L
    
    var count : Long
}

Game <--> Player ์—”ํ‹ฐํ‹ฐ๊ฐ€ 1:N์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ๋‹ค.

Game์ด MappedBy๋ฅผ Player์˜ "team" field๋กœ ๋ช…์‹œ ํ•ด ์คŒ์œผ๋กœ์จ Player๊ฐ€ Owner๋กœ ๋“ฑ๋ก.

Player table์— ๋Œ€ํ•ด์„œ๋Š” ์•„๋ž˜ Query๋ฌธ๊ณผ ๊ฐ™์ด Foreign Key๋ฅผ ์ƒ์„ฑํ•˜๊ฒŒ ๋œ๋‹ค.

alter table player add constraint FKdvd6ljes11r44igawmpm1mc5s foreign key (team_id) references team

์—ฌ๊ธฐ์—์„œ Player ์ƒ์„ฑ ์‹œ Team์˜ total_player_number๋ฅผ ์ƒ๊ฐํ•ด๋ณด์ž.

๋‹น์—ฐํžˆ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ๋งˆ๋‹ค 1์”ฉ ์ฆ๊ฐ€๋˜์–ด์•ผ ํ•  ๊ฒƒ์ด๋‹ค.

ํ•˜์ง€๋งŒ, ์—ฌ๋Ÿฌ Client๊ฐ€ ๋™์‹œ์— Player๋ฅผ ์ƒ์„ฑํ•˜๊ณ , Database๊ฐ€ Lock์ด ๋˜์ง€ ์•Š์„๋•Œ๋ฅผ ๊ฐ€์ •ํ•ด๋ณด์ž.

 

2๊ฐœ์˜ Client์—์„œ ๊ฐ๊ฐ Player๋ฅผ ์ƒ์„ฑํ•˜๋ ค๊ณ  ํ•œ๋‹ค.

๋˜ํ•œ, ๊ฐ๊ฐ์˜ Client์—์„œ Team ์ •๋ณด๋ฅผ ์ฝ์„ ๋•Œ total_player_number๊ฐ€ 0์ด์—ˆ๋‹ค.

์ด ๋•Œ, ๋™์‹œ์— request๊ฐ€ ๋ฐœ์ƒํ•˜๊ฒŒ ๋˜๋ฉด 2๊ฐœ์˜ Player๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ์ง€๋งŒ

Team์˜ total_player_number๋Š” 1์ด ๋  ๊ฐ€๋Šฅ์„ฑ์ด ์กด์žฌํ•œ๋‹ค.

 

์ฒซ๋ฒˆ์งธ Player๋กœ ์ธํ•ด total_player_number๊ฐ€ 1๋กœ ์ฆ๊ฐ€ํ•˜์ง€๋งŒ,

๋‘๋ฒˆ ์งธ Player ์ €์žฅ ๋‹น์‹œ ์ด๋ฏธ ์ฝ์–ด์˜จ team์˜ ํ•ด๋‹น ํ•„๋“œ ๊ฐ’์ด 0์ด๊ธฐ ๋•Œ๋ฌธ์—

1 -> 2๋กœ ๋ณ€ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ 1 -> 1๋กœ ๋ฎ์–ด์”Œ์›Œ ์งˆ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.


๋™์‹œ์„ฑ์„ ๊ณ ๋ คํ•˜์ง€ ์•Š์•˜์„ ๋•Œ Query ๋ฌธ

select 
team0_.team_id as team_id1_3_0_, 
team0_.name as name2_3_0_, 
team0_.total_player_number as total_pl3_3_0_, 
players1_.team_id as team_id4_1_1_, 
players1_.player_id as player_i1_1_1_, 
players1_.player_id as player_i1_1_2_, 
players1_.count as count2_1_2_, 
players1_.name as name3_1_2_, 
players1_.team_id as team_id4_1_2_ 
from 
team team0_ 
left outer join 
player players1_ 
on 
team0_.team_id=players1_.team_id 
where team0_.team_id=?

insert into player 
(player_id, count, name, team_id) 
values 
(null, ?, ?, ?)

update team 
set 
name=?, 
total_player_number=? 
where 
team_id=?

 

Team repository๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ณ€๊ฒฝํ•ด์„œ Pessimistic Lock์„ ๊ฑธ์–ด์ฃผ์—ˆ๋‹ค.

interface TeamRepository : JpaRepository<Team, Long> {
    @Lock(LockModeType.PESSIMISTIC_WRITE)	// ๋น„๊ด€์  Lock (Read / Write ๋ชจ๋‘)
    @EntityGraph(attributePaths = ["players"])
    override fun findById(id: Long): Optional<Team>
}

๋™์‹œ์„ฑ์„ ๊ณ ๋ คํ–ˆ์„ ๋•Œ Query ๋ฌธ

select 
team0_.team_id as team_id1_3_0_, 
team0_.name as name2_3_0_, 
team0_.total_player_number as total_pl3_3_0_, 
players1_.team_id as team_id4_1_1_, 
players1_.player_id as player_i1_1_1_, 
players1_.player_id as player_i1_1_2_, 
players1_.count as count2_1_2_, 
players1_.name as name3_1_2_, 
players1_.team_id as team_id4_1_2_ 
from 
team team0_ 
left outer join 
player players1_ 
on 
team0_.team_id=players1_.team_id 
where 
team0_.team_id=? 
for update		/* Database lock์„ ์œ„ํ•ด for update ๋ผ๋Š” ๊ตฌ๋ฌธ์ด ์ถ”๊ฐ€ ๋จ */

insert into player 
(player_id, count, name, team_id) 
values 
(null, ?, ?, ?)

update team 
set 
name=?, 
total_player_number=? 
where 
team_id=?

๋‹ค๋ฅธ๊ฑด ๋™์ผํ•˜์ง€๋งŒ, select ๋ฌธ์—์„œ ๋’ค์— ~ for update ๊ฐ€ ๋ถ™์–ด์žˆ๋‹ค.

์ด๋Š” ๋™์‹œ์„ฑ ์ œ์–ด๋ฅผ ์œ„ํ•ด ํŠน์ • row์— READ / WRITE Lock์ด ๊ฑธ๋ ค์žˆ๋‹ค๋Š” ๋ง์ด๋‹ค (๋ฐฐํƒ€์  Lock).

๋งŒ์•ฝ, Read๋Š” ์ž์œ ๋กญ๊ฒŒ ํ•˜๋˜, Write์—์„œ๋งŒ Lock์„ ๊ฑธ๊ณ ์‹ถ๋‹ค๋ฉด PESSIMISTIC_READ ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.


๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ ์ง์ ‘ ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ๋‹ค.

 

'Coding > SpringBoot' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[SpringBoot] Kotlin - Entity Graph  (1) 2021.04.22

Google๊ณผ ์—ฐ๋™ํ•˜์—ฌ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ํฌ๊ฒŒ ๋‘๊ฐ€์ง€ ๊ณผ์ •์ด ํ•„์š”ํ•˜๋‹ค.


1. Debugging sign ๊ตฌํ•˜๊ธฐ

2. app ๋‚ด์— google์ด ์ œ๊ณตํ•˜๋Š” google-services.json ํŒŒ์ผ ๋„ฃ๊ธฐ


(google service๋ฅผ ์‚ฌ์šฉํ•จ์— ์žˆ์–ด ์ด ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ง„์งœ๋กœ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•ด๋„ ๋  ์ง€ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๋Š” ์šฉ๋„)

 

๋จผ์ €, Android studio ์—์„œ SHA1 ๋ฅผ ์–ป์–ด๋ณด์ž.

1. View - Tool Windows - Gradle ์„ ํด๋ฆญํ•˜๋ฉด Android studio์˜ ์˜ค๋ฅธํŽธ์— Gradle ์ฐฝ์ด ๋œจ๊ฒŒ ๋œ๋‹ค.

2. [package name] - app - android ์— ๋“ค์–ด๊ฐ€๋ฉด signingReport๋ผ๊ณ  ์žˆ๋Š”๋ฐ ์ด๊ฑธ ์‹คํ–‰์‹œ์ผœ ์ค€๋‹ค.

 

3. debug ์šฉ SHA1๊ฐ€ ์•„๋ž˜์™€ ๊ฐ™์ด ํ‘œ์ถœ๋œ๋‹ค.

4. google-services.json ์„ ๋‹ค์šด๋ฐ›์•„ app ํด๋” ์•„๋ž˜์— ๋ณต์‚ฌํ•ด์„œ ๋„ฃ๋Š”๋‹ค.

5. ๋งŒ์•ฝ build.gradle์— ์•„๋ž˜ ๋‚ด์šฉ์ด ์—†๋‹ค๋ฉด, ๋ฐ˜๋“œ์‹œ ์ž…๋ ฅ ํ›„ sync๋ฅผ ํ•ด์•ผ ํ•œ๋‹ค.

๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด FirebaseApp.initializeApp(context)๊ฐ€ ์™„๋ฃŒ๋˜์ง€ ์•Š์•˜๋‹ค๊ณ  ๊ฒฝ๊ณ  ๋ฉ”์„ธ์ง€๊ฐ€ ๋œจ๋ฉด์„œ ์‹คํ–‰์ด ๋˜์ง€ ์•Š์„ ๊ฒƒ์ด๋‹ค.

- project level build.gradle

buildscript {
    ...
    }
    dependencies {
		...
        classpath "com.google.gms:google-services:4.3.5"
    }
}

- module level build.gradle

plugins {
    ...
    id 'com.google.gms.google-services'
}

...

dependencies {
    implementation platform('com.google.firebase:firebase-bom:26.5.0')
    implementation 'com.google.firebase:firebase-auth-ktx'
}

์•ˆ๋“œ๋กœ์ด๋“œ ์•ฑ ๊ฐœ๋ฐœ์ด ๋๋‚˜์„œ relase ํ›„ google play store์— ์˜ฌ๋ฆฌ๊ธฐ ์œ„ํ•ด์„œ๋Š”

์•ฑ ์„œ๋ช…์ด ํ•„์š”ํ•˜๋‹ค.

์ด๋ฅผ ์œ„ํ•ด์„œ debug๊ฐ€ ์•„๋‹Œ, release key๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

1. app ๋‚ด๋ถ€์— key store๋ฅผ ๋งŒ๋“ ๋‹ค.

 

2. app์˜ build.gradle์—์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ์ด๋ฏธ ๋งŒ๋“ค์–ด๋†“์€ key store๋ฅผ ์ง€์ •ํ•œ๋‹ค.

android {
    compileSdkVersion 30

    defaultConfig {
    	...
        }
    }

    signingConfigs {
        release {
            storeFile file('app_key_store')
            storePassword "xxxxxxx!"
            keyAlias "release"
            keyPassword "xxxxxxx!"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

 

3. apk build ๊ฐ€ ๋Œ์•„๊ฐ„ ๋’ค, aab ํŒŒ์ผ์ด ์ƒ์„ฑ ๋œ ๊ฒƒ์„ ํ™•์ธํ•œ๋‹ค. (app/release ํด๋”์— ์œ„์น˜)

 

4. google play console์— ์—…๋กœ๋“œ ํ•˜๋ฉด ๋œ๋‹ค.

์ด ๋•Œ ์ฃผ์˜ํ•  ์ ์€, ํ•œ๋ฒˆ ์•ฑ์„ ์˜ฌ๋ฆฐ ํ›„ key store๋ฅผ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜ package name์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

๋งŒ์•ฝ ๊ทธ๋ ‡๊ฒŒ ํ•˜๊ณ  ์‹ถ์œผ๋ฉด ์•ฑ๊ณผ play console์—์„œ ์ƒˆ๋กœ ์•ฑ์„ ์ƒ์„ฑํ•ด์•ผ ํ•œ๋‹ค.

์•ˆ๋…•ํ•˜์„ธ์š”?

์ฝ”๋”ฉํ•˜๋Š” ๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค!

 

์ด๋ฒˆ ์‹œ๋ฆฌ์ฆˆ๋Š”, ์ฝ”ํ‹€๋ฆฐ(Kotlin) ์ด๋ผ๋Š” ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•ด์„œ

์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์–ดํ”Œ์„ ๋งŒ๋“ค์–ด ๋ณผ๊ฑฐ์—์š”!


1. ์†Œ๊ฐœ ๋ฐ ๊ฐœ์š”

 

์ฝ”ํ‹€๋ฆฐ์ด๋ž€?

IntelliJ IDEA์˜ ๊ฐœ๋ฐœ์‚ฌ 

JetBrains ์—์„œ 2011๋…„์— ๊ณต๊ฐœํ–ˆ๊ณ ,


2017๋…„ ๊ตฌ๊ธ€์ด ์•ˆ๋“œ๋กœ์ด๋“œ ๊ณต์‹์–ธ์–ด๋กœ ์ถ”๊ฐ€ํ•œ ์–ธ์–ด์—์š”!

๊ตฌ๊ธ€์ด ๋ฐ€์–ด์ฃผ๊ณ  ์žˆ์œผ๋‹ˆ, ๋˜๊ฒŒ ํ•ซํ•œ ์–ธ์–ด์ฃ !

 

Java๊ฐ€ ์ต์ˆ™ํ•˜์‹  ๋ถ„๋“ค์„ ์œ„ํ•ด,

์ฝ”ํ‹€๋ฆฐ๊ณผ Java๋ฅผ ๊ฐ„๋‹จํžˆ ๋น„๊ต ํ•ด๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์•„์š”

  Kotlin Java
๊ณตํ†ต์  ๊ฐ์ฒด ์ง€ํ–ฅํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด
์ฐจ์ด์  Null ํ• ๋‹น์ด ๊ฐ€๋Šฅ
๊ธฐ๋ณธํ˜• ํƒ€์ž…๋งˆ์ € ํด๋ž˜์Šค๋กœ ์กด์žฌ
๊ณ ์ฐจํ•จ์ˆ˜ / ๋žŒ๋‹ค ํ‘œํ˜„์‹ ์‚ฌ์šฉ ๊ฐ€๋Šฅ
Data ํด๋ž˜์Šค ์‚ฌ์šฉ ๊ฐ€๋Šฅ
์ฝ”๋ฃจํ‹ด ์‚ฌ์šฉ ๊ฐ€๋Šฅ
Null ํ• ๋‹น์ด ๋ถˆ๊ฐ€๋Šฅ
๊ฐ์ฒด ๋‹จ์œ„๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๋ฐฉ์‹

 

์ฝ”ํ‹€๋ฆฐ์ด ์ž๋ฐ”๋ณด๋‹ค ์ตœ๊ทผ์— ๊ฐœ๋ฐœ๋œ ์–ธ์–ด์ด๋‹ค ๋ณด๋‹ˆ,

ํŽธ๋ฆฌํ•˜๊ณ  ๊ตฌ์กฐ์ ์œผ๋กœ ์ž˜ ๋งŒ๋“ค์–ด์ง„ ์–ธ์–ด์ธ๊ฒƒ ๊ฐ™์•„์š”.

 

์ด๋ฒˆ ์‹œ๋ฆฌ์ฆˆ๋Š”, ์ดˆ๋ณด์ž๋“ค์˜ ๋ˆˆ๋†’์ด์— ๋งž์ถ”์–ด

์ฝ”๋“œ๋ฅผ ๋”ฐ๋ผ์„œ ์‹คํ–‰ํ•˜๋ฉด ์ด๋ ‡๊ฒŒ ํ•  ์ˆ˜ ์žˆ๋‹ค!

๋ผ๋Š”๋ฐ ์ดˆ์ ์„ ์ข€ ๋งž์ถ”๊ณ  ์ง„ํ–‰ํ• ๊นŒ ํ•ฉ๋‹ˆ๋‹ค.

 

๋‹จ, ๋ชจ๋“  ์ž‘์—…๋“ค์€ ๋ชจ๋ฐ”์ผ์—์„œ๋Š” ์•ˆ๋˜๊ณ ..

PC์—์„œ ์ง„ํ–‰ํ•˜์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค!


2. ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค ์„ค์น˜

 

์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๊ธฐ์— ์•ž์„œ, ์„ธํŒ…์„ ๋จผ์ € ํ•ด์ค์‹œ๋‹ค

์•„๋ž˜์˜ ๋งํฌ์—์„œ ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค๋ฅผ ์„ค์น˜ํ•ด ์ฃผ์„ธ์š”

(VsCode๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๋Š” ๋ถ„๋“ค์€, ๊ทธ๋ƒฅ ์“ฐ์…”๋„ ๋ฌด๋ฐฉํ•ฉ๋‹ˆ๋‹ค)

 

developer.android.com/studio?hl=ko

 

Download Android Studio and SDK tools  |  Android ์ŠคํŠœ๋””์˜ค

developer.android.com

์œˆ๋„์šฐ์™€ ๋งฅ๋ถ ๋ชจ๋‘ ์„ค์น˜๊ฐ€๋Šฅํ•˜๋‚˜,

์„ค์ •์ด ์•ฝ๊ฐ„์”ฉ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์–ด์š”.

(์ €๋Š” ๋งฅ๋ถ์œผ๋กœ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค!)


3. ์ƒˆ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

 

์ด์ œ ์ฝ”ํ‹€๋ฆฐ์„ ์ด์šฉํ•ด์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค์–ด๋ณผ๊นŒ์š”?

์•„๋ž˜์˜ ๊ทธ๋ฆผ์„ ๋”ฐ๋ผ ์™€์ฃผ์„ธ์š”!

์ƒˆ๋กœ์šด ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ด์ค๋‹ˆ๋‹ค

 

๊ธฐ๋ณธ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ˆŒ๋Ÿฌ ์ง„ํ–‰ํ•ด์ฃผ์„ธ์š”

 

๋งŒ๋“ค ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ด๋ฆ„์„ ์ž…๋ ฅํ•˜๊ณ , Kotlin์„ ์–ธ์–ด๋กœ ์„ ํƒํ•ด์ฃผ์„ธ์š”

 

์™„์„ฑ์ด ๋˜์—ˆ๋‹ค๋ฉด, ์•„๋ž˜์˜ ํ™”๋ฉด์ด ๋‚˜์˜ฌ๊ฒ๋‹ˆ๋‹ค!

MainActivity.kt ๊ฐ€ ์ƒ์„ฑ๋œ ๋ชจ์Šต์ž…๋‹ˆ๋‹ค.


4. ์ฝ”๋“œ ์‚ฝ์ž…๊ณผ AVD (๊ฐ€์ƒ ๋””๋ฐ”์ด์Šค) ์‹คํ–‰

 

์ฝ”ํ‹€๋ฆฐ์€ ์•„๋ž˜์˜ 4๊ฐ€์ง€๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ์š”,


Activity
Service
Broadcast receiver
Content provider


์ด ์ค‘์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•˜๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ๋Š” Activity ๋Š”,

๊ทธ๋ฆผ์ด๋‚˜ ๊ธ€์”จ๋“ฑ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์‹œ๊ฐ์ ์ธ ์š”์†Œ๋“ค์„

ํœด๋Œ€ํฐ์˜ ํ™”๋ฉด์— ๋„์›Œ์ฃผ๋Š” ์—ญํ• ์„ ํ•ด์š”.

 

์ฝ”๋”ฉ์˜ ๋ง›์„ ์‚ด์ง ๋ณด๊ธฐ์œ„ํ•ด์„œ,

์•„๋ž˜์˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๋ผ์ธ9์™€ ๋ผ์ธ17์— ๊ฐ๊ฐ

์ฝ”๋“œ๋ฅผ ์‚ฝ์ž… ํ•ด ๋ณผ๊นŒ์š”?

Line 9  --> import android.widget.Toast
Line 17 --> Toast.makeText(this, "hello, formicae", Toast.LENGTH_LONG).show()

 

์‚ฝ์ž…์„ ํ•˜์…จ๋‹ค๋ฉด, ์‹คํ–‰์„ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”!

Run ์„ ํด๋ฆญ

 

๋งŒ์•ฝ, ์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค๊ฐ€ ์ฒ˜์Œ์ด์‹œ๋ผ๋ฉด

๊ฐ€์ƒ ๋””๋ฐ”์ด์Šค ์„ค์น˜๊ฐ€ ํ•„์š”ํ• ๊ฑฐ์—์š”.

AVD Manager๋ฅผ ํด๋ฆญ
Create Virtual Device๋ฅผ ๋ˆŒ๋Ÿฌ ์ƒ์„ฑ ํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค

 

๋””๋ฐ”์ด์Šค์—์„œ ์‹คํ–‰์ด ์™„๋ฃŒ๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด,

์•„๋ž˜์™€ ๊ฐ™์ด "hello, formicae" ๋ผ๋Š” ๋ฌธ๊ตฌ๊ฐ€

์ž ๊น ์˜ฌ๋ผ์™”๋‹ค๊ฐ€ ์‚ฌ๋ผ์ง€๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

 

์ด๊ฒƒ์€ Toast๋ผ๋Š” ๋‚ด์žฅ ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•œ ๊ฒƒ์ธ๋ฐ์š”,

์•ž์œผ๋กœ๋„ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์œ ์šฉํ•œ ํด๋ž˜์Šค๋“ค๊ณผ

์ง์ ‘ ๋งŒ๋“  ํด๋ž˜์Šค๋“ค์„ ์ด์šฉํ•ด ์–ดํ”Œ์„ ๋งŒ๋“ค์–ด ๋ณด์•„์š”!

 

์—ฌ๊ธฐ๊นŒ์ง€๊ฐ€ ๊ธฐ๋ณธ์ ์ธ ์„ค์ •์„ ๋‹ค๋ฃจ์—ˆ๊ณ ,

๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ๋Š” ์ฝ”๋“œ๋ฅผ ์กฐ๊ธˆ์”ฉ ๋ฐ”๊พธ์–ด ๊ฐ€๋ฉฐ

์–ด๋–ค ๊ฒƒ๋“ค์„ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ์†Œ๊ฐœ ํ•ด ๋ณผ๊นŒ ํ•ด์š”!

 

๊ทธ๋Ÿผ ๋‹ค์Œ ํฌ์ŠคํŒ…์œผ๋กœ ๊ณ ๊ณ ์”ฝ :)

'Coding > Kotlin' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Android ๊ฐœ๋ฐœ - Google service ์—ฐ๋™ํ•˜๊ธฐ  (0) 2021.03.20
์•ˆ๋“œ๋กœ์ด๋“œ release key store ๊ด€๋ฆฌ  (0) 2021.03.20

 

์•ˆ๋…•ํ•˜์„ธ์š”?

๋ชจ์ฃผ๋ถ€์ž…๋‹ˆ๋‹ค!

 

์˜ค๋Š˜์€ ํ‹ฐ์Šคํ† ๋ฆฌ์— ๋ธ”๋กœ๊ทธ ์œ ์ž… ํšŸ์ˆ˜๋ฅผ ๋Š˜๋ฆด ์ˆ˜ ์žˆ๋Š”

์ข‹์€ ๋ฐฉ๋ฒ•์„ ์†Œ๊ฐœ ํ•ด ๋“œ๋ฆด๊ฑฐ์—์š”!

์ €๋„ ์ด ๋ฐฉ๋ฒ•์œผ๋กœ ๋‹จ๊ธฐ๊ฐ„์— ๊นœ์ง๋†€๋ž„๋งŒํผ

๋ฐฉ๋ฌธ์ž์ˆ˜๊ฐ€ ์ฆ๊ฐ€ํ–ˆ์–ด์š” ใ…Žใ…Ž

 

์ œ๊ฐ€ ์†Œ๊ฐœ ํ•ด ๋“œ๋ฆฌ๊ณ ์ž ํ•˜๋Š” ๊ฒƒ์€ ๋ฐ”๋กœ,

์‚ฌ์ดํŠธ๋งต(Sitemap) ์ด๋ผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.


์‚ฌ์ดํŠธ ๋งต์ด๋ž€,

๋ณธ์ธ์˜ ๋ธ”๋กœ๊ทธ์— ์žˆ๋Š” ๋ชจ๋“  ์นด๋ฐ๊ณ ๋ฆฌ, ๊ธ€๋“ค์„

xml์ด๋ผ๋Š” ํŒŒ์ผ๋กœ ๋งŒ๋“  ๊ฒƒ์ด์—์š”.

์–ด๋–ป๊ฒŒ ์ƒ๊ธด์ง€ ์ž ๊น ๋ณผ๊นŒ์š”?

๋ฉ”์ธ URL๊ณผ ์šฐ์„ ์ˆœ์œ„๊ฐ€ 0.8์ธ ํ•ญ๋ชฉ๋“ค (๋งค์šฐ ๋‚ฎ์Œ)
์šฐ์„ ์ˆœ์œ„๊ฐ€ 0.64์ธ ํ•ญ๋ชฉ๋“ค (์ค‘๊ฐ„)
์šฐ์„ ์ˆœ์œ„๊ฐ€ 0.51์ธ ํ•ญ๋ชฉ๋“ค (๋งค์šฐ ๋†’์Œ)

 

์ฝ”๋“œ๋กœ ๋˜์–ด์žˆ์–ด์„œ ๋ณด๊ธฐ ์‹ซ์œผ์‹ค์ˆ˜๋„ ์žˆ์ง€๋งŒ..

๊ตณ์ด ์ดํ•ดํ•˜์ง€ ์•Š์œผ์…”๋„ ๋ผ์š”!

์‚ฌ์ดํŠธ๋งต์€ ์•„๋ž˜์™€ ๊ฐ™์ด ์ด 4๊ฐ€์ง€๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ต๋‹ˆ๋‹ค.


loc : ์„ค๋ช…ํ•˜๋ ค๊ณ  ํ•˜๋Š” ๊ธ€์˜ ์œ„์น˜

lastmod : ๋งˆ์ง€๋ง‰์œผ๋กœ ์ˆ˜์ •๋œ ์‹œ๊ฐ„

priority : ์‚ฌ์ดํŠธ ์ „์ฒด ๋‚ด์—์„œ์˜ ์šฐ์„ ์ˆœ์œ„

changefreq : ๋ณ€๊ฒฝ๋˜๋Š” ์ฃผ๊ธฐ



์‚ฌ์ดํŠธ๋งต์„ ์‚ฌ์šฉํ•˜๋ฉด ๊ตฌ๊ธ€, ๋„ค์ด๋ฒ„, ๋‹ค์Œ ๋“ฑ์˜

๊ฒ€์ƒ‰์—”์ง„์ด ๋ถ„์„ํ•˜๊ธฐ ์‰ฝ๊ฒŒ ๋˜์–ด

์‚ฌ์šฉ์ž๊ฐ€ ๊ฒ€์ƒ‰ ํ•˜๋Š” ๊ฒฝ์šฐ ๋…ธ์ถœ๋  ์ˆ˜ ์žˆ๋Š”

ํ™•๋ฅ ์ด ์ฆ๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜์‹œ๋ฉด ๋  ๊ฒƒ ๊ฐ™์•„์š”!

 

๋จผ์ € ์ œ๊ฐ€ ์“ด ์‚ฌ์ดํŠธ๋งต์„ ๋ณด์‹œ๋ฉด,

2020๋…„ 11/13์ผ ์ƒˆ๋ฒฝ 1์‹œ์— ๋น„๊ณต๊ฐœ๋กœ ์ž‘์„ฑ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค

๋น„๊ณต๊ฐœ ๊ธ€์ด๋ผ ํ• ์ง€๋ผ๋„
๊ฒ€์ƒ‰์—”์ง„์€ ์•Œ์•„์„œ ์ฐพ์•„ ์ฝ๋Š”๊ฒƒ ๊ฐ™์•„์š”

 

 

๊ทธ๋ฆฌ๊ณ  ๊ทธ ๋‹ค์Œ๋‚ ....

๋ฐฉ๋ฌธ์ž ์ˆ˜๊ฐ€ ๊ธฐํ•˜๊ธ‰์ˆ˜์ ์œผ๋กœ ๋Š˜์–ด๋‚ฌ์Šต๋‹ˆ๋‹ค!

๋ฌผ๋ก  ๊ฒ€์ƒ‰์œผ๋กœ ์ธํ•œ ์œ ์ž…์€ ๋งŽ์ด ๋Š˜์–ด๋‚˜์ง€ ์•Š์•˜์ง€๋งŒ,

ํ‹ฐ์Šคํ† ๋ฆฌ ๋‚ด๋ถ€์˜ ์ง์ ‘์œ ์ž…์ด ์—„์ฒญ ๋Š˜์–ด๋‚ฌ์–ด์š” 

 

 

ํ•˜๋ฃจ ์‚ฌ์ด์— ๋ฐฉ๋ฌธ์ž ์ˆ˜๊ฐ€ ํ™• ๋Š˜์–ด๋‚œ ๋ชจ์Šต

 

๊ฐ€์žฅ ์ข‹์€ ๊ฒƒ์€ ๊ฒ€์ƒ‰์œผ๋กœ ์ธํ•œ ์œ ์ž…์ด๊ฒ ์ง€๋งŒ,

๋ธ”๋กœ๊ทธ ์ดˆ๊ธฐ์—๋Š” ํ‹ฐ์Šคํ† ๋ฆฌ ์ง์ ‘ ์œ ์ž…๋„ ์ ˆ์‹คํ•˜์ฃ ...

 

์‚ฌ์ดํŠธ ๋งต์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์€,

์•„๋ž˜์˜ ํฌ์ŠคํŒ…์„ ์ฐธ์กฐํ•ด์ฃผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค!

formicae.tistory.com/38

 

ํ‹ฐ์Šคํ† ๋ฆฌ - ์‚ฌ์ดํŠธ๋งต ์ƒ์„ฑ ๋ฐ ๊ตฌ๊ธ€ & ๋„ค์ด๋ฒ„์— ๋“ฑ๋กํ•˜๊ธฐ

์•ˆ๋…•ํ•˜์„ธ์š”? ๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค :) ์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” ์‚ฌ์ดํŠธ ๋งต์„ ๋งŒ๋“ค๊ณ , ๊ตฌ๊ธ€๊ณผ ๋„ค์ด๋ฒ„์— ๋“ฑ๋กํ•ด ๋ณด๋„๋ก ํ• ๊ฑฐ์—์š”! ์‚ฌ์ดํŠธ ๋งต์ด ๋ฌด์—‡์ธ์ง€, ์™œ ํ•„์š”ํ•œ์ง€๋Š” ์•„๋ž˜์˜ ํฌ์ŠคํŒ…์„ ์ฐธ์กฐํ•ด์ฃผ์„ธ์š” 1. ์‚ฌ์ดํŠธ๋งต

formicae.tistory.com

์ €๋Š” ์ด๊ฑธ๋กœ ๋ฐฉ๋ฌธ์ž์ˆ˜๊ฐ€ ๋Š๋Š” ๊ฒƒ์„ ๋ณด๊ณ ,

๊ธ€ ์“ฐ๋Š”๊ฒƒ๋„ ์ค‘์š”ํ•˜์ง€๋งŒ..

๊ฒ€์ƒ‰์—”์ง„๊ณผ ์นœํ•ด์ง€๋Š” ๊ฒƒ๋„

๋งค์šฐ ์ค‘์š”ํ•˜๋‹ค๋Š” ๊ฒƒ์„ ๊นจ๋‹ฌ์•˜์Šต๋‹ˆ๋‹ค.

์•ž์œผ๋กœ๋Š” ์ƒˆ๋กœ์šด ๊ธ€ 5๊ฐœ ์ •๋„ ์˜ฌ๋ผ๊ฐˆ ๋•Œ ๋งˆ๋‹ค

์ƒˆ๋กœ xml์„ ์—…๋ฐ์ดํŠธํ•ด ์ค„ ์ƒ๊ฐ์ž…๋‹ˆ๋‹ค!

 

์ข€ ๋” ๋‚˜์•„๊ฐ€์„œ,

์œ„์—์žˆ๋Š” xml ์ฝ”๋“œ๋ฅผ ๋ณ€๊ฒฝํ•˜๋ฉด

์ข€ ๋” ๊ฒ€์ƒ‰์—”์ง„๊ณผ ์นœํ•ด์ง€์ง€ ์•Š์„๊นŒ?

์ƒ๊ฐ์„ ํ•˜์‹ค์ˆ˜๋„ ์žˆ์œผ์‹ค ๊ฒ๋‹ˆ๋‹ค.

 

ํ•˜์ง€๋งŒ xml ํŒŒ์ผ ๋‚ด๋ถ€์— ์žˆ๋Š” ์šฐ์„ ์ˆœ์œ„๋Š”

๊ฐ™์€ ๋ธ”๋กœ๊ทธ(์‚ฌ์ดํŠธ)๋‚ด์—์„œ์˜
์ˆœ์œ„
๋งŒ์„ ๊ฒฐ์ •ํ•˜๋Š” ๊ฒƒ์ด๋ฏ€๋กœ,

๋ชจ๋“  ๋งํฌ์˜ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๋‚ฎ๊ฒŒ ๋ณ€๊ฒฝํ•œ๋‹ค๊ณ  ํ•ด์„œ

๊ฒ€์ƒ‰์—”์ง„์ด ๋” ์ž˜ ์ฐพ์•„์ฃผ๋Š”๊ฒƒ์€ ์•„๋‹ˆ๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ๋ฐ˜๋“œ์‹œ ๋ณธ์ธ์˜ ๋ธ”๋กœ๊ทธ ๋Œ€ํ‘œ URL์€

์šฐ์„ ์ˆœ์œ„๊ฐ€ 1.0 ์ด์–ด์•ผ ํ•œ๋‹ค๊ณ  ํ•˜๋„ค์š”!

 

์ด๋ฒˆ์‹œ๊ฐ„์— ์ค€๋น„ํ•œ ๋‚ด์šฉ์€ ์—ฌ๊ธฐ๊นŒ์ง€์ž…๋‹ˆ๋‹ค.

๋‹ค๋“ค ๋ฐฉ๋ฌธ์ž์ˆ˜๋ฅผ ๋Š˜๋ฆฌ๋Š”๋ฐ ๋„์›€์ด ๋˜์—ˆ์œผ๋ฉด ์ข‹๊ฒ ๋„ค์š”!

๊ทธ๋Ÿผ ์˜ค๋Š˜๋„ ์ข‹์€ ํ•˜๋ฃจ ๋ณด๋‚ด์„ธ์š” :)

 

 

์•ˆ๋…•ํ•˜์„ธ์š”?
๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค :)

์ด๋ฒˆ ์‹œ๊ฐ„์—๋Š” ์‚ฌ์ดํŠธ ๋งต์„ ๋งŒ๋“ค๊ณ ,
๊ตฌ๊ธ€๊ณผ ๋„ค์ด๋ฒ„์— ๋“ฑ๋กํ•ด ๋ณด๋„๋ก ํ• ๊ฑฐ์—์š”!

์‚ฌ์ดํŠธ ๋งต์ด ๋ฌด์—‡์ธ์ง€,
์™œ ํ•„์š”ํ•œ์ง€๋Š” ์•„๋ž˜์˜ ํฌ์ŠคํŒ…์„ ์ฐธ์กฐํ•ด์ฃผ์„ธ์š”
formicae.tistory.com/39

 

ํ‹ฐ์Šคํ† ๋ฆฌ - ์‚ฌ์ดํŠธ๋งต(sitemap)์„ ์ด์šฉํ•œ ๋ธ”๋กœ๊ทธ ์œ ์ž… ๋Š˜๋ฆฌ๊ธฐ

์•ˆ๋…•ํ•˜์„ธ์š”? ๋ชจ์ฃผ๋ถ€์ž…๋‹ˆ๋‹ค! ์˜ค๋Š˜์€ ํ‹ฐ์Šคํ† ๋ฆฌ์— ๋ธ”๋กœ๊ทธ ์œ ์ž… ํšŸ์ˆ˜๋ฅผ ๋Š˜๋ฆด ์ˆ˜ ์žˆ๋Š” ์ข‹์€ ๋ฐฉ๋ฒ•์„ ์†Œ๊ฐœ ํ•ด ๋“œ๋ฆด๊ฑฐ์—์š”! ์ €๋„ ์ด ๋ฐฉ๋ฒ•์œผ๋กœ ๋‹จ๊ธฐ๊ฐ„์— ๊นœ์ง๋†€๋ž„๋งŒํผ ๋ฐฉ๋ฌธ์ž์ˆ˜๊ฐ€ ์ฆ๊ฐ€ํ–ˆ์–ด์š” ใ…Žใ…Ž ์ œ๊ฐ€

formicae.tistory.com

 



1. ์‚ฌ์ดํŠธ๋งต ๋งŒ๋“ค๊ธฐ

www.xml-sitemaps.com/

 

Create your Google Sitemap Online - XML Sitemaps Generator

Installable version We offer a server-side script written in PHP language that you can install on your server and create sitemap for your website. The script doesn't have the limit on number of pages included in sitemap, although server resources required

www.xml-sitemaps.com

 

์œ„ ๋งํฌ์— ๋“ค์–ด๊ฐ€์„œ ๋ณธ์ธ์˜ ๋ธ”๋กœ๊ทธ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•˜๊ณ , Start๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.

 

์™„๋ฃŒ๊ฐ€ ๋˜์—ˆ์œผ๋ฉด, xml ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ํ•ฉ๋‹ˆ๋‹ค

 


2. ๋ธ”๋กœ๊ทธ์— ํฌ์ŠคํŒ…ํ•˜๊ธฐ & URL ๋ณต์‚ฌํ•˜๊ธฐ


๋จผ์ €, ๋ณธ์ธ์˜ ํ‹ฐ์Šคํ† ๋ฆฌ ๋ธ”๋กœ๊ทธ์—์„œ ์„ค์ •์— ๋“ค์–ด๊ฐ€์ฃผ์„ธ์š”

 

์„ค์ •์„ ํด๋ฆญ

 

์ƒˆ๋กœ์šด ๊ธ€์“ฐ๊ธฐ - ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ์œผ๋กœ ๋ณ€๊ฒฝํ•˜๊ณ  ์ €์žฅํ•ด์ฃผ์„ธ์š”

 

์—ฌ๊ธฐ๊นŒ์ง€ ์ž˜ ์™”๋‹ค๋ฉด, ๊ธ€์“ฐ๊ธฐ๋ฅผ ๋ˆ„๋ฅด๋Š” ์ˆœ๊ฐ„

์ต์ˆ™ํ•˜์ง€ ์•Š์€ ํ™”๋ฉด์ด ๋ณด์ผ๊ฒ๋‹ˆ๋‹ค!

๋‹นํ™ฉํ•˜์ง€ ๋งˆ์‹œ๊ณ .. ์•„๋ž˜ ์ˆœ์„œ๋Œ€๋กœ ๋ฐœํ–‰๊นŒ์ง€ ํ•ด์ฃผ์„ธ์š”!

 

๊ธฐ๋ณธ์„ค์ • - ๋น„๊ณต๊ฐœ ํด๋ฆญ / ํŒŒ์ผ ์‚ฝ์ž… - sitemap.xml ์ถ”๊ฐ€

 

๊ทธ๋ฆฌ๊ณ  ์ž‘์„ฑ๋œ ๊ธ€์— ๋“ค์–ด๊ฐ€ ๋ด…์‹œ๋‹ค.

์ฒจ๋ถ€ ํŒŒ์ผ์œ„์— ๋งˆ์šฐ์Šค๋ฅผ ๋Œ€๊ณ  ์šฐํด๋ฆญ์„ ํ•ด์„œ

"๋งํฌ ๋ณต์‚ฌํ•˜๊ธฐ" ๋ฅผ ๋ˆŒ๋Ÿฌ์ค์‹œ๋‹ค!

 

 

๊ทธ๋Ÿฌ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๋งํฌ๊ฐ€ ๋ณต์‚ฌ๊ฐ€ ๋  ๊ฑฐ์—์š”

์—ฌ๊ธฐ์—์„œ ์šฐ๋ฆฌ๊ฐ€ ํ•„์š”ํ•œ๊ฑด, 

๋ธ”๋กœ๊ทธ ์ฃผ์†Œ .com/ ๋’ค์— ์žˆ๋Š” ๊ฒƒ๋“ค์ž…๋‹ˆ๋‹ค.

https://formicae.tistory.com/attachment/cfile30.uf@993245345FAD605A2B9BCF.xml


3. ๊ตฌ๊ธ€์— ์‚ฌ์ดํŠธ๋งต ์˜ฌ๋ฆฌ๊ธฐ

search.google.com/search-console/sitemaps

 

Google Search Console

ํ•˜๋‚˜์˜ ๊ณ„์ •์œผ๋กœ ๋ชจ๋“  Google ์„œ๋น„์Šค๋ฅผ ๋กœ๊ทธ์ธํ•˜์—ฌ Google Search Console๋กœ ์ด๋™

accounts.google.com


๋จผ์ € ๊ตฌ๊ธ€ ์„œ์น˜ ์ฝ˜์†”์— ๋“ค์–ด๊ฐ€์„œ,  Sitemaps๋ฅผ ๋ˆŒ๋Ÿฌ์ฃผ์„ธ์š”

 

์œ„์—์„œ ๋ณต์‚ฌํ•œ xml ํŒŒ์ผ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”

 

์ œ๋Œ€๋กœ ์ž…๋ ฅ์„ ํ•˜์…จ๋‹ค๋ฉด, ์ƒํƒœ์— ์„ฑ๊ณต์ด ๋‚˜์˜ฌ๊ฒ๋‹ˆ๋‹ค



4. ๋„ค์ด๋ฒ„์— ์‚ฌ์ดํŠธ๋งต ์˜ฌ๋ฆฌ๊ธฐ

searchadvisor.naver.com/console/board#

 

[๋„ค์ด๋ฒ„: ๋กœ๊ทธ์ธ]

์•ˆ์ „ํ•œ ๋กœ๊ทธ์ธ์„ ์œ„ํ•ด ์ฃผ์†Œ์ฐฝ์˜ URL๊ณผ ์ž๋ฌผ์‡  ๋งˆํฌ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

nid.naver.com

 

๋ณธ์ธ ๋ธ”๋กœ๊ทธ์˜ URL์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค
๋ณธ์ธ์˜ ์‚ฌ์ดํŠธ๋ฅผ ํด๋ฆญํ•ด์ค์‹œ๋‹ค
์š”์ฒญ - ์‚ฌ์ดํŠธ๋งต ์ œ์ถœ์„ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค
xml ํŒŒ์ผ ์ฃผ์†Œ ๋ณต์‚ฌํ•œ ๊ฒƒ์„ ๋ถ™์—ฌ๋„ฃ์–ด์ค์‹œ๋‹ค

 


์—ฌ๊ธฐ๊นŒ์ง€ ์™„๋ฃŒ๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด,

๊ฒ€์ƒ‰์—”์ง„์ด xml ํŒŒ์ผ์„ ์ฝ์–ด๋“ค์—ฌ์„œ

์ด์ „๋ณด๋‹ค ๋” ์œ ์ž…์ด ์ž˜ ๋˜์‹ค๊ฑฐ์—์š”!


> Tip <

๋ธ”๋กœ๊ทธ๋ฅผ ์šด์˜ํ•˜๋ฉด์„œ ๊ธ€์˜ ๊ฐœ์ˆ˜๊ฐ€ ๋Š˜์–ด๋‚ ํ…๋ฐ,

์ด์ „์— ์˜ฌ๋ฆฐ xml ํŒŒ์ผ์—๋Š” ์ƒˆ๋กœ ์ž‘์„ฑํ•œ ๊ธ€์ด 

๋ฐ˜์˜๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค!

๋”ฐ๋ผ์„œ, ์ ๋‹นํžˆ ๊ธ€์ด ์ƒˆ๋กœ ์˜ฌ๋ผ์™”๋‹ค๋ฉด

์œ„์˜ ์ž‘์—…์„ ๋ฐ˜๋ณตํ•ด์ฃผ๋Š”๊ฒŒ ์ข‹์•„์š”!



์ด์ƒ์œผ๋กœ ์ด๋ฒˆ์‹œ๊ฐ„์— ์ค€๋น„ํ•œ ํฌ์ŠคํŒ…์ด์—ˆ์Šต๋‹ˆ๋‹ค.

๋ชจ๋‘๋“ค ๋ธ”๋กœ๊ทธ๊ฐ€ ๋Œ€๋ฐ•๋‚˜๊ธธ ๊ธฐ์›ํ•˜๋ฉฐ..

์˜ค๋Š˜๋„ ์ข‹์€ ํ•˜๋ฃจ ๋ณด๋‚ด์„ธ์š” :)

์•ˆ๋…•ํ•˜์„ธ์š”?

์ฝ”๋”ฉํ•˜๋Š” ๋ชจ์ฃผ๋ถ€์ž…๋‹ˆ๋‹ค!

 

์ง€๋‚œ ์‹œ๊ฐ„์— ํฐํŠธ ํฌ๊ธฐ๋ฅผ ์กฐ์ ˆํ•˜๋Š” ๊ฒƒ์— ์ด์–ด

์˜ค๋Š˜์€ ํ‹ฐ์Šคํ† ๋ฆฌ์—์„œ HTML ํŽธ์ง‘์„ ํ†ตํ•ด

ํ•œ ์ค„์— ์„œ๋กœ ๋‹ค๋ฅธ ํฌ๊ธฐ์˜ ๊ธ€์ž๋ฅผ ์ ์–ด๋ณด๋ ค๊ณ  ํ•ด์š”!

formicae.tistory.com/19?category=815537

 

ํ‹ฐ์Šคํ† ๋ฆฌ ๊ธ€์“ฐ๊ธฐ ์ค‘ ๊ธ€์ž(ํฐํŠธ) ํฌ๊ธฐ ์กฐ์ ˆํ•˜๊ธฐ

์•ˆ๋…•ํ•˜์„ธ์š”? ์ฝ”๋”ฉํ•˜๋Š” ๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค! ์ด๋ฒˆ์—๋Š” ๊ตฌ๋…์ž๋‹˜์˜ ์š”์ฒญ์ด ์žˆ์–ด์„œ ํ‹ฐ์Šคํ† ๋ฆฌ์—์„œ ๊ธ€์ž(ํฐํŠธ) ํฌ๊ธฐ๋ฅผ ์กฐ์ ˆํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณผ ๊ฑฐ์—์š”! ๊ธฐ๋ณธ์ ์œผ๋กœ, ํ‹ฐ์Šคํ† ๋ฆฌ์—์„œ ์ œ๊ณต๋˜๋Š” ๊ธ€์”จ์˜ ํฌ๊ธฐ๋Š”

formicae.tistory.com

๋จผ์ € ์˜ˆ์‹œ๋ฅผ ๋ณด๊ณ  ์‹œ์ž‘ํ• ๊นŒ์š”?

๊ฐ€ ๋‚˜ ๋‹ค ๋ผ ๋งˆ ๋ฐ” ์‚ฌ

์œ„์™€ ๊ฐ™์ด ๊ธ€์ž ํฌ๊ธฐ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์œผ๋ฉด

๊ธ€์„ ์“ธ ๋•Œ ์œ ์šฉํ•˜๊ฒ ์ฃ ?

ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์ •๋ง ๊ฐ„๋‹จํ•˜๋‹ต๋‹ˆ๋‹ค!

ํ‹ฐ์Šคํ† ๋ฆฌ ๊ธ€์“ฐ๊ธฐ์—์„œ 

"๊ธฐ๋ณธ๋ชจ๋“œ"๋กœ ๋˜์–ด์žˆ๋Š” ์„ค์ •์„

"HTML"๋กœ ์ผ๋‹จ ๋ฐ”๊ฟ”์ฃผ์„ธ์š”!

HTML์„ ํด๋ฆญ

๊ทธ๋Ÿฌ๋ฉด ๊นŒ๋งŒ์ƒ‰ ํ™”๋ฉด์— ์ฝ”๋“œ๊ฐ€ ๋งŽ์ด ๋‚˜ํƒ€๋‚  ํ…๋ฐ์š”,

๋„ˆ๋ฌด ๊ฑฑ์ • ์•ˆํ•˜์…”๋„ ๋ฉ๋‹ˆ๋‹ค ใ…Žใ…Ž

์ฝ”๋“œ๊ฐ€ ๋ณต์žกํ•ด๋ณด์ด์ง€๋งŒ,

๊ธฐ๋ณธ๋ชจ๋“œ์—์„œ ์ž‘์„ฑํ–ˆ๋˜ ๊ธ€๋“ค์ด ๊ทธ๋Œ€๋กœ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—

ํฌ๊ธฐ๊ฐ€ ๋‹ค๋ฅธ ๊ธ€์„ ๋„ฃ๊ณ ์‹ถ์€ ์œ„์น˜๋ฅผ

Ctrl + F ๋กœ ๊ฒ€์ƒ‰ํ•ด์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์–ด์š”!

HTML ํŽธ์ง‘ ํ™”๋ฉด

์ด๋ ‡๊ฒŒ ์ฐพ๊ธฐ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋ฉด,

๋…ธ๋ž€์ƒ‰์œผ๋กœ ํ‘œ์‹œ๊ฐ€ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ช‡ ๋ฒˆ์งธ ์ค„์—

ํฌ๊ธฐ๊ฐ€ ๋‹ค๋ฅธ ๊ธ€์„ ๋„ฃ์„์ง€ ์•Œ ์ˆ˜ ์žˆ๋‹ต๋‹ˆ๋‹ค!

 

์ž ์ด์ œ ๋„ฃ๊ณ  ์‹ถ์€ ์œ„์น˜๋ฅผ ๊ฒฐ์ •ํ•˜์…จ๋‹ค๋ฉด,

์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•ด์„œ ๋ถ™์—ฌ ๋„ฃ์–ด๋ด…์‹œ๋‹ค!

<p><span style="font-size: 200%;">๊ฐ€</span>
<span style="font-size: 100%;">๋‚˜</span>
<span style="font-size: 150%;">๋‹ค</span>
<span style="font-size: 50%;">๋ผ</span>
<span style="font-size: 100%;">๋งˆ</span>
<span style="font-size: 300%;">๋ฐ”</span>
<span style="font-size: 400%;">์‚ฌ</span></p>

์—ฌ๋Ÿฌ๊ฐ€์ง€ ํฌ๊ธฐ๋ฅผ ํ‘œํ˜„ํ•˜๋Š๋ผ ์ฝ”๋“œ๊ฐ€ ์ข€ ๊ธธ์–ด์กŒ๋„ค์š”.

<p> tag์•ˆ์— ์žˆ๊ธฐ๋งŒ ํ•œ๋‹ค๋ฉด, <span> .... </span> ๊ตฌ๋ฌธ์„

๋ช‡๊ฐœ ์‚ญ์ œํ•ด๋„ ์ƒ๊ด€์—†๋‹ต๋‹ˆ๋‹ค!

๋ˆˆ์น˜ ์ฑ„์…จ๊ฒ ์ง€๋งŒ, <span> tag๋ฅผ ์ด์šฉํ•˜๋ฉด

ํ•œ ์ค„์— ์—ฌ๋Ÿฌ ๊ธ€์ž๋ฅผ ์ ์„ ์ˆ˜ ์žˆ์–ด์š”.

๋˜๊ฒŒ ๊ฐ„๋‹จํ•˜์ฃ ?

์ฝ”๋”ฉ์„ ๋ชจ๋ฅด์‹œ๋Š” ๋ถ„๋“ค๋„ ์ž˜ ๋”ฐ๋ผํ•˜์…จ์œผ๋ฉด

์ข‹๊ฒ ๋‹ค๋Š” ๋งˆ์Œ์—์„œ ํฌ์ŠคํŒ…์„ ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿผ ๋‹ค์Œ์—๋„ ์œ ์ตํ•œ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋„๋ก ํ• ๊ฒŒ์š”

์˜ค๋Š˜๋„ ์žฌ๋ฏธ์žˆ๋Š” ์ฝ”๋”ฉ ํ•˜์„ธ์š” :)

์•ˆ๋…•ํ•˜์„ธ์š”?

์ฝ”๋”ฉํ•˜๋Š” ๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค :)

์ด๋ฒˆ์‹œ๊ฐ„์—๋Š” ์ง€๋‚œ ํฌ์ŠคํŒ…์—์„œ ๋งŒ๋“   ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋ฅผ ๊ฐ€์ง€๊ณ 

Apache2๋ฅผ ์ด์šฉํ•˜์—ฌ ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด ๋ณผ๊ฑฐ์—์š”!

formicae.tistory.com/23?category=815536

 

GCP(Google cloud platform)๋กœ ๋‚˜์˜ ์„œ๋ฒ„(Server) ๋งŒ๋“ค๊ธฐ - 6

์•ˆ๋…•ํ•˜์„ธ์š”? ์ฝ”๋”ฉํ•˜๋Š” ๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค! ์ง€๋‚œ ๋ฒˆ ํฌ์ŠคํŒ…์— ์ด์–ด ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ์„ค์ •์„ ๋งˆ๋ฌด๋ฆฌ ์ง€์–ด ๋ณด๋„๋ก ํ• ๊ฒŒ์š”! formicae.tistory.com/entry/GCPGoogle-cloud-platform%EB%A1%9C-%EB%82%98%EC%9D%98-%EC%84%9C%EB%B..

formicae.tistory.com

๋จผ์ €, ์•„๋ž˜ ๊ทธ๋ฆผ์—์„œ ๋ณด์ด๋Š” ์ด๋ฏธ์ง€๋ฅผ ํด๋ฆญ ํ•ด์ฃผ์„ธ์š”

"Cloud shell ํ™œ์„ฑํ™”" ๋ˆ„๋ฅด๊ธฐ

Cloud shell์„ ์‚ฌ์šฉํ•ด์„œ ์ง์ ‘ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅ ํ•ด ๋ณผ๊ฑฐ์—์š”

Cloud shell์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๊ตฌ๊ธ€ ๋ฌธ์„œ๋ฅผ ์ฐธ์กฐํ•˜์‹œ๋ฉด ์ข‹์•„์š”!

cloud.google.com/shell/docs/using-cloud-shell?hl=ko

 

Cloud Shell ์‚ฌ์šฉ  |  Google Cloud

์ด ํŽ˜์ด์ง€์—์„œ๋Š” ์ƒˆ๋กœ์šด Google Cloud Shell ์„ธ์…˜์„ ์‹œ์ž‘ํ•˜๊ณ  ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. ์ƒˆ๋กœ์šด ์„ธ์…˜ ์‹œ์ž‘ํ•˜๊ธฐ Google Cloud Console ์ƒ๋‹จ์˜ Cloud Shell ํ™œ์„ฑํ™” ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. Console ํ•˜๋‹จ์˜ ์ƒˆ ํ”„๋ ˆ์ž„

cloud.google.com

๋™์ž‘์„ ์‹œ์ผฐ์œผ๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์ด ํ„ฐ๋ฏธ๋„์ด ๋‚˜์˜ฌ๊ฒ๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์—์„œ ์šฐ๋ฆฌ๋Š” Apache2๋ผ๋Š” ๊ฒƒ์„ ์„ค์น˜ํ•ด์„œ ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด ๋ณผ ๊ฒ๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌ๊ธฐ ์œ„ํ•ด์„œ๋Š”  Apache2๋ฅผ ์„ค์น˜ํ•ด์•ผ๊ฒ ์ฃ ?

์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด์ค์‹œ๋‹ค.

sudo apt-get install -y -qq apache2-utils

์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋œ ๋ชจ์Šต

์ด์ œ ์ค€๋น„๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

๊ทธ๋Ÿผ ์„œ๋ฒ„๋กœ ๊ฐ€์ƒ์˜ request๋ฅผ ๋ณด๋‚ด๋ณผ๊นŒ์š”? ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด์ค์‹œ๋‹ค!

ab -n 500 http://๋กœ๋“œ๋ฐธ๋Ÿฐ์„œํ”„๋ŸฐํŠธ์—”๋“œIP์ฃผ์†Œ:Port๋ฒˆํ˜ธ/

์ €์˜ ๊ฒฝ์šฐ์—๋Š” ์œ„์™€ ๊ฐ™์ด ์ž…๋ ฅํ•˜๋ฉด

ab -n 500 http://35.241.37.36:80/ ์ด ๋ฉ๋‹ˆ๋‹ค!

์—ฌ๋Ÿฌ๋ถ„๋“ค๋„ ๋ณธ์ธ์ด ๋งŒ๋“œ์‹  ํ”„๋ŸฐํŠธ์—”๋“œ์˜ IP์ฃผ์†Œ์™€ PORT ๋ฒˆํ˜ธ๋ฅผ ์ž˜ ์ž…๋ ฅํ•ด์ฃผ์‹œ๊ณ ,

๋ฐ˜๋“œ์‹œ Port ๋ฒˆํ˜ธ ๋’ค์— / ๋ฅผ ์จ์ฃผ์„ธ์š”!! ์•ˆ๊ทธ๋Ÿฌ๋ฉด ๋ช…๋ น์–ด๊ฐ€ ์ œ๋Œ€๋กœ ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

์ž˜ ์‹คํ–‰์ด ๋˜์—ˆ์œผ๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์€ ์ถœ๋ ฅ์ด ๋‚˜์˜ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

500๊ฐœ์˜ request๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ์ž˜ ๋ณด๋ƒˆ๋‹ค๋Š” ๋œป์ด์ฃ !

์ธ์Šคํ„ด์Šค ๊ทธ๋ฃน์ด ์ด request๋“ค์„ ์ฒ˜๋ฆฌํ•  ๋•Œ์˜ ์ƒํƒœ๋ฅผ ๋ณด๋ ค๋ฉด

VM์ธ์Šคํ„ด์Šค - ์ธ์Šคํ„ด์Šค ๊ทธ๋ฃน - ๋ชจ๋‹ˆํ„ฐ๋ง ์œผ๋กœ ๋“ค์–ด๊ฐ€ ์ค์‹œ๋‹ค.

์œ„์™€ ๊ฐ™์ด, ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜๋Š” ๋™์•ˆ์— ๋„คํŠธ์›Œํฌ๋ฅผ ํ†ตํ•ด ์š”์ฒญ์ด ๋“ค์–ด์™”๊ณ ,

์„œ๋ฒ„์—์„œ ์ด๋ฅผ ๋ฐ›์•„ ์ฒ˜๋ฆฌํ–ˆ๋‹ค๋Š” ๊ฒƒ์ด ๋‚˜์˜ต๋‹ˆ๋‹ค.

์ด ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜๋Š” ์ด์œ ๋Š”,

๋ณธ์ธ์ด ๋งŒ๋“  ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ์™€ ์ธ์Šคํ„ด์Šค ๊ทธ๋ฃน์ด ์ ์ ˆํ•˜๊ฒŒ ๋งŒ๋“ค์–ด ์กŒ๋Š”์ง€,

๊ทธ๋ฆฌ๊ณ  ์‚ฌ์šฉํ•˜๋ ค๋Š” ๋ชฉ์ ์— ๋งž๊ฒŒ ์ธ์Šคํ„ด์Šค์˜ ํ™•์žฅ ๋˜๋Š” CPU load๊ฐ€ ๊ณ ๋ ค ๋˜์—ˆ๋Š”์ง€๋ฅผ

ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ž…๋‹ˆ๋‹ค.

 

์ด๊ฒƒ์œผ๋กœ ์ด๋ฒˆ ์‹œ๋ฆฌ์ฆˆ์ธ GCP๋ฅผ ์ด์šฉํ•œ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ ๋งŒ๋“ค๊ธฐ๋Š” ๋งˆ์น˜๊ฒ ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿผ ์˜ค๋Š˜๋„ ์žฌ๋ฏธ์žˆ๋Š” ์ฝ”๋”ฉ ํ•˜์„ธ์š” :)

 

์•ˆ๋…•ํ•˜์„ธ์š”?

์ฝ”๋”ฉํ•˜๋Š” ๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค!

 

์ง€๋‚œ ๋ฒˆ ํฌ์ŠคํŒ…์— ์ด์–ด

๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ์„ค์ •์„ ๋งˆ๋ฌด๋ฆฌ ์ง€์–ด ๋ณด๋„๋ก ํ• ๊ฒŒ์š”!

formicae.tistory.com/entry/GCPGoogle-cloud-platform%EB%A1%9C-%EB%82%98%EC%9D%98-%EC%84%9C%EB%B2%84Server-%EB%A7%8C%EB%93%A4%EA%B8%B0-5?category=815536

 

GCP(Google cloud platform)๋กœ ๋‚˜์˜ ์„œ๋ฒ„(Server) ๋งŒ๋“ค๊ธฐ - 5

์•ˆ๋…•ํ•˜์„ธ์š”? ์ฝ”๋”ฉํ•˜๋Š” ๋ชจ์ฃผ๋ถ€ ์ž…๋‹ˆ๋‹ค! ์ ์  ์‹œ๋ฆฌ์ฆˆ๊ฐ€ ๋งˆ์ง€๋ง‰์„ ํ–ฅํ•ด ๊ฐ€๊ณ  ์žˆ๋„ค์š”! 1. GCP ์—์„œ ๋‚ด๋ถ€ / ์™ธ๋ถ€ ๋ถ€ํ•˜ ๋ถ„์‚ฐ ์„ ํƒํ•˜๊ธฐ ์ง€๋‚œ๋ฒˆ ํฌ์ŠคํŒ…์„ ๋‹ค ๋”ฐ๋ผ ํ•˜์…จ๋‹ค๋ฉด, formicae.tistory.com/entry/GCPGoogle-cloud

formicae.tistory.com


1. GCP์—์„œ ํ˜ธ์ŠคํŒ… ๋ฐ ๊ฒฝ๋กœ ๊ทœ์น™ ์ •ํ•˜๊ธฐ

๋จผ์ €, ์ƒ์„ฑํ•œ ์ธ์Šคํ„ด์Šค ๊ทธ๋ฃน์„ ๋ˆŒ๋Ÿฌ๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์™ธ๋ถ€ IP๊ฐ€ ๋‚˜์™€ ์žˆ์„ ๊ฒ๋‹ˆ๋‹ค

์ด IP๋ฅผ ํ†ตํ•ด ์ธ์Šคํ„ด์Šค ๊ทธ๋ฃน์— ์ ‘๊ทผ์„ ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด์ง€์š”.

๋งŒ์•ฝ ์ด IP๊ฐ€ ๊ณ ์ •์ด ์•„๋‹ˆ๋ผ๋ฉด, "VPC ๋„คํŠธ์›Œํฌ" - "์™ธ๋ถ€ IP์ฃผ์†Œ" ๋กœ ๊ฐ€์„œ

ํ•ด๋‹น IP๋ฅผ ๊ณ ์ • ์˜ˆ์•ฝ์„ ํ•ด ์ฃผ๋„๋ก ํ•ฉ์‹œ๋‹ค.

 

์ด ์™ธ๋ถ€ IP๋Š” ์ด์ œ ์ธ์Šคํ„ด์Šค ๊ทธ๋ฃน์„ ๋Œ€ํ‘œํ•˜๋Š” IP๋กœ์จ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

์ด์ œ ํ˜ธ์ŠคํŠธ ๋ฐ ๊ฒฝ๋กœ ๊ทœ์น™์„ ์‚ฌ์šฉํ•ด ๋ด…์‹œ๋‹ค.

์—ฌ๊ธฐ์—์„œ ํ˜ธ์ŠคํŠธ๋Š”, ํŠธ๋ž˜ํ”ฝ์„ ๋ฐ›๊ฒŒ ๋  ๋Œ€์ƒ์ด ๋˜๋Š” ์„œ๋ฒ„๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

์›๋ž˜๋Š” ๋ช…์‹œ์ ์œผ๋กœ IP๋ฅผ ์จ ์ฃผ์–ด์•ผ ํ•˜์ง€๋งŒ,

*  ๋ฅผ ์จ ์ฃผ๊ฒŒ ๋˜๋ฉด ์•Œ์•„์„œ ํ˜ธ์ŠคํŠธ๋ฅผ ๋งค์นญ ํ•ด์ค๋‹ˆ๋‹ค.

 

๊ธฐ๋ณธ์ ์ธ ํ˜ธ์ŠคํŠธ ๋ฐ ๊ฒฝ๋กœ ๊ทœ์น™์˜ ๋ชจ์Šต

ํ˜„์žฌ ์šฐ๋ฆฌ๋Š” ๋ฐฑ์—”๋“œ๋ฅผ ํ•˜๋‚˜๋ฐ–์— ์ƒ์„ฑํ•˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์—,

๊ตณ์ด ํ˜ธ์ŠคํŠธ์™€ ๊ฒฝ๋กœ๋ฅผ ์ถ”๊ฐ€ ํ•  ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ, ์ถ”ํ›„์— ํ•„์š”ํ•  ๋•Œ๋ฅผ ๋Œ€๋น„ํ•˜์—ฌ ์•„๋ž˜์™€ ๊ฐ™์ด

์ œ๊ฐ€ ๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ์˜ˆ์‹œ๋ฅผ ๋ณด์‹œ๊ฒ ์Šต๋‹ˆ๋‹ค.

ํ˜ธ์ŠคํŠธ๋Š” ์ „๋ถ€ * ๋กœ ์ฒ˜๋ฆฌํ–ˆ๊ณ , ๊ฒฝ๋กœ๋ฅผ ๋‹ค๋ฅด๊ฒŒ ํ•˜์—ฌ

์–ด๋–ค ๋ฐฑ์—”๋“œ๋กœ ์—ฐ๊ฒฐ๋˜๊ฒŒ ํ•  ์ง€๋ฅผ ์„ค์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉํ•œ ํ˜ธ์ŠคํŠธ ๋ฐ ๊ฒฝ๋กœ ๊ทœ์น™์˜ ์˜ˆ์‹œ


2. GCP์—์„œ ํ”„๋ŸฐํŠธ ์—”๋“œ ๊ตฌ์„ฑํ•˜๊ธฐ

์ด์ œ ํ”„๋ŸฐํŠธ ์—”๋“œ๋ฅผ ๊ตฌ์„ฑ ํ•ด ๋ณผ ์ฐจ๋ก€์ž…๋‹ˆ๋‹ค!

ํ˜„์žฌ ์šฐ๋ฆฌ๊ฐ€ ๊ตฌ์„ฑํ•œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋Š” http / https ์ด๋ฏ€๋กœ

์ด ๋‘๊ฐœ ์ค‘์—์„œ ์„ ํƒํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

https๋Š” http๋ณด๋‹ค ๋ณด์•ˆ์„ฑ์ด ๋” ๋†’์€ ํ”„๋กœํ† ์ฝœ์ž…๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ https ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ธ์ฆ์„œ๋ฅผ ๋ฐ›์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

https ์ธ์ฆ์„ ๋ฐ›๋Š” ๋ฐฉ๋ฒ•์€ ์ถ”ํ›„์— ๋‹ค๋ฃจ๋„๋ก ํ•˜๊ณ ,

ํ…Œ์ŠคํŠธ ํ•˜๋Š”๋ฐ์—๋Š” http๋งŒ ์‚ฌ์šฉํ•ด๋„ ๋ฌด๋ฆฌ๊ฐ€ ์—†์œผ๋ฏ€๋กœ http๋ฅผ ์„ ํƒ ํ•ด ์ค์‹œ๋‹ค.

ํ”„๋ŸฐํŠธ ์—”๋“œ ๊ตฌ์„ฑ ํ™”๋ฉด
ํ”„๋ก ํŠธ ์—”๋“œ๋ฅผ ์œ„ํ•ด ๊ณ ์ • IP๋ฅผ ํ•˜๋‚˜ ๋” ์˜ˆ์•ฝ ํ•ด ์ค์‹œ๋‹ค

์ด ๋•Œ ํฌํŠธ๋ฅผ ์™œ 3000๋ฒˆ์ด ์•„๋‹Œ, 80๋ฒˆ์ธ์ง€์— ๋Œ€ํ•ด ๊ณ ๋ฏผํ•˜์‹ค ํ•„์š”๋Š” ์—†์Šต๋‹ˆ๋‹ค.

์ง€๊ธˆ ์šฐ๋ฆฌ๊ฐ€ ์ž‘์—…ํ•˜๊ณ  ์žˆ๋Š” ์ „์ฒด์ ์ธ ๊ตฌ์„ฑ์€ ์•„๋ž˜์™€ ๊ฐ™๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

(ํ˜„์žฌ๋Š” ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ์™€๋Š” Backend 1๋งŒ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๋Š” ์ƒํƒœ์ด๊ธด ํ•ฉ๋‹ˆ๋‹ค)

 

ํ”„๋ก ํŠธ ์—”๋“œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์ตœ์ดˆ๋กœ ์š”์ฒญ์„ ํ•˜๋Š” ํ†ต๋กœ์ด๊ธฐ ๋•Œ๋ฌธ์—,

์„œ๋ฒ„(๋ฐฑ์—”๋“œ)์˜ ํฌํŠธ ๋ฒˆํ˜ธ์™€ ๋‹ฌ๋ผ๋„ ๊ด€๊ณ„๊ฐ€ ์—†๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ „์ฒด์ ์ธ ๊ตฌ์„ฑ๋„ (Backend 1 ๋งŒ ๊ตฌ์„ฑํ•˜๊ณ  ์žˆ์œผ๋‚˜, ํ™•์žฅ์ด ๊ฐ€๋Šฅํ•จ์„ ํ‘œ์‹œ)

๋ฌธ์ œ ์—†์ด ์ƒ์„ฑ์ด ๋˜์—ˆ์œผ๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์ด ๋…น์ƒ‰ ์ฒดํฌ๊ฐ€ ๋‚˜ํƒ€๋‚  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋ฅผ ํด๋ฆญํ•˜์—ฌ ์„ธ๋ถ€์ •๋ณด๋ฅผ ๋ณด๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์ด ๋‚˜์™€์žˆ์Šต๋‹ˆ๋‹ค.

GCP ๋‚ด๋ถ€์ ์œผ๋กœ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ์˜ ์„ค์ •์— ์•ฝ 3~5๋ถ„์ •๋„๊ฐ€ ์†Œ์š”๋ฉ๋‹ˆ๋‹ค.

๊ทธ ์ดํ›„๋กœ ํ”„๋ŸฐํŠธ ์—”๋“œ๋กœ ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด ์‘๋‹ต์ด ์˜ฌ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ด์ œ URL์— ํ”„๋ŸฐํŠธ์—”๋“œ์˜ host๋ฅผ ์ž…๋ ฅ ํ•ด์ฃผ๋ฉด

์•„๋ž˜์™€ ๊ฐ™์ด ์ •์ƒ์ ์ธ ์‘๋‹ต์ด ์˜ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค!

ํ”„๋ŸฐํŠธ์—”๋“œ - ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ - ์„œ๋ฒ„๊ฐ€ ์—ฐ๊ฒฐ๋œ ๋ชจ์Šต

๋งˆ์ง€๋ง‰์œผ๋กœ, ๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ ์ด ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์ด์šฉํ•ด์„œ

์ธ์œ„์ ์œผ๋กœ ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด๊ณ  VM์— ์–ผ๋งŒํผ์˜ ๋ถ€ํ•˜๊ฐ€ ๊ฑธ๋ฆฌ๋Š”์ง€,

๋‚ด๊ฐ€ ์„ ํƒํ•œ ๋ฉ”๋ชจ๋ฆฌ ๋“ฑ์˜ ์„ค์ •์ด ์ ํ•ฉํ•œ์ง€ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!

 

๊ทธ๋Ÿผ, ์˜ค๋Š˜๋„ ์ฆ๊ฑฐ์šด ์ฝ”๋”ฉํ•˜์„ธ์š” :)

+ Recent posts