首页 文章 精选 留言 我的

精选列表

搜索[部署],共10000篇文章
优秀的个人博客,低调大师

MCollective架构篇7-多MQ下MCollective高可用部署

零基础学习Puppet自动化配置管理系列文档 存在这样一种场景,当你的puppet基于mcollective环境搭建完成之后,需要考虑MQ的高可用,否则,MQ挂掉之后就不能用mco命令进行推送了哦。 如何做MQ的高可用呢,其实有两种方法: 方法一:两台MQ做集群,通过复制队列信息进行同步,节点访问可通过浮动IP进行。 方法二:两台MQ独立,在MC Server端做failover,通过rabbtimq的plugins参数实现,可设置自动检测,切换时间等等。 一、配置Rabbitmq 安装(略),可参考http://kisspuppet.com/2013/11/10/mcollective-middleware/或http://rsyslog.org/2013/11/10/mcollective-middleware/ 1. 开启插件rabbitmq_stomp [root@linuxmaster1poc~]#rabbitmq-pluginsenablerabbitmq_stomp Thefollowingpluginshavebeenenabled: rabbitmq_stomp Pluginconfigurationhaschanged.RestartRabbitMQforchangestotakeeffect. 2. 添加tcp监听端口和范围 [root@linuxmaster1poc~]#vim/etc/rabbitmq/rabbitmq.config [ {rabbitmq_stomp,[{tcp_listeners,[61613]}]} ]. 备注:可参考http://www.rabbitmq.com/stomp.html 3. 创建账户并设置权限 如果你以前配置过,建议将配置清空 [root@linuxmaster1poc~]#rabbitmqctlstop_app Stoppingnoderabbit@linuxmaster1poc... ...done. [root@linuxmaster1poc~]#rabbitmqctlreset Resettingnoderabbit@linuxmaster1poc... ...done. [root@linuxmaster1poc~]#rabbitmqctlstart_app Startingnoderabbit@linuxmaster1poc... ...done. 删除默认用户guest,添加三个用户(web_admin-http访问用,admin--管理员,mc_rabbitmq--mcollective链接用) [root@linuxmaster1poc~]#rabbitmqctllist_users Listingusers... guest[administrator] ...done. [root@linuxmaster1poc~]#rabbitmqctldelete_userguest Deletinguser"guest"... ...done. [root@linuxmaster1poc~]#rabbitmqctladd_usermc_rabbitmq123.com Creatinguser"mc_rabbitmq"... ...done. [root@linuxmaster1poc~]#rabbitmqctladd_useradminpassword=123.com Creatinguser"admin"... ...done. [root@linuxmaster1poc~]#rabbitmqctladd_userweb_admin123.com Creatinguser"web_admin"... ...done. 设置用户的角色 [root@linuxmaster1poc~]#rabbitmqctlset_user_tagsadminadministrator Settingtagsforuser"admin"to[administrator]... ...done. [root@linuxmaster1poc~]#rabbitmqctlset_user_tagsweb_adminmonitoring Settingtagsforuser"web_admin"to[monitoring]... ...done. 创建虚拟主机组 [root@linuxmaster1poc~]#rabbitmqctladd_vhost/mcollective Creatingvhost"/mcollective"... ...done. 设置用户访问虚拟主机组的权限 [root@linuxmaster1poc~]#rabbitmqctlset_permissions-p"/mcollective"mc_rabbitmq".*"".*"".*" Settingpermissionsforuser"mc_rabbitmq"invhost"/mcollective"... ...done. [root@linuxmaster1poc~]#rabbitmqctlset_permissions-p"/mcollective"admin".*"".*"".*" Settingpermissionsforuser"admin"invhost"/mcollective"... ...done. [root@linuxmaster1poc~]#rabbitmqctlset_permissions-p"/mcollective"web_admin".*"".*"".*" Settingpermissionsforuser"web_admin"invhost"/mcollective"... ...done. 重启rabbitmq-server服务 [root@linuxmaster1poc~]#/etc/init.d/rabbitmq-serverrestart Restartingrabbitmq-server:SUCCESS rabbitmq-server. 查看用户以及角色是否创建成功 [root@linuxmaster1poc~]#rabbitmqctllist_users Listingusers... admin[administrator] mc_rabbitmq[] web_admin[monitoring] ...done. 查看虚拟主机组“/mcollective”中所有用户的权限 [root@linuxmaster1poc~]#rabbitmqctllist_permissions-p"/mcollective" Listingpermissionsinvhost"/mcollective"... admin.*.*.* mc_rabbitmq.*.*.* web_admin.*.*.* ...done. [root@linuxmaster1poc~]# 4、登录http://192.168.100.120:15672/设置虚拟主机“/mcollective”的exchanges 默认配置 [root@linuxmaster1poc~]#rabbitmqctllist_exchanges-p"/mcollective" Listingexchanges... direct amq.directdirect amq.fanoutfanout amq.headersheaders amq.matchheaders amq.rabbitmq.tracetopic amq.topictopic ...done. exchanges设置 设置后更新配置 exchanges设置 [root@linuxmaster1poc~]#rabbitmqctllist_exchanges-p"/mcollective" Listingexchanges... direct amq.directdirect amq.fanoutfanout amq.headersheaders amq.matchheaders amq.rabbitmq.tracetopic amq.topictopic mcollective_broadcasttopic mcollective_directeddirect ...done. 备注:可参考官网设置https://www.rabbitmq.com/man/rabbitmqctl.1.man.html 二、 配置MCollective: 1. 配置mcollective client端 [root@linuxmaster1poctesting]#cat/etc/mcollective/client.cfg topicprefix=/topic/ main_collective=mcollective collectives=mcollective libdir=/usr/libexec/mcollective logger_type=console #loglevel=debug loglevel=warn #Plugins securityprovider=psk plugin.psk=a36cd839414370e10fd281b8a38a4f48 direct_addressing=1 connector=rabbitmq plugin.rabbitmq.vhost=/mcollective#虚拟主机 plugin.rabbitmq.pool.size=2#设置地址池里有两个mq plugin.rabbitmq.initial_reconnect_delay=0.01 plugin.rabbitmq.max_reconnect_delay=30.0#重连时间 plugin.rabbitmq.use_exponential_back_off=true plugin.rabbitmq.back_off_multiplier=2 plugin.rabbitmq.max_reconnect_attempts=0 plugin.rabbitmq.randomize=false plugin.rabbitmq.timeout=-1 plugin.rabbitmq.pool.1.host=192.168.100.120 plugin.rabbitmq.pool.1.port=61613 plugin.rabbitmq.pool.1.user=mc_rabbitmq plugin.rabbitmq.pool.1.password=123.com plugin.rabbitmq.pool.1.ssl=false plugin.rabbitmq.pool.2.host=192.168.100.121 plugin.rabbitmq.pool.2.port=61613 plugin.rabbitmq.pool.2.user=mc_rabbitmq plugin.rabbitmq.pool.2.password=123.com plugin.rabbitmq.pool.2.ssl=false #Facts factsource=yaml plugin.yaml=/etc/mcollective/facts.yaml 2. 配置mcollective server端 [root@linux57poctmp]#cat/etc/mcollective/server.cfg #--Global-- topicprefix=/topic/ main_collective=mcollective collectives=mcollective libdir=/usr/libexec/mcollective logfile=/var/log/puppet/mcollective.log loglevel=info daemonize=1 #--rabbitmqPlugins-- securityprovider=psk plugin.psk=a36cd839414370e10fd281b8a38a4f48 direct_addressing=1 connector=rabbitmq plugin.rabbitmq.vhost=/mcollective plugin.rabbitmq.pool.size=2 plugin.rabbitmq.initial_reconnect_delay=0.01 plugin.rabbitmq.max_reconnect_delay=30.0 plugin.rabbitmq.use_exponential_back_off=true plugin.rabbitmq.back_off_multiplier=2 plugin.rabbitmq.max_reconnect_attempts=0 plugin.rabbitmq.randomize=false plugin.rabbitmq.timeout=-1 plugin.rabbitmq.pool.1.host=192.168.100.120 plugin.rabbitmq.pool.1.port=61613 plugin.rabbitmq.pool.1.user=mc_rabbitmq plugin.rabbitmq.pool.1.password=123.com plugin.rabbitmq.pool.1.ssl=false plugin.rabbitmq.pool.2.host=192.168.100.121 plugin.rabbitmq.pool.2.port=61613 plugin.rabbitmq.pool.2.user=mc_rabbitmq plugin.rabbitmq.pool.2.password=123.com plugin.rabbitmq.pool.2.ssl=false #--Puppetproviderspecificoptions-- plugin.service.provider=puppet plugin.service.puppet.hasstatus=true plugin.service.puppet.hasrestart=true plugin.puppet.command=puppetagent plugin.puppet.splay=true plugin.puppet.splaylimit=30 plugin.puppet.config=/etc/puppet/puppet.conf #--Facts-- factsource=yaml ##factsource=facter plugin.yaml=/etc/mcollective/facts.yaml 三、高可用测试 特别注意:节点mcollective的server.cfg中pool是有优先级的,默认数字小的生效,这点需要注意,也就是说当所有节点都连接在MQ2上的时候,启动MQ1,mco命令是无法使用的,因为它在运行的时候连接的是MQ1,而所有节点都连接在MQ2上。 1. 停止MQ1,查看切换状态 1.1 先看当前的节点连接状态 [root@linuxmaster1poc~]#mcoping#查看连接的节点 linux57poctime=69.46ms linux58poctime=70.05ms linux64poctime=70.59ms ----pingstatistics---- 3repliesmax:70.59min:69.46avg:70.03 [root@linuxmaster1poc~]#mcoshell"lsof-i:61613"#查看所有节点监听的端口情况,可以看到目前都连接在linuxmaster1poc上。 Doyoureallywanttosendthiscommandunfiltered?(y/n):y Discoveringhostsusingthemcmethodfor2second(s)....3 Host:linux64poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby36625root6uIPv4277710t0TCPlinux64poc:40493->linuxmaster1poc:61613(ESTABLISHED) Host:linux58poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby11060root6uIPv4340460t0TCPlinux58poc:36295->linuxmaster1poc:61613(ESTABLISHED) Host:linux57poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZENODENAME ruby18076root6uIPv41351365TCPlinux57poc:24698->linuxmaster1poc:61613(ESTABLISHED) [root@linuxmaster1poc~]#/etc/init.d/rabbitmq-serverstop Stoppingrabbitmq-server:rabbitmq-server. 1.2 再次运行mco查看切换状态 [root@linuxmaster1poc~]#mcoping linux58poctime=73.54ms linux64poctime=74.61ms linux57poctime=75.39ms ----pingstatistics---- 3repliesmax:75.39min:73.54avg:74.51 [root@linuxmaster1poc~]#mcoshell"lsof-i:61613" Doyoureallywanttosendthiscommandunfiltered?(y/n):y Discoveringhostsusingthemcmethodfor2second(s)....3 Host:linux58poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby11060root6uIPv4340460t0TCPlinux58poc:36295->linuxmaster1poc:61613(CLOSE_WAIT) ruby11060root9uIPv4341370t0TCPlinux58poc:47200->linuxmaster2poc:61613(ESTABLISHED) Host:linux64poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby36625root6uIPv4277710t0TCPlinux64poc:40493->linuxmaster1poc:61613(CLOSE_WAIT) ruby36625root8uIPv4278770t0TCPlinux64poc:37472->linuxmaster2poc:61613(ESTABLISHED) Host:linux57poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZENODENAME ruby18076root9uIPv41351484TCPlinux57poc:9309->linuxmaster2poc:61613(ESTABLISHED) 通过日志查看 [root@linuxmaster1poc~]#mcoshell"lsof-i:61613" Doyoureallywanttosendthiscommandunfiltered?(y/n):y Discoveringhostsusingthemcmethodfor2second(s)....3 Host:linux58poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby11428root6uIPv4342830t0TCPlinux58poc:36300->linuxmaster1poc:61613(CLOSE_WAIT) ruby11428root8uIPv4343380t0TCPlinux58poc:47205->linuxmaster2poc:61613(ESTABLISHED) Host:linux57poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZENODENAME ruby18447root6uIPv41351559TCPlinux57poc:59343->linuxmaster1poc:61613(CLOSE_WAIT) ruby18447root8uIPv41351622TCPlinux57poc:29757->linuxmaster2poc:61613(ESTABLISHED) Host:linux64poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby37054root4uIPv4280360t0TCPlinux64poc:37476->linuxmaster2poc:61613(ESTABLISHED) ruby37054root6uIPv4279900t0TCPlinux64poc:40497->linuxmaster1poc:61613(CLOSE_WAIT) 总结:可以看到之前的连接已经变成CLOSE_WAIT,新的连接被建立 2. 停止MQ2,启动MQ1 查看切换状态 [root@linuxmaster2pocrabbitmq]#/etc/init.d/rabbitmq-serverstop Stoppingrabbitmq-server:rabbitmq-server. [root@linux57pocservice]#lsof-i:61613 COMMANDPIDUSERFDTYPEDEVICESIZENODENAME ruby18447root6uIPv41351559TCPlinux57poc:59343->linuxmaster1poc:61613(CLOSE_WAIT) ruby18447root8uIPv41351622TCPlinux57poc:29757->linuxmaster2poc:61613(CLOSE_WAIT) [root@linux58poc~]#lsof-i:61613 COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby11428root6uIPv4342830t0TCPlinux58poc:36300->linuxmaster1poc:61613(CLOSE_WAIT) ruby11428root8uIPv4343380t0TCPlinux58poc:47205->linuxmaster2poc:61613(CLOSE_WAIT) [root@linux64poc~]#lsof-i:61613 COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby37054root4uIPv4280360t0TCPlinux64poc:37476->linuxmaster2poc:61613(CLOSE_WAIT) ruby37054root6uIPv4279900t0TCPlinux64poc:40497->linuxmaster1poc:61613(CLOSE_WAIT) [root@linuxmaster1poc~]#/etc/init.d/rabbitmq-serverstart Startingrabbitmq-server:SUCCESS rabbitmq-server. 根据 plugin.rabbitmq.max_reconnect_delay = 30.0,需要过最多30秒,mcollective服务端会重新建立连接请求 [root@linuxmaster1poc~]#tailf/var/log/rabbitmq/rabbit\@linuxmaster1poc.log =INFOREPORT====24-Dec-2013::11:00:45=== acceptingSTOMPconnection<0.332.0>(192.168.100.126:36316->192.168.100.120:61613) =INFOREPORT====24-Dec-2013::11:00:45=== acceptingSTOMPconnection<0.348.0>(192.168.100.125:18945->192.168.100.120:61613) =INFOREPORT====24-Dec-2013::11:00:45=== acceptingSTOMPconnection<0.382.0>(192.168.100.127:40513->192.168.100.120:61613) [root@linuxmaster1poc~]#mcoping linux58poctime=70.60ms linux57poctime=71.32ms linux64poctime=111.56ms ----pingstatistics---- 3repliesmax:111.56min:70.60avg:84.49 [root@linuxmaster1poc~]#mcoshell"lsof-i:61613" Doyoureallywanttosendthiscommandunfiltered?(y/n):y Discoveringhostsusingthemcmethodfor2second(s)....3 Host:linux58poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby11428root6uIPv4342830t0TCPlinux58poc:36300->linuxmaster1poc:61613(CLOSE_WAIT) ruby11428root8uIPv4343380t0TCPlinux58poc:47205->linuxmaster2poc:61613(CLOSE_WAIT) ruby11428root10uIPv4344440t0TCPlinux58poc:36316->linuxmaster1poc:61613(ESTABLISHED) Host:linux57poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZENODENAME ruby18447root10uIPv41351723TCPlinux57poc:18945->linuxmaster1poc:61613(ESTABLISHED) Host:linux64poc Statuscode:0 Output: COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAME ruby37054root4uIPv4280360t0TCPlinux64poc:37476->linuxmaster2poc:61613(CLOSE_WAIT) ruby37054root6uIPv4279900t0TCPlinux64poc:40497->linuxmaster1poc:61613(CLOSE_WAIT) ruby37054root9uIPv4282060t0TCPlinux64poc:40513->linuxmaster1poc:61613(ESTABLISHED) 本文转自凌激冰51CTO博客,原文链接:http://blog.51cto.com/dreamfire/1586729,如需转载请自行联系原作者

