mac【启动elasticsearch报错:can not run elasticsearch as root
问题原因
es默认不能用root用户启动,生产环境建议为elasticsearch创建用户。
解决方案
为elaticsearch创建用户并赋予相应权限。
尝试了以下命令创建用户,adduser esh 和useradd都会报错。
bash
Last login: Thu Mar 14 17:48:04 on ttys012
diannao1@xiejiandeMacBook-Air ~ % adduser esh
zsh: command not found: adduser
diannao1@xiejiandeMacBook-Air ~ % useradd esh
zsh: command not found: useradd
diannao1@xiejiandeMacBook-Air ~ % su -
Password:
xiejiandeMacBook-Air:~ root# adduser esh
-sh: adduser: command not found
xiejiandeMacBook-Air:~ root# useradd esh
-sh: useradd: command not found
后来经查询说可以用命令 su - 进入(这个命令非root用户 su - 切换到root用户可以获得权限),如果是linux现在已经可以执行成功了。
(mac输入su命令报错如何重置密可以参考这片帖子http://t.csdnimg.cn/WgYB4)
于是又试了以下命令,还是不行。具体原因应该是因为Mac没有这个命令,linux有
bash
Last login: Thu Mar 14 17:48:04 on ttys012
diannao1@xiejiandeMacBook-Air ~ % adduser esh
zsh: command not found: adduser
diannao1@xiejiandeMacBook-Air ~ % useradd esh
zsh: command not found: useradd
diannao1@xiejiandeMacBook-Air ~ % su -
Password:
xiejiandeMacBook-Air:~ root# adduser esh
-sh: adduser: command not found
xiejiandeMacBook-Air:~ root# useradd esh
-sh: useradd: command not found
接下来又尝试了如下命令
bash
diannao1@xiejiandeMacBook-Air ~ % sudo dscl . -create /Users/esa
Password:
Sorry, try again.
Password:
diannao1@xiejiandeMacBook-Air ~ % sudo dscl . -passwd /Users/esa xj12345
diannao1@xiejiandeMacBook-Air ~ % dscl . list /users
_amavisd
_analyticsd
_appleevents
_applepay
_appowner
_appserver
_appstore
_ard
_assetcache
_astris
_atsserver
_avbdeviced
_calendar
_captiveagent
_ces
_clamav
_cmiodalassistants
_coreaudiod
_coremediaiod
_ctkd
_cvmsroot
_cvs
_cyrus
_datadetectors
_devdocs
_devicemgr
_displaypolicyd
_distnote
_dovecot
_dovenull
_dpaudio
_driverkit
_eppc
_findmydevice
_fpsd
_ftp
_gamecontrollerd
_geod
_hidd
_iconservices
_installassistant
_installer
_jabber
_kadmin_admin
_kadmin_changepw
_krb_anonymous
_krb_changepw
_krb_kadmin
_krb_kerberos
_krb_krbtgt
_krbfast
_krbtgt
_launchservicesd
_lda
_locationd
_lp
_mailman
_mbsetupuser
_mcxalr
_mdnsresponder
_mobileasset
_mysql
_nearbyd
_netbios
_netstatistics
_networkd
_nsurlsessiond
_nsurlstoraged
_ondemand
_postfix
_postgres
_qtss
_reportmemoryexception
_sandbox
_screensaver
_scsd
_securityagent
_softwareupdate
_spotlight
_sshd
_svn
_taskgated
_teamsserver
_timed
_timezone
_tokend
_trustevaluationagent
_unknown
_update_sharing
_usbmuxd
_uucp
_warmd
_webauthserver
_windowserver
_www
_wwwproxy
_xserverdocs
daemon
diannao1
es
esa
esb
nobody
root
diannao1@xiejiandeMacBook-Air ~ %
sudo dscl . -create /Users/esa #这个命令是创建了用户 esb
sudo dscl . -passwd /Users/esa xj12345 #这个命令是给用户设置了一个密码xj12345
dscl . list /users #这个命令显示用户
添加的esa用户在这个位置。
至此,mac创建用户成功。