标签: digitalocean

digitalocean使用经验

  • DigitalOcean开始支持FreeBSD

    DigitalOcean应广大客户要求,在今天正式开始支持FreeBSD。附上官方的宣传海报:

    FreeBSD作为DigitalOcean平台上出现的地一个非Linux内核的操作系统,以稳定性和良好的操作性而著称。作为20156年DigitalOcean的第一个大动作,期待DigitalOcean能够提供更多更好的服务。本来打算翻译官方给出的详细说明,发现自己的中式英语太蹩脚了,就不献丑了,在这里附上官方的说明,供参考。

    We’re happy to announce that FreeBSD is now available for use on DigitalOcean!

    FreeBSD will be the first non-Linux distribution available for use on our platform. It’s been widely requested because of its reputation of being a stable and performant OS. While similar to other open source unix-like operating systems, it’s unique in that the development of both its kernel and user space utilities are managed by the same core team, ensuring consistent development standards across the project. FreeBSD also offers a simple, yet powerful package management system that allows you to compile and install third-party software for your system with ease.

    One particularly compelling attribute of the FreeBSD project is the quality of theirdocumentation, including the FreeBSD Handbook which provides a comprehensive and thoughtful overview of the operating system. We at DigitalOcean love effective and concise technical writing, and so we’ve also produced numerous FreeBSD tutorials to aid new users with Getting Started with FreeBSD.

    We understand that this has been a long standing user request, and we’ve heard you. You might be asking yourself – what took so long?

    The internal structure of DigitalOcean’s engineering team has rapidly changed over time due to the dynamic growth of the company. What began as a couple of guys coding furiously in a room in Brooklyn has ballooned to a 100+ person organization serving hundreds of thousands of users around the globe. As we’ve grown, by necessity we’ve needed to adjust and reorganize ourselves and our systems to be able to better serve our users. There have been many experiments in how we approach, prioritize and execute this work; this image is a result of the successful alignment of a few key elements.

    Technical Foundation

    Last year, we built our metadata service — allowing a droplet to have access to information about itself at the time that it’s being created. This is a powerful thing because it gives a vanilla image a mechanism to configure itself independently. This service was a big part what allowed us to offer CoreOS, and in building it, it gave us more flexibility in what we could offer moving forward. Our backend code would no longer need to know the contents of the image to be able to serve it. On creation, the droplet itself could query for configurables — hostnames, ssh keys, and the like — and configure itself instead of relying on a third party.

    This fundamental decoupling is an echo of a familiar refrain: build well defined interfaces and don’t let knowledge leak across those boundaries unnecessarily. It’s allowed us to free images from customization by our backend code, and entirely sidestep the problematic issue of modifying a UFS filesystem from a Linux host.

    Since we now had a feasible mechanism to allow images to be instantiated independently of our backend, we just needed to put the parts together that would allow us to inject the configuration upon creation. FreeBSD doesn’t itself offer cloud versions of the OS similar to what Canonical and Red Hat provide, so we started from a publicly available port of cloud-init meant to allow FreeBSD to run on OpenStack.

    In order to query metadata, we need to have an initial network configuration in order to build our configuration, since DigitalOcean’s droplets use static networking. During boot time, we bring up the droplet on a v4 link-local address in order to do the initial query to the service. From there, we pick up the real network config, hostname, and ssh keys. The cloud-init project then writes a configuration that’s associated with the droplet’s ID. Linking this configuration to the droplet ID is the mechanism that allows it to know whether the image is being created from a snapshot or new create, or is just a rebooted instance of an already configured droplet.

    Once this configuration has been injected, FreeBSD’s boot process can continue and use it accordingly — eventually booting into the instance as expected.

    Focus

    This endeavor began life as an experiment in how we organize ourselves in the engineering team. We were given a few weeks to pick a project, self organize in cross-functional teams, and execute. A lot went right during this process that allowed this project to succeed.

    Deadlines are powerful things. Not in a punitive or negative sense of the word, but in a sense that there will be a well defined time where work on this will collectively end. So is having a very clear picture of what “done” looks like. In the case of BSD, it was particularly powerful to have a clear goal of a alpha functional BSD droplet with a date to drive for. Given the freedom to focus on a single goal, clear communication, and well defined restraints, we were able to finally deliver a long standing user request with relative ease.

    This is the start to the many things we’re excited to build in 2015!

  • digitalocean wordpress 数据库错误解决办法

    wordpress数据库连接错误的毛病相信很多用户都遇到过,无非是数据库出了故障,导致连接失败。前几日,一直被数据库连接错误的问题所围绕。刚开始,认为是vps性能差导致,于是开启了cache,可是依然如故,没过多久就又连接错误了。

    从网上搜索了一些优化mysql数据库的文章,尝试优化数据库,优化之后直接无法启动数据库了,查看日志后发现wp_options这个表故障所致,在vps中,进入mysql,repair下wp_options这个表,就可以了。

    用到的命令:

    登录MySQL:mysql -uroot -p (用root账户登录),然后输入密码;

    修复数据表:repair 表名

    修复wp_options的话,就输入 repair wp_options

    退出mysql操作: q

     

  • digitalocean使用两天感受

    博客由digitalocean驱动,有5天了,整体感觉不错,不过数据库挂掉了不下两次了,由于前几日没注意,看到阿里云发来的监测日志,才意识到宕机时间那么久。联系了客服,客服给的建议,竟然是让升级服务,说是512内存的vps支撑不了。

    这个确实有些让人难以接受了,我流量少的可怜,不存在大的波动,怎么可能频繁宕机呢?继续用两天试试,如果不行的话,就重装试试,实在不行就用完这个月再换回ec2,毕竟稳定比什么都重要。

    附上客服的奇葩解决办法:

    The most common reason why MySQL is not running is that it stopped or failed to start as a result of not enough memory.

    This can usually be seen by attempting to start the mysql server (“service mysql start” on Ubuntu and some other systems) and then reviewing the mysql error log (usually in /var/log/mysql/error.log or similar file path).

    A useful program to review the logs one page at a time is “less” –for example:

    less /var/log/mysql/error.log

    If you see memory issues such as “mmap can’t allocate” then you can be sure that you are having memory issues.

    Potential solutions are:

    1) upsize to a larger server. We recommend at least a 1GB droplet for any server utilizing a MySQL database.

    2) Enable swap space, which functions in the same way as RAM, except it’s slower since it’s using disk space to simulate RAM. Your system uses this only in the case where you run out of RAM, and it’ll likely result in slower responses from your site, but if you add enough swap (generally twice as much as the amount of RAM you have is a safe bet) it should prevent MySQL from crashing and causing your site to go down. You can find a guide relevant to your Linux distribution here:

    有点店大欺客的感觉了,之前哪怕用000webhost都没有这么脆弱。

  • 从amazon ec2搬迁至digitalocean

    博客使用Amazon EC2有一年了,一年的免费使用配额就要结束,由于博客所占用的空间以及流量比较低,综合考量之后,决定搬迁。EC2使用过程中,直到最后这个月的时候,才出现了MYSQL数据库有损坏的问题,简单修复后仍然正常使用,没有重启过,没有遇到过宕机。单论稳定这一条,还是很赞的。

    搬迁思路,很简单,EC2和digitalocean分别安装phpmyadmin,推荐安装4.0的版本,否则会遇到提示数据库版本低的问题。备份wp-content目录,copy到digitalocean中。

    不推荐使用wordpress的数据库备份插件,导入后会遇到乱码问题。

    由于博客使用了伪静态,导入到digitalocean后要设置一下。digitalocean一键安装的wordpress是使用的lamp架构,vps默认直接开启了伪静态。只需要在wordpress根目录添加.htaccess文件即可。

    还有一点就是wp-content文件夹的权限设置。

    处理完了以上这些问题就搬家成功了。如果遇到问题测试域名的话,建议自己本机改host来配合测试。