[英]Redis in Vagrant(Ubuntu): how to forward redis port?
我試圖在Vagrantbox(帶有Ubuntu映像)中將redis運行到主機端口16379的前向端口6379,但由於原因我不能這樣做。 所以,我像這樣使用Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 6379, host: 16379
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
end
和ansible劇本:
- name: Prepare redis host
hosts: all
sudo: true
vars:
redis_conf_path: /etc/redis.conf
tasks:
- name: set locale
lineinfile: dest=/etc/default/locale line="LC_ALL=C"
- name: install redis
apt: name=redis-server update_cache=yes
- name: create user redis
user:
name: redis
system: yes
home: "/var/lib/redis"
shell: "/bin/false"
- name: create the redis configuration file
template:
src: redis.conf.j2
dest: "{{ redis_conf_path }}"
mode: 0644
backup: yes
notify:
- restart redis
- name: start redis
service:
name: redis-server
state: started
arguments: "{{ redis_conf_path }}"
enabled: yes
handlers:
- name: restart redis
service:
name: redis-server
state: restarted
enabled: yes
哪個做簡單的事情,使用下面的配置文件安裝和配置redis:
appendonly yes
appendfilename "/var/appendonly.aof"
appendfsync everysec
bind 0.0.0.0
所以,當我嘗試ping主機時,我有一個錯誤如下:
host> redis-cli -p 16379 ping
Error: Server closed the connection
當我在客戶機內運行ping時,一切正常:
vm> redis-cli ping
PONG
有任何想法嗎?
問題在於:appendfilename“/var/appendonly.aof”
如果我手動運行redis-server redis.conf
,我會看到一個錯誤:
'appendfilename“/var/appendonly.aof”'appendfilename不能是路徑,只是文件名
由於某些原因,ansible不會顯示此錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.