优秀的个人博客,低调大师

阿里云服务器CentOS 7.3 64位部署FTP服务

一、安装vsftpd yum -y install vsftpd 二、配置 vsftpd的配置文件在/etc/vsftpd,其中vsftp.conf文件是住配置文件,打开如下: # Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). # 匿名访问,NO关闭,默认为YES开启状态 anonymous_enable=NO # # Uncomment this to allow local users to log in. # When SELinux is enforcing check for SE bool ftp_home_dir local_enable=YES # # Uncomment this to enable any form of FTP write command. write_enable=YES # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. # When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access #anon_upload_enable=YES # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES # # Activate logging of uploads/downloads. xferlog_enable=YES # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # You may override where the log file goes if you like. The default is shown # below. #xferlog_file=/var/log/xferlog # # If you want, you can have your log file in standard ftpd xferlog format. # Note that the default log file location is /var/log/xferlog in this case. xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) #chroot_local_user=YES #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd/chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=NO # # This directive enables listening on IPv6 sockets. By default, listening # on the IPv6 "any" address (::) will accept connections from both IPv6 # and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 # sockets. If you want that (perhaps because you want to listen on specific # addresses) then you must run two copies of vsftpd with two configuration # files. # Make sure, that one of the listen options is commented !! listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES # FTP跟路径设置 local_root=/home 理论上什么都不用修改就可以,但是实际上,我们都会把匿名访问给关闭,和设置一个FTP根路径 anonymous_enable=NO YES改为NO 添加local_root=/home 等号后面为想要设置的文件路径 三、添加用户 useradd ftpadmin -s /sbin/nologin // ftpadmin可改为你的FTP账号 passwd ftpadmin // 设置密码,输入两遍,密码不可见 chown -R ftpadmin /var/ftp // 改动用户权限,格式为chown -R 用户名 文件路径 四、开启服务 service vsftpd start 附:这篇就先这样,以后再更新卸载,vsftpd主配置文件修改及介绍,黑白名单,制定用户配置权限等等

