![내 서버는 왜 3GB의 메모리만 사용합니까?](https://rvso.com/image/959231/%EB%82%B4%20%EC%84%9C%EB%B2%84%EB%8A%94%20%EC%99%9C%203GB%EC%9D%98%20%EB%A9%94%EB%AA%A8%EB%A6%AC%EB%A7%8C%20%EC%82%AC%EC%9A%A9%ED%95%A9%EB%8B%88%EA%B9%8C%3F.png)
서버에는 24GB의 메모리와 4개의 쿼드 코어 CPU가 있습니다. apache/MySQL/php에서 바쁜 웹 사이트를 실행하고 때로는 서버 부하가 너무 높다는 메시지를 표시합니다. 로그를 보면 3GB 이상의 메모리를 사용하지 않는데, 이는 나에게도 이상하게 보입니다. 이는 MySQL 또는 Apache 설정일 수 있습니다.
여기에 일부 데이터가 있습니다.
uname -a
Linux s2274 2.6.32-32-server #62-Ubuntu SMP Wed Apr 20 22:07:43 UTC 2011 x86_64 GNU/Linux
free -m
total used free shared buffers cached
Mem: 24153 20951 3201 0 125 17719
-/+ buffers/cache: 3106 21046
Swap: 11240 14 11226
보시다시피 여기에는 20GB가 사용 중이라고 나와 있습니다. 하지만 top/htop을 보면 사용량이 3092를 넘지 않습니다. 프로세서가 실제로 활성화되지 않았으며 평균 부하는 0.9입니다. 모든 메모리를 사용할 수 있는지 확인하기 위해 Apache 및/또는 MySQL에서 사용하는 메모리를 늘릴 수 있습니까?
죄송합니다. 잠시 자리를 비웠습니다..... mysqld 명령의 출력은 다음과 같습니다.
120108 8:48:21 [Note] Plugin 'FEDERATED' is disabled.
--binlog_cache_size=#
--bulk_insert_buffer_size=#
--delayed_queue_size=#
--join_buffer_size=#
--key_buffer_size=# The size of the buffer used for index blocks for MyISAM
--key_cache_block_size=#
--max_binlog_cache_size=#
--max_binlog_size=# Binary log will be rotated automatically when the size
max_relay_log_size is 0. The minimum value for this
--max_heap_table_size=#
--max_join_size=# Joins that are probably going to read more than
max_join_size records return an error.
--max_relay_log_size=#
the size exceeds max_binlog_size. 0 excepted, the minimum
--myisam_block_size=#
--myisam_data_pointer_size=#
--myisam_max_extra_sort_file_size=#
--myisam_max_sort_file_size=#
--myisam_sort_buffer_size=#
--preload_buffer_size=#
--profiling_history_size=#
--query_alloc_block_size=#
--query_cache_size=#
--query_prealloc_size=#
--range_alloc_block_size=#
--read_buffer_size=#
--read_rnd_buffer_size=#
--record_buffer=# Alias for read_buffer_size
--sort_buffer_size=#
--thread_cache_size=#
--tmp_table_size=# If an internal in-memory temporary table exceeds this
--transaction_alloc_block_size=#
--transaction_prealloc_size=#
binlog_cache_size 32768
bulk_insert_buffer_size 8388608
delayed_queue_size 1000
join_buffer_size 12582912
key_buffer_size 805306368
key_cache_block_size 1024
max_binlog_cache_size 18446744073709547520
max_binlog_size 104857600
max_heap_table_size 805306368
max_join_size 18446744073709551615
max_relay_log_size 0
myisam_block_size 1024
myisam_data_pointer_size 6
myisam_max_extra_sort_file_size 2147483648
myisam_max_sort_file_size 9223372036853727232
myisam_sort_buffer_size 25165824
preload_buffer_size 32768
profiling_history_size 15
query_alloc_block_size 8192
query_cache_size 805306368
query_prealloc_size 8192
range_alloc_block_size 4096
read_buffer_size 25165824
read_rnd_buffer_size 25165824
sort_buffer_size 25165824
thread_cache_size 256
tmp_table_size 805306368
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
PHP memory_limit는 128M입니다.
여러 상황에서 3GB 제한이 표시됩니다. Fi Htop, top 그리고 서버 상태에서 Webmin에 로그인하면.( 네, 저는 아이패드에서 관리를 많이 하기 때문에 Webmin을 사용합니다 ;))
여기에 스크린샷을 추가하려고 합니다...
답변1
24153 중 20951을 사용하고 있습니다. 애플리케이션은 3092 이상을 요청하지 않으므로 커널은 캐시와 버퍼에 나머지를 사용하고 있습니다. 애플리케이션에 더 많은 메모리가 필요하면 커널은 새로운 애플리케이션 요구 사항을 수용하기 위해 캐시를 줄입니다.
최적의 성능을 위해 MySQL 및 Apache 구성을 조정하는 것은 애플리케이션에 따라 다릅니다. 정적 웹 사이트와 같은 경우에는 대규모 파일 시스템 캐시가 좋습니다. 그러나 데이터베이스 상호 작용이 많은 동적 사이트는 기본 MySQL 구성을 몇 가지 변경하면 이점을 얻을 수 있습니다.
Percona에는 MySQL 구성을 시작하는 데 유용한 도구가 있습니다.http://tools.percona.com/wizard기본 사항이 갖추어지면 애플리케이션의 세부 사항에 맞게 추가로 조정할 수 있습니다.
Apache 구성은 트래픽 양과 요청 크기에 따라 달라집니다. 아무것도 모르는 상태에서 기본값 이상을 권장하기는 어렵습니다.
답변2
내 말이 맞다면 당신은 32비트 서버를 실행하고 있는 것입니다.
pae 이미지를 사용하지 않는 한 32비트는 4GB 메모리로 제한됩니다.
32비트 컴퓨터의 워드 크기는 32비트이므로 이론적으로 메모리는 4GB로 제한됩니다. 이 장벽은 '물리적 주소 확장'(또는 PAE)을 사용하여 확장되었으며, 4GB 이상의 메모리 액세스는 약간 느려지지만 제한을 64GB로 늘립니다.
커널 이미지에 pae가 포함되어 있는지 찾을 수 없습니다.
apt-get install linux-image-generic-pae를 시도해 볼 수 있습니다.
그렇다면 재부팅을 하고 메모리를 더 많이 사용하는지 확인하세요.
그렇지 않으면 64비트 서버 설치를 고려하십시오.