首页 文章 精选 留言 我的

精选列表

搜索[基础软件],共10000篇文章
优秀的个人博客,低调大师

smart_Activity互相跳转——基础编

让我们看一下原代码: packagecom.smart.activity; importandroid.app.Activity; importandroid.content.ComponentName; importandroid.content.Intent; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.Button; publicclassMainextendsActivity{ //ANDROID系统,组件与组件之间是通过,INTENT进行通信的。 @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); Buttonbutton=(Button)this.findViewById(R.id.button); button.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ //打开新的Activity //第一种方法调用 Intentintent=newIntent(Main.this,SmartActivity.class); //打开应用的组件 Main.this.startActivity(intent); //第二种方法调用 //Intentintent=newIntent(); //intent.setClass(Main.this,SmartActivity.class); //第三种方法调用 //Intentintent=newIntent(); //intent.setComponent(newComponentName(Main.this,SmartActivity.class)); //意思是讲三种方法调查用,意是一样的, //一般来讲用第一种 } }); } } packagecom.smart.activity; importandroid.app.Activity; importandroid.content.Intent; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.Button; publicclassSmartActivityextendsActivity{ @Override protectedvoidonCreate(BundlesavedInstanceState){ //关于这行代码,是完成界面的代码 super.onCreate(savedInstanceState); setContentView(R.layout.smart); Buttonbutton2=(Button)this.findViewById(R.id.button2); button2.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ //打开新的Activity //第一种方法调用 Intentintent=newIntent(SmartActivity.this,Main.class); //打开应用的组件 SmartActivity.this.startActivity(intent); //第二种方法调用 //Intentintent=newIntent(); //intent.setClass(Main.this,SmartActivity.class); //第三种方法调用 //Intentintent=newIntent(); //intent.setComponent(newComponentName(Main.this,SmartActivity.class)); //意思是讲三种方法调查用,意是一样的, //一般来讲用第一种 } }); } } 本文转自 llb988 51CTO博客,原文链接:http://blog.51cto.com/llb988/490078,如需转载请自行联系原作者

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

确定取消经典之作——基础编

让我们看一下效果图 packagecom.smart; importandroid.app.Activity; importandroid.app.AlertDialog; importandroid.content.DialogInterface; importandroid.os.Bundle; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; /** *不知道看的朋友,认识,如何,我觉得挺经典的按钮之作 *如有问题,请发自llb988@126.com **/ publicclassMainextendsActivityimplementsOnClickListener{ /**Calledwhentheactivityisfirstcreated.*/ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); //得到按钮ID Buttonbutton=(Button)findViewById(R.id.button); //进行监听 button.setOnClickListener(this); } @Override//断送确定与取消方法 publicvoidonClick(Viewv){ newAlertDialog.Builder(this).setIcon(R.drawable.question).setTitle("是否删除文件").setPositiveButton("确定",newDialogInterface.OnClickListener(){ @Override publicvoidonClick(DialogInterfacedialog,intwhich){ newAlertDialog.Builder(Main.this).setMessage("文件已删除").create().show(); } }).setNegativeButton("取消",newDialogInterface.OnClickListener(){ @Override publicvoidonClick(DialogInterfacedialog,intwhich){ newAlertDialog.Builder(Main.this).setMessage("您选择取消按钮,文件未被删除").create().show(); } }).show(); } } 本文转自 llb988 51CTO博客,原文链接:http://blog.51cto.com/llb988/489541,如需转载请自行联系原作者

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

Toast使用方法——简单基础编

Toast内容显示图 packagecom.smart; importandroid.app.Activity; importandroid.content.DialogInterface; importandroid.os.Bundle; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; importandroid.widget.TextView; importandroid.widget.Toast; publicclassMainextendsActivityimplementsOnClickListener{ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main);//得到参数 ButtonbtnTextToast=(Button)findViewById(R.id.btnTextToast); ButtonbtnImageToast=(Button)findViewById(R.id.btnImageToast); btnTextToast.setOnClickListener(this);//绑定器 btnImageToast.setOnClickListener(this); } //点击方法事件 @Override publicvoidonClick(Viewv){ switch(v.getId()){ caseR.id.btnTextToast: //使用TOAST方法显示结果内容 ToasttextToast=Toast.makeText(this,"新年好,我的朋友们,\n哈,哈,哈!",Toast.LENGTH_LONG); textToast.show(); break; caseR.id.btnImageToast: Viewview=getLayoutInflater().inflate(R.layout.toast,null); TextViewtextView=(TextView)view.findViewById(R.id.smart); //使用TOAST方法显示结果内容 textView.setText("新年好,我的朋友们,\n哈,哈,哈!"); Toasttoast=newToast(this); toast.setDuration(Toast.LENGTH_LONG); toast.setView(view); toast.show(); break; } } } 本文转自 llb988 51CTO博客,原文链接:http://blog.51cto.com/llb988/489546,如需转载请自行联系原作者

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

android中进度条—基础篇

本文转自 llb988 51CTO博客,原文链接:http://blog.51cto.com/llb988/486075,如需转载请自行联系原作者 android progrssbar 进度条即计算机在处理文件时,实时的,以图片形式显示处理文件的速度,完成度,剩余未完成文件的大小,和可能需要处理时间,一般以水平或者是图形条状显示 类代码 package com.smart; import android.app.Activity; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.Window; import android.widget.Button; import android.widget.ProgressBar; public class Main extends Activity implements OnClickListener { // 各位在导入包的时候,记住要导入import android.view.View.OnClickListener; private ProgressBar progressbarHorizontal; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.main); setProgressBarIndeterminateVisibility(true); progressbarHorizontal = (ProgressBar) findViewById(R.id.progressBarHorizontal); Button button1 = (Button) findViewById(R.id.button1); Button button2 = (Button) findViewById(R.id.button2); // 绑定器 button1.setOnClickListener(this); button2.setOnClickListener(this); } @Override public void onClick(View view) { switch (view.getId()) { // 处理“增加进度"按钮事件 case R.id.button1: progressbarHorizontal.setProgress((int) (progressbarHorizontal .getProgress() * 1.18)); progressbarHorizontal .setSecondaryProgress((int) (progressbarHorizontal .getSecondaryProgress() * 1.18)); break; // 处理“减少进度"按钮事件 case R.id.button2: progressbarHorizontal.setProgress((int) (progressbarHorizontal .getProgress() * 0.88)); progressbarHorizontal .setSecondaryProgress((int) (progressbarHorizontal .getSecondaryProgress() * 0.88)); break; } } } main.xml 代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SMART圆形进度条1" /> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/progressBarStyleSmallTitle"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SMART圆形进度条2" /> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SMART圆形进度条3" /> <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" style="?android:attr/progressBarStyleLarge" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="SMART水平进度条4" /> <ProgressBar android:layout_width="fill_parent" android:layout_height="wrap_content" style="?android:attr/progressBarStyleHorizontal" android:max="100" android:progress="30" /> <ProgressBar android:id="@+id/progressBarHorizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" style="?android:attr/progressBarStyleHorizontal" android:max="100" android:progress="30" android:secondaryProgress="60" android:layout_marginTop="20dp" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:text="进度增加" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:text="进度减小" /> </LinearLayout> </LinearLayout>

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

openstack学习笔记二 网络设置基础

租用这个服务的机构,我们称之"租户/tenant/项目/project" 租户 用户 vxlan划分租户 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [root@h1~] #ipaddr 1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWN link /loopback 00:00:00:00:00:00brd00:00:00:00:00:00 inet127.0.0.1 /8 scopehostlo valid_lftforeverpreferred_lftforever 2:eth0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscmqstateUPqlen1000 link /ether 00:50:56:a0:b6:6bbrdff:ff:ff:ff:ff:ff inet192.168.1.201 /24 brd192.168.1.255scopeglobaleth0 valid_lftforeverpreferred_lftforever 3:ovs-system:<BROADCAST,MULTICAST>mtu1500qdiscnoopstateDOWN link /ether 36:26:25:65:14:9cbrdff:ff:ff:ff:ff:ff 4:br-ex:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscnoqueuestateUNKNOWN link /ether de:4c:6d:9c:15:4dbrdff:ff:ff:ff:ff:ff 5:br-int:<BROADCAST,MULTICAST>mtu1500qdiscnoopstateDOWN link /ether ce:0b:9b:b5:c1:4dbrdff:ff:ff:ff:ff:ff 6:br-tun:<BROADCAST,MULTICAST>mtu1500qdiscnoopstateDOWN link /ether ae:75:26:fb:f8:42brdff:ff:ff:ff:ff:ff 你想把哪个网络作为数据包的出口,那么你就应该把那个网卡桥接到 br-ex openvswitch 简称 ovs 配置网卡 重点 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [root@h1network-scripts] #catifcfg-eth0 DEVICE=eth0 DEVICETYPE=ovs TYPE=OVSPort OVS_BRIDGE=br-ex ONBOOT= yes BOOTPROTO=none [root@h1network-scripts] #catifcfg-br-ex DEVICE=br-ex DEVICETYPE=ovs TYPE=OVSBridge ONBOOT= yes BOOTPROTO=none IPADDR=192.168.1.201 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS1=202.106.0.20 1 2 3 4 5 6 7 8 9 10 查看网卡 2:eth0:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscmqmasterovs-systemstateUPqlen1000 link /ether 00:50:56:a0:b6:6bbrdff:ff:ff:ff:ff:ff 3:ovs-system:<BROADCAST,MULTICAST>mtu1500qdiscnoopstateDOWN link /ether d2:18:7d:5e:5e:b9brdff:ff:ff:ff:ff:ff 5:br-ex:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscnoqueuestateUNKNOWN link /ether 00:50:56:a0:b6:6bbrdff:ff:ff:ff:ff:ff inet192.168.1.201 /24 brd192.168.1.255scopeglobalbr-ex valid_lftforeverpreferred_lftforever 管理员登陆http://192.168.1.201/dashboard 选择系统--网络--创建网络 创建,点击网络名称put-ex 下一步 创建一个项目,创建一个新的用户,新用户关联项目。 用新的用户登录,创建网络 先创建网络,然后创建路由,连到网络上,最后添加端口 本文转自 295631788 51CTO博客,原文链接:http://blog.51cto.com/hequan/1795705,如需转载请自行联系原作者

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

学习OpenStack之 (0):基础知识

vi 方向键出现字母问题解决方法 执行命令 sudo apt-get remove vim-common 执行命令 sudo apt-get install vim 鼠标被virtualbox捕获无法释放 按右Control键可以释放鼠标 使服务在机器重启后自启动 sudo update-rc.d ssh defaults IP段表示方法 原来“/”后面的数字其实代表了掩码。正常情况下,掩码中的“1”是不可间断的,这样只要知道掩码中“1”的个数,就可以唯一地确定一个掩码。比如“/24”就表示掩码中有24个“1”,即“11111111 11111111 11111111 00000000”,用十进点分法表示就是“255.255.255.0”。 192.168.2.12与192.168.2.20 换成2进制 192.168.2.12二进制11000000.10101000.00000010.00001100 192.168.2.20二进制11000000.10101000.00000010.00010100 相与,有27位地址相同,所以可以写成192.168.2.12/27 主机位就是2的5次方,192168.2.12/27 有32个主机位 tar命令 tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。 -z:有gzip属性的 -j:有bz2属性的 -Z:有compress属性的 -v:显示所有过程 -O:将文件解开到标准输出 下面的参数-f是必须的 -f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。 # tar -cf all.tar *.jpg 这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。 # tar -rf all.tar *.gif 这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。 # tar -uf all.tar logo.gif 这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。 # tar -tf all.tar 这条命令是列出all.tar包中所有文件,-t是列出文件的意思 # tar -xf all.tar 这条命令是解出all.tar包中所有文件,-x是解开的意思 压缩 tar –cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg tar –czf jpg.tar.gz *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz tar –cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2 tar –cZf jpg.tar.Z *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux 解压 tar –xvf file.tar //解压 tar包 tar -xzvf file.tar.gz //解压tar.gz tar -xjvf file.tar.bz2 //解压 tar.bz2 tar –xZvf file.tar.Z //解压tar.Z unrar e file.rar //解压rar unzip file.zip //解压zip 总结 1、*.tar 用 tar –xvf 解压 2、*.gz 用 gzip -d或者gunzip 解压 3、*.tar.gz和*.tgz 用 tar –xzf 解压 4、*.bz2 用 bzip2 -d或者用bunzip2 解压 5、*.tar.bz2用tar –xjf 解压 6、*.Z 用 uncompress 解压 7、*.tar.Z 用tar –xZf 解压 8、*.rar 用 unrar e解压 9、*.zip 用 unzip 解压 指定ubuntu的源,参考http://chenrongya.blog.163.com/blog/static/8747419620143185103297/ 配置静态ip地址 $sudo vi /etc/network/interfaces 原有内容只有如下两行: auto lo iface lo inet loopback 向末尾追加以下内容: auto eth0 iface eth0 inet static address 192.168.0.33 gateway 192.168.0.1 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 然后保存退出; 修改机器名: 修改/etc/hostname 和 /etc/hosts,再重启机器 W: GPG error: http://ppa.launchpad.net lucid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A1715D88E1DF1F24 Google 之,在这篇文档里有提到解决方案: http://muzso.hu/2007/05/25/how-to-fix-no_pubkey-errors-in-apt-get-update-operations 具体的解决方法步骤是(注意下面的KEY 是根据每次报错而不同的,可能需要用实际报错的KEY替换命令中的KEY值): $ sudo gpg --keyserver keyserver.ubuntu.com --recv A1715D88E1DF1F24 $sudo gpg --export --armor A1715D88E1DF1F24 | sudo apt-key add - 注:上面第二个命令中的第二个sudo,因为sudo不能跨越Pipe,所以第二个命令也需要使用sudo 在ubuntu上安装ssh server 现象: ssh client无法连到ubuntu sammydeair:~ Sammy$ ssh -l s1 10.211.55.4 ssh: connect to host 10.211.55.4 port 22: Connection refused 查看: ubuntu上ssh local,同样错误,发现是openssh-server没安装 解决: $ sudo apt-getupdate //视网络情况会花比较长的时间 $ sudo apt-getupgrade $ sudo apt-get install openssh-server $sudo /etc/init.d/ssh start 在Mac上使用过要license的Parallels Desktop和免费的VirtualBox,比较结果如下: 1. VirtualBox对鼠标的捕获和控制更加友好,Parallels需要按键来释放鼠标,但是VirtualBox里面完全自动。 2. VirtualBox里面虚拟机的运行速度似乎更快,至少关机比Parallels快。 3.VirutalBox里面可以很方便地复制虚拟机,但是在Parallels Desktop里面不知道什么原因“克隆”菜单为灰色不可用。 4. VirtualBox里面多网卡配置更方便。 5. google查到的VirtualBox的文章比Parallels Desktop多得多 至少在我看来,免费的VirtualBox要比收费的Parallels要好些。接下里继续体会VirtualBox。 在Ubuntu里面配置静态IP使得可以连接外网 1. 关闭虚机,在VirtualBox里面,设置虚机的一个网卡为桥接模式 2. 查看主机的DNS server 3. 开虚机,运行ifconfig和route命令,查看该网卡自动获得的IP,netmask,gateway s1@compute1:~$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 4. 运行命令vi /etc/network/interfaces,设置静态IP,gateway,broadcast,netmask auto eth0 iface eth0 inet static address 192.168.1.15 netmask 255.255.255.0 gateway 192.168.1.1 5.配置DNS, 运行vi /etc/resolvconf/resolv.conf.d/tail, 从而在/etc/resolvconf/resolv.conf.d/目录下创建tail文件,写入 nameserver 192.168.1.1 然后重启,DNS生效 6.测试。ping www.sohu.com s1@compute1:~$ ping www.sohu.com PING fsh.a.sohu.com (114.80.130.88) 56(84) bytes of data. 64 bytes from www.sohu.com (114.80.130.88): icmp_seq=1 ttl=56 time=4.65 ms 64 bytes from www.sohu.com (114.80.130.88): icmp_seq=2 ttl=56 time=6.91 ms 64 bytes from www.sohu.com (114.80.130.88): icmp_seq=3 ttl=56 time=5.39 ms VirtualBox 虚拟机的几种网络连接方式 (1)NAT(网络地址转换模式):能从虚拟机访问外网,主机不能访问虚拟机。 网络地址转换( NAT )是最简单的方法从一个虚拟机访问外部网。通常,它并不要求在主机网络和客户机上做任何配置。基于这个原因,它是默认的网络模式 。 原理:客户机(即虚拟机)送出的网络帧被 VirtualBox 的 NAT 引擎收到,抽取 TCP/IP 数据,再通过主机的操作系统(即安装 VirtualBox 的操作系统)重新发送出去。送到在主机上的一个应用程序,或者到位于主机同一网络的另一台计算机上,它看起来好象是安装在主机上的程序 VirtualBox,通过一个属于主机的 IP 地址,把数据发送出去。VirtualBox 倾听到数据包裹的回复,通过客户机的私人网络重新包装和发送往客户机上。 效果:使用NAT模式,就是让虚拟系统借助NAT(网络地址转换)功能,通过宿主机器所在的网络来访问公网。但纯NAT模式下,宿主机不能访问虚拟机。 使用场景:如果你想利用安装一个新的虚拟系统,在虚拟系统中不用进行任何手工配置就能直接访问互联网,建议你采用NAT模式. (2)Bridged方式:虚拟机和主机拥有同样的网络功能,能互相访问。 用这种方式,虚拟系统的IP可设置成和本机系统在同一网段,虚拟系统相当于网络内的一台独立的机器,和本机一起插在一个Hub上,网络内其他机器可访问虚拟系统,虚拟系统也可访问网络内其他机器,当然和本机系统的双向访问也不成问题。 (3)内部网络:虚拟机之间可以互相访问,虚拟机不能访问外网,主机和虚机之间不能访问。 内网模式,顾名思义就是内部网络模式: 虚拟机与外网完全断开,只实现虚拟机于虚拟机之间的内部网络模式。 (1)虚拟机与主机的关系:不能相互访问,彼此不属于同一个网络,无法相互访问。 (2)虚拟机与网络中其他主机的关系:不能相互访问,理由同上。 (3)虚拟机与虚拟机的关系:可以相互访问,前提是在设置网络时,两台虚拟机设置同一网络名称。 (4)host-only方式 (主机模式):虚拟机不能访问外网,主机可以访问虚拟机。 Virtualbox在宿主机中模拟出一张专供虚拟机使用的网卡,所有虚拟机都是连接到该网卡上的,虚拟机可以通过该网卡IP访问宿主机,同时Virtualbox提供一个DHCP服务,虚拟机可以获得一个内部网IP,宿主机可以通过该IP访问虚拟机。如果单纯使用Host-only模式,则虚拟机不能连接外部公共网络。 (5)通用驱动 作用和效果:运行用于选择网卡驱动。该驱动是virtualbox内部自带的,或者是通过extensionpack添加进来的。此模式实际上很少用到 一般来说,Bridged方式最方便好用。但如果本机系统是win2000而网线没插(或根本没有网卡),网络非常可能不可用(大部分用PCI网卡的机器都如此),此时就只能用NAT方式或host-only,之前所说的那两块虚拟网卡就是适应这两种网络准备的。 使用NAT和host-only混合模式,使得虚拟机既能访问外网,主机也能访问虚机 在虚机关机状态下配置网络,网卡1使用NAT模式,网卡2使用host-only模式。 1. 检查宿主机上host-only adapter的网络设置 当添加多个网卡时,比如 eth0 是 NAT 模式用于虚机访问外网,eth1 是 host-only 模式用于宿主机访问虚机,eth2 是internal 模式用于虚机之间互访,需要注意 default gateway。设置不对的话,虚机是不能访问外网的。当专有 eth0 时候,default gw 是它自己,当增加 eth1 和 eth2 后,default gw 就跑到了 eth2上,而 eth2 是不能用于外网访问的。因此,此时需要手工修改 default gw,修改为: route del default gw 192.168.1.1 route add default gw 10.0.2.2 eth0 root@ceph1:~# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0 10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2 192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 root@ceph1:~# ping www.sohu.com PING fhk.a.sohu.com (175.100.207.201) 56(84) bytes of data. 64 bytes from 175.100.207.201: icmp_seq=1 ttl=41 time=133 ms 64 bytes from 175.100.207.201: icmp_seq=2 ttl=41 time=69.9 ms 64 bytes from 175.100.207.201: icmp_seq=3 ttl=41 time=69.4 ms 64 bytes from 175.100.207.201: icmp_seq=4 ttl=41 time=68.5 ms 64 bytes from 175.100.207.201: icmp_seq=5 ttl=41 time=71.9 ms 注意 eth0 的 default gw 是 10.0.2.2 而不是 10.0.2.1. 2. 开启虚拟机配置网络 sudo vi /etc/network/interfaces sudo /etc/init.d/networking restart 可运行ifconfig查看ip 3. 可以从主机ping和ssh虚拟机了 本文转自SammyLiu博客园博客,原文链接:http://www.cnblogs.com/sammyliu/p/4139246.html,如需转载请自行联系原作者

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

centos6 - elk基础入门搭建

1 2 3 4 5 6 7 [root@host-192-168-53-108~] #rm-rf/etc/yum.repos.d/* [root@host-192-168-53-108~] #wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo [root@host-192-168-53-108~] #yumcleanall [root@host-192-168-53-108~] #yum-yinstalljava-1.8.0-openjdk* [root@host-192-168-53-108~] #wgethttps://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.rpm [root@host-192-168-53-108~] #rpm-ivhelasticsearch-5.5.0.rpm [root@host-192-168-53-108~] #chkconfig--addelasticsearch 1 2 [root@host-192-168-53-108~] #cat/etc/hosts 192.168.53.108elk1 1 2 3 4 5 6 7 8 9 [root@host-192-168-53-108~] #cat/etc/elasticsearch/elasticsearch.yml node.name:elk1 network.host:192.168.53.108 http.port:9200 bootstrap.memory_lock: false bootstrap.system_call_filter: false discovery.zen. ping .unicast.hosts:[elk1] http.cors.enabled: true http.cors.allow-origin: "*" 1 2 3 4 [root@host-192-168-53-108~] #cat/etc/elasticsearch/jvm.options|grep-v'^#'|grep-v^$ #修改 -Xms6g -Xmx6g 1 2 3 4 5 [root@host-192-168-53-108~] #vim/etc/security/limits.conf *softnofile1000000 *hardnofile1000000 *softnproc1000000 *hardnproc1000000 1 2 3 [root@host-192-168-53-108~] #cat/etc/security/limits.d/90-nproc.conf *softnproc100000 rootsoftnprocunlimited 1 2 3 4 5 6 [root@host-192-168-53-108~] #cd/usr/local/ [root@host-192-168-53-108 local ] #gitclonegit://github.com/mobz/elasticsearch-head.git [root@host-192-168-53-108 local ] #wgethttps://nodejs.org/dist/v8.2.0/node-v8.2.0-linux-x64.tar.gz--no-check-certificate [root@host-192-168-53-108 local ] #tarzxfnode-v8.2.0-linux-x64.tar.gz [root@host-192-168-53-108 local ] #ln-s/usr/local/node-v8.2.0-linux-x64/bin/node/usr/sbin/node [root@host-192-168-53-108 local ] #ln-s/usr/local/node-v8.2.0-linux-x64/bin/npm/usr/sbin/npm 1 2 3 4 5 #设置npm代理镜像 [root@host-192-168-53-108 local ] #npmconfigsetregistryhttps://registry.npm.taobao.org [root@host-192-168-53-108 local ] #npminstall-ggrunt [root@host-192-168-53-108 local ] #ln-s/usr/local/node-v8.2.0-linux-x64/lib/node_modules/grunt/bin/grunt/usr/sbin/grunt [root@host-192-168-53-108 local ] #cdelasticsearch-head/ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [root@host-192-168-53-108elasticsearch- head ] #npminstall Errormakingrequest. Error:connectETIMEDOUT52.216.1.0:443 atObject.exports._errnoException(util.js:1024:11) atexports._exceptionWithHostPort(util.js:1047:20) atTCPConnectWrap.afterConnect[asoncomplete](net.js:1150:14) Pleasereportthisfulllogathttps: //github .com /Medium/phantomjs npmWARNelasticsearch- head @0.0.0licenseshouldbeavalidSPDXlicenseexpression npmWARNoptionalSKIPPINGOPTIONALDEPENDENCY:fsevents@1.1.2(node_modules /fsevents ): npmWARNnotsupSKIPPINGOPTIONALDEPENDENCY:Unsupportedplatform for fsevents@1.1.2:wanted{ "os" : "darwin" , "arch" : "any" }(current:{ "os" : "linux" , "arch" : "x64" }) npmERR!codeELIFECYCLE npmERR!errno1 npmERR!phantomjs-prebuilt@2.1.14 install :`node install .js` npmERR!Exitstatus1 npmERR! npmERR!Failedatthephantomjs-prebuilt@2.1.14 install script. npmERR!Thisisprobablynotaproblemwithnpm.Thereislikelyadditionalloggingoutputabove. npmERR!Acompletelogofthisruncanbefound in : npmERR! /root/ .npm /_logs/2017-07-26T11_29_47_063Z-debug .log 1 2 [root@host-192-168-53-108elasticsearch- head ] #npminstallphantomjs-prebuilt@2.1.14--ignore-scripts [root@host-192-168-53-108elasticsearch- head ] #npminstall 1 2 3 4 [root@host-192-168-53-108elasticsearch- head ] #vim/usr/local/elasticsearch-head/_site/app.js #把localhost改为ip this.base_uri=this.config.base_uri||this.prefs.get( "app-base_uri" )|| "http://localhost:9200" ; this.base_uri=this.config.base_uri||this.prefs.get( "app-base_uri" )|| "http://192.168.53.108:9200" ; 1 2 3 4 5 6 7 8 9 10 11 [root@host-192-168-53-108elasticsearch- head ] #vim/usr/local/elasticsearch-head/Gruntfile.js connect:{ server:{ options:{ hostname : "0.0.0.0" , #添加此行 port:9100, base: '.' , keepalive: true } } } 1 2 3 4 [root@host-192-168-53-108elasticsearch- head ] #gruntserver& [root@host-192-168-53-108elasticsearch- head ] #echo"cd/usr/local/elasticsearch-head;gruntserver&">>/etc/rc.local [root@host-192-168-53-108elasticsearch- head ] #cd [root@host-192-168-53-108~] #wgethttps://artifacts.elastic.co/downloads/logstash/logstash-5.5.0.rpm 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [root@host-192-168-53-108~] #vim/etc/logstash/conf.d/system.conf input{ file { path=> "/var/log/messages" type => "systemlog" start_position=> "beginning" stat_interval=> "2" } } output{ elasticsearch{ hosts=>[ "192.168.53.108:9200" ] index=> "logstash-systemlog-%{+YYYY.MM.dd}" } } 1 [root@host-192-168-53-108~] #/usr/share/logstash/bin/logstash-f/etc/logstash/conf.d/system.conf 1 2 #在Elasticsearch中查看 #浏览器访问http://192.168.53.108:9100/选择基本查询搜素 1 2 [root@host-192-168-53-108~] #wgethttps://artifacts.elastic.co/downloads/kibana/kibana-5.5.0-x86_64.rpm [root@host-192-168-53-108~] #rpm-ivhkibana-5.5.0-x86_64.rpm 1 2 3 4 [root@host-192-168-53-108~] #cat/etc/kibana/kibana.yml|grep-v'^#'|grep-v^$ server.port:5601 server.host: "0.0.0.0" elasticsearch.url: "http://elk1:9200" 1 2 [root@host-192-168-53-108~] #/etc/init.d/kibanastart [root@host-192-168-53-108~] #chkconfig--addkibana 本文转自谢无赖51CTO博客,原文链接:http://blog.51cto.com/xieping/1951765,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

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

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

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

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册