优秀的个人博客,低调大师

centos 安装部署docker与局域网主机相通详细配置

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化.有了docker,对于运维和开发都是福音。下面直接上配置: centos安装docker源: yum install http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm 安装docker: yum install -y docker-io 启动docker: service docker start 如果启动报错的话: /usr/bin/docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference 解决:yum install device-mapper-event-libs 然后再次启动docker即可。 docker可以创建本次仓库,也可以将镜像提交到公有仓库,下面讲创建本地仓库: 创建本地仓库: docker run -d -p 5000:5000 registry 创建完成启动之后,你会发现 使用docker push无法上传此时: 注意 需要https验证:修改/etc/init.d/docker 增加: DOCKER_OPTS="--insecure-registry 192.168.1.231:5000"##我的ip为192.168.1.231,根据实际情况修改 将 $exec -d $other_args &>> $logfile &改成$exec -d $DOCKER_OPTS &>> $logfile & 重新启动docker,再次push就OK了 service docker restart 初步搭建就此完成。下面讲多个服务器之间怎么搭建网桥通讯。 注意事项: 1.docker启动容器之后,或默认创建一个网桥,并且会为启动的容器自动分配一个ip,这个时候可以容器和主机是相通的,但是与其他主机是不通的。 要想与其他容器相通,可以自己建立网桥,将物理网卡加入网桥,并且此时启动的容器必须为手动给到ip(pipeword),要不然会导致局域网内不能上网 设置自定义网桥,修改网络配置: cp /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-br0 vi /etc/sysconfig/network-scripts/ifcfg-br0加入: DEVICE="br0" ONBOOT=yes TYPE="Bridge" BOOTPROTO=ststic IPADDR=192.168.1.215 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS=119.6.6.6 DEFROUTE=yes vi /etc/sysconfig/network-scripts/ifcfg-eth1##将网卡加入网桥 DEVICE=eth0 HWADDR=00:0c:29:a2:9e:53 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none BRIDGE=br0 #IPADDR=192.168.1.215 #NETMASK=255.255.255.0 #GATEWAY=192.168.1.1 重新启动 service network restart 删除以前的网桥:##docker0 为你启动容器时候自动创建 ip link set dev docker0 down brctl delbr docker0 查看网桥: brctl show##此时可以看见了eth0已经加入到网桥了 启动容器的时候,不要自动分配ip,要不然会导致局域网不能上网加上--name xxx --net=none eg: docker run -it --name 123 --net=none centos /bin/bash 使用pipe工具设置静态ip: git clone https://github.com/jpetazzo/pipework 直接进入pipework目录: ./pipework br0##网桥名称 123##容器名称 192.168.1.175/24@192.168.1.1##@后面为网关,此时可以和其他主机相通了 设置时候可能会报错:Object "netns" is unknown, try "ip help" 解决办法:rpm -Uvh https://repos.fedorapeople.org/openstack/EOL/openstack-grizzly/epel-6/iproute-2.6.32-130.el6ost.netns.2.x86_64.rpm 完成之后就可以设置ip了。可以使brctl show可以查看已经多了一个网卡。进入容器可以看到ip已经设置完成 配置ssh登录: yum install openssh-server -y mkdir -p /var/run/sshd /usr/sbin/sshd -D & 修改ssh服务的安全登录配置,取消pam登录限制: 将 session required pam_loginuid.so 注释掉即可 mkdir /root/.ssh cd /root/.ssh ssh-keygen -t rsa##生产公钥 passwd root xxx xxx 最后创建启动脚本 vi /root/run.sh #!/bin/bash /usr/sbin/sshd -D chmod +x /root/run.sh 最后commit镜像即可 启动容器: docker run -d centos /root/run.sh##ssh服务自动开启,此时可以通过ip和密码登录,安装你想安装的东西,然后commit了。 本文转自 674591788 51CTO博客,原文链接:http://blog.51cto.com/mrdeng/1768771

