linux redis 启动用户,redis 进程使用root用户启动 -- 整改方案
最近內(nèi)部風(fēng)險(xiǎn)整改, 各種進(jìn)程使用root身份進(jìn)行啟動(dòng)不符合要求,
于是各路神仙各施其法,為的就是讓 某進(jìn)程不以root 啟動(dòng):
先以 redis 為例:
原有進(jìn)程如下:
#超一流標(biāo)準(zhǔn)的執(zhí)行文件位置及配置文件位置
root ? ? 9602? ? ? 1? 0 23:25 ?? ? ? ? 00:00:00? ?/usr/bin/redis-server? /etc/redis/redis.conf
于是有了以下操作:
一 、簡(jiǎn)單直接類
# kill -9 9602
# su? ?redis
this account is currently not available
# usermod -s /bin/bash
# su redis
#?/usr/bin/redis-server? /etc/redis/redis.conf
于是redis由一個(gè)非登錄用戶變成了一個(gè)登陸用戶,而且下次開(kāi)機(jī)還是要手動(dòng)啟動(dòng)一次進(jìn)程。。
二、開(kāi)機(jī)啟動(dòng)類
# echo 'su -c "/usr/bin/redis-server? /etc/redis/redis.conf" redis ' >> /etc/rc.local
測(cè)試了一下
#? /bin/bash /etc/rc.local
this account is currently not available
# vi??/etc/rc.local
把redis改為了 newuser
# useradd newuser
#??/bin/bash /etc/rc.local
于是服務(wù)開(kāi)機(jī)啟動(dòng)設(shè)置成功,但redis被棄用了。。
三 、 服務(wù)設(shè)置類 (推薦)
# echo '
[unit]
description=redis daemon
[service]
type=forking
#這個(gè)是配置啟動(dòng)用戶
user=redis
execstart=?/usr/bin/redis-server? /etc/redis/redis.conf
execreload=/bin/kill -hup $mainpid
killmode=process
restart=on-failure
restartsec=42s
[install]
wantedby=multi-user.target
'? >? /usr/lib/systemd/system/redisd.service
# chown -r redis /var/log/redis/? ? ?(日志文件redis需要有讀寫(xiě)權(quán)限,具體日志文件位置不細(xì)說(shuō) 我的就當(dāng)作放在這里)
# systemctl start redisd
# systemctl enable redisd
created symlink from /etc/systemd/system/multi-user.target.wants/redisd.service to /usr/lib/systemd/system/redisd.service
# ps -ef|grep redisd
redis? ? ?10175? ? ? 1? 0 23:52 ?? ? ? ? 00:00:00 /usr/bin/redis-server *:6379
設(shè)置成了服務(wù)自啟動(dòng),還是以redis用戶啟動(dòng)了,是不是很高大上?
總結(jié)
以上是生活随笔為你收集整理的linux redis 启动用户,redis 进程使用root用户启动 -- 整改方案的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c++语言 tcp例子,C++中TCP通
- 下一篇: linux 下nc-verilog 仿真