1. systemctl 용 서비스 script 생성 (예, mysqld.service)
설치 디렉토리에 맞게 조정
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysqluser
Group=mysqlgrp
# Have mysqld write its state to the systemd notify socket
Type=notify
# Disable service start and stop timeout logic of systemd for mysqld
service.
TimeoutSec=0
# Start main service
ExecStart=/mysql/mysql-latest/bin/mysqld --defaults-file=/mysql/etc/my.cnf $MYSQLD_OPTS
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysqld.service
# Sets open_files_limit
LimitNOFILE = 10000
Restart=on-failure
RestartPreventExitStatus=1
# Set environment variable MYSQLD_PARENT_PID. This is required for
restart.
Environment=MYSQLD_PARENT_PID=1
PrivateTmp=false
2. systemctl 디렉토리로 이동 및 권한 부여
cp /tmp/mysqld.service /user/lib/systemd/system
chmod 644 /usr/lib/systemd/system/mysqld.service
systemctl enable mysqld.service
3. 커널에 경로 등록
mysql이 설치된 디렉토리를 systemctl이 접근 할수 있도록 권한 등록
semanage fcontext -a -t bin_t "/mysql/mysql-latest/bin(/.*)?"
restorecon -r -v /mysql/mysql-latest/bin
4. 시작
systemctl start mysqld.service
systemctl status mysqld.service
systemctl stop mysqld.service
'RDB > MySQL' 카테고리의 다른 글
delay replication (0) | 2023.03.28 |
---|---|
semisynchronous replication (0) | 2023.03.28 |
mysql global status 증분값 확인 (1) | 2023.01.29 |
서비스 SLA 시간 (0) | 2023.01.28 |
MySQL Performance 스키마 (0) | 2023.01.27 |