优秀的个人博客,低调大师

Centos7.3部署Elasticsearch5.4.0集群

一、 安装JDK 1.1下载安装 cd /usr/local/src tar -zxvf jdk-8u131-linux-x64.tar.gz mv jdk1.8.0_131 /usr/local/java 1.2修改配置文件 vim /etc/profile //最后面添加 export JAVA_HOME=/usr/local/java CLASSPATH=/usr/local/java/lib/dt.jar/usr/local/java/lib/tools.jar PATH=/usr/local/java/bin:$PATH export PATH JAVA_HOMECLASSPATH source /etc/profile //导入配置文件 java -version //查看java版本 二、安装Elasticsearch 官网:https://www.elastic.co/downloads 参考:http://blog.csdn.net/u013365215/article/details/70159159 2.1下载安装 cd /usr/local/src/ curl -L -Ohttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz tar -xvf elasticsearch-5.4.0.tar.gz mv elasticsearch-5.4.0 /usr/local/ cd /usr/local/elasticsearch-5.4.0/ 2.2系统调优 1)配置系统最大打开文件描述符数 vim /etc/sysctl.conf vm.max_map_count = 262144 执行以下命令生效 sysctl -p 2)配置进程最大打开文件描述符 vim /etc/security/limits.conf //文件最后 * soft nofile 65536 * hard nofile 65536 2.3编写ES Master节点配置文件 vim config/elasticsearch.yml cluster.name: my-es node.name:node-1 network.host:192.168.19.141 http.port: 9200 transport.tcp.port: 9300 discovery.zen.ping.unicast.hosts: ["192.168.19.141","192.168.19.142","192.168.19.143"] discovery.zen.minimum_master_nodes: 2 #避免出现跨域问题 http.cors.enabled: true http.cors.allow-origin: "*" 第二个、第三个节点的配置只需修改成对应的即可。 2.4启动ES 用root账号启动会报错:java.lang.RuntimeException: can not runelasticsearch as root 因为Elasticsearch5.0之后,不能使用root账户启动,我们先创建一个elasticsearch组和账户: groupadd elsearch useradd elsearch -g elsearch -p elasticsearch chown -R elsearch.elsearch /usr/local/elasticsearch-5.4.0/ 后台启动: su -elsearch -c "/usr/local/elasticsearch-5.4.0/bin/elasticsearch -d" 2.5安装head开源插件 参考:http://blog.csdn.net/ronmy/article/details/63685254 只在master上安装插件即可。elasticsearch5不可以直接通过plugin -install mobz/elasticsearch-head安装,并且head需要在node环境下运行,具体步骤如下: 第一步:安装node curl -sL -o /etc/yum.repos.d/khara-nodejs.repohttps://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repo yum install -y nodejs nodejs-npm 查看安装版本 第二步:安装grunt cd /usr/lib/node_modules/npm/ npm install grunt-cli npm install grunt 查看版本: /usr/lib/node_modules/npm/node_modules/.bin/grunt -version 第三步:安装head yum install -y git cd /usr/local/ git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-head/ npm install 注意:这步可以会有一些报错信息,可以忽略。 vim _site/app.js #修改『http://localhost:9200』字段到本机ES端口与IP 第四步:启动head并在后台运行 ./node_modules/grunt/bin/gruntserver & 浏览器访问: 注意:若不能形成集群,可能是 iptables 或者 selinux 的原因 2.6开机自启 vim /etc/rc.local su - elsearch -c "/usr/local/elasticsearch-5.3.1/bin/elasticsearch -d" /usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server & 保存退出后,给自启文件赋予执行权限(若不加,Centos7不会开机执行) chmod +x /etc/rc.d/rc.local 本文转自M四月天 51CTO博客,原文链接:http://blog.51cto.com/msiyuetian/1926325,如需转载请自行联系原作者

