Elasticsearch8
Ubuntu 22.04 부팅시 Elasticsearch 자동 실행
Jack Moon
2023. 6. 12. 10:32
* 현재 상황: Elasticsearch 를 압축을 풀어 깔고 bin/elasticsearch -d 로 실행하고 있다. 부팅시 자동으로 실행되도록 수정하려 한다. 보통 /etc/rc.local 에 명령을 넣지만 22.04에는 /etc/rc.local 파일도 없고 rc-local.service 도 비활성화 되어 있다.
1. 점검
$ systemctl status rc-local.service
비활성화
$ ll /etc/rc.local
존재하지 않는다.
2. /etc/rc.local 파일 생성 및 실행권한 추가
$ sudo vi /etc/rc.local
#! /bin/sh
su - elastic -c "/home/elastic/elasticsearch-8.1.1/bin/elasticsearch -d"
** su - 특정계정 -c "명령어"
elastic 계정으로 /home/elastic/elasticsearch-8.1.1/bin/elasticsearch -d 명령을 실행하란 뜻이다.
$ sudo chmod +x /etc/rc.local
3. rc-local.service 시작및 부팅시 자동실행
$ sudo systemctl status rc-local.service
$ sudo systemctl enable rc-local.service
상태점검
$ sudo systemctl status rc-local.service