我尝试在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 playbook:
- 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
有什么想法吗?
答案 0 :(得分:0)
问题在于: appendfilename" /var/appendonly.aof"
如果我手动运行$scope.$parent.$on('messageOne', function( event, data ){
console.log( data );
});
,我会看到错误:
' appendfilename" /var/appendonly.aof"' appendfilename不能是路径,只是文件名
由于某些原因,ansible没有显示此错误