优秀的个人博客,低调大师

Centos7部署ntp服务器同步时间

查看时区列表: timedatectl list-timezones|grep Asia 设置中国时区: timedatectl set-timezone Asia/Shanghai 执行完后时间就变为北京时间了 查看当前时间: date 查看当前设置: [root@localhost ~]# timedatectl Local time: Mon 2017-10-09 16:44:08 CST Universal time: Mon 2017-10-09 08:44:08 UTC RTC time: Mon 2017-10-09 08:44:08 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a 如果没有系统没有安装ntp服务器的话可以安装yum install ntp -y 然后编辑ntp的配置文件vi /etc/ntp.conf (日志文件默认在/var/log/messages中),添加以下几个服务器域名,如果原配置文件没有的话 server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst systemctl restart ntpd systemctl enable ntpd 这样,服务器端就配置得差不多了,但我为了让效果更明显,把服务器修改为纽约时区,另一台需要同步的linux客户端的时区修改为非洲时间,结果导致,客户端ntpdate之后没有同步,后来才发现,需要在同一时区内才能同步时间,也就是说,服务端和客户端的时区必须在中国这个时区内才可以 下面来测试我们的ntp服务器配置有没有成功 在服务器端(ip:10.0.3.66)上 使用date -s 23:30:30 (时间可以随便改,反正改一个跟客户端时间不一样的就可以了),然后date可以看到时间变成了23:30:30 在客户端上 ntpdate 10.0.3.66 执行后发现,时间也变成了23:30:30

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册