ElasticSearch7.3学习(十四)—-生产环境实时重建索引

1、实时重建索引

在实际的生产环境中,一个field的设置是不能被修改的,如果要修改一个Field,那么应该重新按照新的mapping,建立一个index,然后将数据批量查询出来,重新用bulk api写入index中。

批量查询的时候,建议采用scroll api,并且采用多线程并发的方式来reindex数据。例如说每次scoll就查询指定日期的一段数据,交给一个线程即可。

(1) 一开始,依靠dynamic mapping,插入数据,但是不小心有些数据是2019-09-10这种日期格式的,所以title这种field被自动映射为了date类型,实际上它应该是string类型的。

首先插入以下数据

PUT /my_index/_doc/1
{
  "title": "2019-09-10"
}

PUT /my_index/_doc/2
{
  "title": "2019-09-11"
}

(2)当后期向索引中加入string类型的title值的时候,就会报错

PUT /my_index/_doc/3
{
  "title": "my first article"
}

报错

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [title] of type [date] in document with id '3'. Preview of field's value: 'my first article'"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [title] of type [date] in document with id '3'. Preview of field's value: 'my first article'",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "failed to parse date field [my first article] with format [strict_date_optional_time||epoch_millis]",
      "caused_by": {
        "type": "date_time_parse_exception",
        "reason": "Failed to parse with all enclosed parsers"
      }
    }
  },
  "status": 400
}

(3)如果此时想修改title的类型,是不可能的

PUT /my_index/_mapping
{
  "properties": {
    "title": {
      "type": "text"
   	}
  }
}

报错

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "mapper [title] of different type, current_type [date], merged_type [text]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "mapper [title] of different type, current_type [date], merged_type [text]"
  },
  "status": 400
}

(4)此时,唯一的办法,就是进行reindex,也就是说,重新建立一个索引,将旧索引的数据查询出来,再导入新索引。

(5)如果说旧索引的名字,是old_index,新索引的名字是new_index,终端java应用,已经在使用old_index在操作了,难道还要去停止java应用,修改使用的indexnew_index,才重新启动java应用吗?这个过程中,就会导致java应用停机,可用性降低。

(6)所以说,给java应用一个别名,这个别名是指向旧索引的,java应用先用着,java应用先用prod_index来操作,此时实际指向的是旧的my_index

PUT /my_index/_alias/prod_index

(7)查看别名,会发现my_index已经存在一个别名prod_index了。

GET my_index/_alias

(8)新建一个index,调整其title的类型为string

PUT /my_index_new
{
  "mappings": {
    "properties": {
      "title": {
        "type": "text"
      }
    }
  }
}

(9)使用scroll api将数据批量查询出来

GET /my_index/_search?scroll=1m
{
  "query": {
    "match_all": {}
  },
  "size": 1
}

返回

{
  "_scroll_id" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAARUMWQWx5bzRmTW9TeUNpNmVvN0E2dF9YQQ==",
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "title" : "2019-09-10"
        }
      }
    ]
  }
}

(9)采用bulk apiscoll查出来的一批数据,批量写入新索引

POST /_bulk
{"index":{"_index":"my_index_new","_id":"1"}}
{"title":"2019-09-10"}

(10)反复循环8~9,查询一批又一批的数据出来,采取bulk api将每一批数据批量写入新索引

(11)将my_index索引的别名prod_index切换到my_index_new上去,java应用会直接通过index别名使用新的索引中的数据,java应用程序不需要停机,零提交,高可用

POST /_aliases
{
  "actions": [
    {
      "remove": {
        "index": "my_index",
        "alias": "prod_index"
      }
    },
    {
      "add": {
        "index": "my_index_new",
        "alias": "prod_index"
      }
    }
  ]
}

(12)直接通过prod_index别名来查询,是否ok

GET prod_index/_search

可以看到能够查询到新索引my_index_new的数据了

{
  "took" : 1117,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_index_new",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "title" : "2019-09-10"
        }
      }
    ]
  }
}

2、总结:

基于aliasclient透明切换index

PUT /my_index_v1/_alias/my_index

clientmy_index进行操作

reindex操作,完成之后,切换v1到v2

POST /_aliases
{
    "actions": [
        { "remove": { "index": "my_index_v1", "alias": "my_index" }},
        { "add":    { "index": "my_index_v2", "alias": "my_index" }}
    ]
}

macOS X Mount NFS Share / Set an NFS Client

Network File System (NFS), a distributed file system protocol developed by Sun Microsystems. NFS is the common for file sharing on NAS server and Linux / UNIX systems like, HP-UX, Solaris, Mac OS X, and

Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements OSX 10.6.x/10.7.x
Est. reading time 10m

others. Mac OS X can be setup as an NFS client to access shared files on the network. Mounting NFS volumes in OS X can be done using following methods: 

ADVERTISEMENT

a] Command line option.

b] GUI option.

macOS X Mount NFS Share / Set an NFS Client

Our sample setup for macOS client and nfs server:

        nas01                                   Laptop/Desktop
   +--------------+                           +--------+
   |  UNIX/Linux  |                           | Mac    |
   |    NFS       +---------------------------+ OS X   |
   |   SERVER     |  mount nas01:/mp3 /nfs    | Client |
   +--------------+                           +--------+
         |                                    (192.168.3.100)
     (shared dirs)
         /
         --/Sales
         --/Mp3
         --/Data
         --/wwwroot
   (192.168.3.1) 
See all UNIX related articles/faq

nas01 allows your users or client compute to access files over a network. Mac OS can mount file system over a network and work as they are mounted locally. This is perfect for sharing files or centralized home directories. See how to setup an NFS server under RHEL / CentOS Linux and Ubuntu Linux here. 

How Do I Find Out Shared Directories?

To mount an NFS file system, the resource must be made available on the NAS or NFS server. To verify that resource available open the terminal and type the following command:
$ showmount -e nas01
$ showmount -e nfs-server-ip-address-here
$ showmount -e nas01.lan.nixcraft.net.in

Sample outputs:

Fig.01: UNIX showmount command lists all clients that have remotely mounted a filesystem from NFS server

Fig.01: UNIX showmount command lists all clients that have remotely mounted a filesystem from NFS server

The showmount command show remote NFS mounts (resources).

Mac OS X Nfs mount Command

First, create a directory to mount an nfs share, enter:
$ sudo mkdir /private/nfs
$ sudo mkdir /private/mp3

To mount an NFS file system, enter:
$ sudo mount -t nfs nas01:/mp3 /private/nfs
OR
$ sudo mount -t nfs 192.168.3.1:/mp3 /private/nfs
To mount an NFS file system in read/write mode, enter:
$ sudo mount -o rw -t nfs nas01:/mp3 /private/nfs

Tip: Operation not permitted Error

If you get an error which read as follows:

 192.168.3.1:/mp3 Operation not permitted

Try to mount it as follows with -o resvport command:
$ sudo mount -t nfs -o resvport 192.168.3.1:/mp3 /private/nfs
OR mount an NFS in read/write mode, enter:
$ sudo mount -t nfs -o resvport,rw 192.168.3.1:/mp3 /private/nfs
From the man page:

resvport
Use a reserved socket port number. This is useful for mounting
servers that require clients to use a reserved port number on the
mistaken belief that this makes NFS more secure. (For the rare
case where the client has a trusted root account but untrustwor-
thy users and the network cables are in secure areas this does
help, but for normal desktop clients this does not apply.)

Verify: NFS Is Working or Not

Type the following commands:
df -H
$ cd /private/nfs
$ ls -l

Sample outputs (note I’ve mounted it at /private/mp3/ dir):

Fig.02: UNIX df command

Fig.02: UNIX df command which displays information about total space and available space for NFS

How Do I Copy Files?

Use the cp command:
cp /path/to/file.doc /private/nfs/
$ cp -a /path/to/*pl /private/nfs/
$ cp /private/nfs/mp3/*.mp3 ~/mp3

Using the Finder

Note: The following entry “NFS mounts” in the Disk Utility does NOT exist in MAC OS X v10.8+. The following discussion only applies to the older Mac OS X version <= 10.7.x and eariler.

The Finder is the default file manager used on the Mac OS and Mac OS X operating systems that is responsible for the overall user-management of files, disks, network volumes and the launching of other applications. Open Finder > Shared (select from the left sidebar) > NFS server (nas01 or 192.168.3.1):

Fig.03: The Finder in action (browse an NFS share)

Fig.03: The Finder in action (browse an NFS share)

Now, you can copy and paste files as usual. 

Recommend mount Command Options

I suggest that you run the mount command it as follows to get better a performance:
$ sudo mount -t nfs -o soft,intr,rsize=8192,wsize=8192,timeo=900,retrans=3,proto=tcp nas01:/sales /private/sales
OR
sudo mount -t nfs nfs -o soft,timeo=900,retrans=3,vers=3, proto=tcp nas01:/sales /private/sales
See mont_nfs(8) for more information.

GUI Method: HowTo Set Mac OS X As an NFS Client

To mount an NFS share from OS X using GUI tools, follow these steps:

[1] Start Finder, and go to Applications / Utilities / Disk Utility:

Fig.04: Starting Disk Utility

Fig.04: Starting Disk Utility

You will see the disk utility as follows: 

Fig.05: Click the 'Mounts' icon at the top of the Directory Utility panel

Fig.05: Click the ‘Mounts’ icon at the top of the Directory Utility panel

[2] Alternatively, you can select “Disk utility” > click on File > Mount NFS as follows:
Fig.06: Mounting an NFS using - Disk Utility > File > Mount optionYou will see an “NFS mounts” window as follows:

Fig.07: OS X NFS Mounts to set it as an NFS Client

Fig.07: OS X NFS Mounts to set it as an NFS Client

[3] Click on “+” icon:

Fig.08: Setting up an NFS mount options in the dialog box

Fig.08: Setting up an NFS mount options in the dialog box

You need to enter your remote NFS server URL (IP address or dns name) in the following format:
nfs://192.168.3.1/mp3
nfs://nas01/mp3

Where, 

  1. 192.168.3.1: NFS server IP address.
  2. nas01: NFS server dns name.
  3. mp3: Shared nfs directory name.

You need to set mount location as follows:
/Volumes/mp3
/Volumes/mp3 is nothing but the mount location. This is a convenient place. In this example, you entered the URL as nfs://192.168.3.1/mp3, enter /Volumes/mp3 as the mount location. Please note that don’t create the subdirectory (mp3); it will be created dynamically when the share is mounted.

Optional

Click the arrow in front of “Advanced Mount Parameters”. A new text entry box is displayed. Enter: resvport (this is only required if you get some sort of error [see above for more info or read mount_nfs man page]).
[4] Finally, click “Verify” button at the bottom right:

Fig.09: Verify NFS mount configuration which only checks that your NFS server is enabled and working correctly.

Fig.09: Verify NFS mount configuration which only checks that your NFS server is enabled and working correctly.

[5] You will see a popup window, stating that “The NFS server appears to be functional” > Click “OK” button to continue. Finally, Click “Save” button. You may be prompted for the password to make changes. Your NFS share should appear at the mount location you entered above i.e. /Volumes/mp3.

Fig.10: NFS Share mounted

Fig.10: NFS Share mounted

You can access /Volumes/mp3 using the Finder:

Fig.11: The finder in action

Fig.11: The finder in action

You can also use command line options:
$ ls /Volumes/mp3
$ cd /Volumes/mp3
cp /path/to/something.file.in file.out
rsync -av user@server3.nixcraft.com:/var/www/html/ server.backups/
 

See also:

This entry is 3 of 15 in the Linux / UNIX NFS File Server Tutorial series. Keep reading the rest of the series:

  1. CentOS / Redhat: Setup NFS v4.0 File Server
  2. Debian / Ubuntu Linux: Setup NFSv4 File Server
  3. Mac Os X: Mount NFS Share / Set an NFS Client
  4. RHEL: How Do I Start and Stop NFS Service?
  5. How To Restart Linux NFS Server Properly When Network Become Unavailable
  6. Linux Iptables Allow NFS Clients to Access the NFS Server
  7. Debian / Ubuntu Linux Disable / Remove All NFS Services
  8. Linux: Tune NFS Performance
  9. Mount NFS file system over a slow and busy network
  10. Linux Track NFS Directory / Disk I/O Stats
  11. Linux Disable / Remove All NFS Services
  12. Linux: NFS4 mount Error reason given by server: No such file or directory
  13. Linux NFS Mount: wrong fs type, bad option, bad superblock on fs2:/data3 Error And Solution
  14. CentOS / RHEL CacheFS: Speed Up Network File System (NFS) File Access
  15. Increase NFS Client Mount Point Security

 

🥺 Was this helpful? Please add your comment below to show your appreciation or feedback ↓

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

RSS feed ➔    Weekly email newsletter ➔

Category List of Unix and Linux commands
Ansible Check version • Fedora • FreeBSD • Linux • Ubuntu 18.04 • Ubuntu • macOS
Download managers wget
Driver Management Linux Nvidia driver • lsmod
Documentation help • mandb • man • pinfo
Disk Management df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
KVM Virtualization CentOS/RHEL 7 • CentOS/RHEL 8 • Debian 9/10/11 • Ubuntu 20.04
Linux Desktop apps Chrome • Chromium • GIMP • Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap • ping
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 11 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Power Management upower
Package Manager apk • apt-get • apt • yum
Processes Management bg • chroot • cron • disown • fg • glances • gtop • iotop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • egrep • grep • whereis • which
Shell builtins compgen • echo • printf
System Management reboot • shutdown
Terminal/ssh tty
Text processing cut • rev
User Environment exit • who
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • w
User Management /etc/group • /etc/passwd • /etc/shadow • chsh
WireGuard VPN Alpine • Amazon Linux • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 • qrencode
37 comments… add one
  • Sergei Nov 4, 2010 @ 7:58

    now that’s a working tutorial! been struggling with my Zyxel NSA220, trying to use NFS instead of SMB – couldn’t mount until found this page 🙂

  • Jaysunn Dec 8, 2010 @ 21:19

    Wow,
    Vivek this is a great tutorial. I as well was struggling and as soon as I found this page I nailed it in one try. Thanks jaysunn

  • Ken Mar 30, 2011 @ 22:48

    This doesn’t describe how to set up persistent NFS mounts from the command line (hard mounts, not automounts). That should be easy but I can’t find it anywhere.

    • 🐧 nixCraft Mar 31, 2011 @ 5:18

      Do you want to know about soft / hard option that determines the recovery behavior of the NFS client after an NFS request times out? May be you need to give us more info..

    • dipmit Aug 2, 2011 @ 11:54

      you have to fire this command for mout NFS shared folder to MAC OX
      sudo mount_nfs -P :

  • erez May 6, 2011 @ 0:28

    Great job……thanks 🙂

  • Chiraj Sep 11, 2011 @ 22:38

    I followed every step(gui and terminal) word for word and I can see files on my nfs server, but I can’t write or modify the contents of the shared directory. It keeps saying “Permission Denied”. Is there anything particular I need to do on the server side?

    • 🐧 nixCraft Sep 12, 2011 @ 11:36

      You need to make sure server is exporting directories in a rw (read write) and not in a ro (read only) mode.

      • Chiraj Sep 14, 2011 @ 21:26

        If have tried exporting it as rw as seen below, but still no avail 🙁

        /mnt/shared 192.168.0.0/255.255.0.0(rw,sync,all_squash,anonuid=502,anongid=502,insecure)

        • sofia story Feb 7, 2012 @ 3:42

          Same problem here.

          • Colin Aug 28, 2012 @ 12:50

            ditto Lion 10.7.4 rw enabled in /etc/exports

  • fsimerey Sep 14, 2011 @ 16:18

    Have a NFS server running on Debian 5.
    I can mounting my shares on Linux Mint 11 like a charm (with r/w permissions).
    But under os 10.6.8, i can mount these shares but i haven’t permission to write or modify anything -> “Permission Denied”.
    The NFS server is setup with these options in /etc/exports

    /mnt/shared 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)

    Any idea ?
    Thanks in advance

    • fsimerey Sep 14, 2011 @ 16:57

      In fact, i can create and modify files via terminal if i use sudo command or logged as root.
      All folders/files are uid=1000 and gid=1000 like the screen capture of this article.

      • ttt May 7, 2012 @ 13:52

        You need to add an account on Debian server. For example if you login as fsimerey on OS X. Make fsimerey account on the Debian too. This will map UID and GIDs.

  • Sx1 Oct 8, 2011 @ 19:30

    Hi from France,

    Great faqs, thank !
    I have the same question as fsimerey.

    I can access to my nfs server, but not with my single user account under mac Osx. I need to use SUDO into the terminal to access it.

    From my others PC, under Ubuntu, single users don’t needs to use root account to access the nfs.

    My nfs server exports : rw, sync, no_root_squash, anonuid=1000,anongid=1000

    Can you help me please ?

    Thank a lot

  • Lyndon Adams Oct 18, 2011 @ 21:02

    Worked first time using Fedora 15 and latest Mac OS X. Many thanks!!

  • pww Oct 21, 2011 @ 2:35

    got it

  • Nicklas Nilsson Jan 15, 2012 @ 16:53

    Same problem as fsimerey and sx1! Anyone now a fix?

    • 🐧 nixCraft Jan 15, 2012 @ 19:21

      Most modern NFS server need some sort of user authentication and user id mapping. For example, /home/vivek is owned by vivek user id # 501 on the Debian Linux nfs 4 server.
      You need to add a user called vivek to Apple OS x with user id # 501 using the following command:

      sudo dscl . -create /Users/vivek UniqueID "501"

      See this page for more info. Use dscl command with care as it can destroy existing users and other system properties.

  • Rogerio Jan 21, 2012 @ 5:04

    Thanks for the article.
    Now I have a NFS server running on Ubuntu 11.10 exporting a 2TB exFAT external HD drive. Had to install fuse-exfat to be able to mount the HD on Ubuntu.
    I mounted a NFS folder on a Mac OSX using: sudo mount -t nfs -o resvport my_nfs_server:/media/HD2TB /private/nfs and from Finder I can navigate through and create folders and even open large files. The problem is that I can’t copy anything to the NFS (neither from Finder nor from Terminal). Here is the error:
    cp: /private/nfs/test.txt: fchmod failed: Input/output error
    Here is my /etc/exports:
    /media/HD2TB my_mac(rw,no_root_squash,no_subtree_check)
    Thanks for helping.

    • fsimerey Jan 21, 2012 @ 10:26

      For my nfs exports on Debian, i used insecure option.
      Try with:
      /media/HD2TB my_mac(rw,no_root_squash,no_subtree_check,insecure)

      Hope that would solve your prob.

  • Björn König Apr 15, 2012 @ 14:58

    Thanks for the tutorial. It fit the trick for me!

  • tim Jul 31, 2012 @ 0:50

    running ox 10.8 and in disk utility. Under file menu mount is grayed out and there is no nfs mount in menu.

  • Nik Sep 2, 2012 @ 15:13

    Vivek – Brilliant! Was annoyed with my Synology 1512+ shares with AFP going offline and having to remount for my Plex (MMS). This was the solution! I used your tutorial (which was spot on) and a GUI from NFS Manager(now that OSX 10.8 Disk Utility doesn’t have NFS mounting options) and was successful. I’m super happy now with automounts and dismounts for all my shares! Great, great job!!!!

    p.s. With OSX 10.8 not including the Disk Utility bit, you may want to update/mention that for future users.

  • Daniel Sep 6, 2012 @ 9:43

    After a solid week of having permission denied messages etc.. out of Mountain Lion, here is the fix…..

    Stolen from Apple Discussions:

    Hi!
    Few days ago i run into same problem. I have Ubuntu server and want to mount some folders from there… Anyway, I was solved this problem this way:
    — on Ubuntu —
    1. edit /etc/exports (sudo vim /etc/exports) and add this line(s)

    /folder 0.0.0.0(rw,sync,all_squash,insecure,anonuid=xxx,anongid=xxx)
    


    where “/folder” is a folder you want to mount from your Mac
    “0.0.0.0” is an IP address you allow to connect to your share from
    “anonuid=xxx,anongid=xxx” is UID and GID of user on Ubuntu you want to be used as owner of files you want to create on mounted share (if you ommit this you will have read-only access to the share folder)
    2. export your shares – sudo exportfs -a
    ———————–
    — on your Mac —
    Use Connect to Server (Commant+K) menu and write nfs://server-name-or-ip/folder
    ————
    Voila! You have to have rw access to shared folder on your server.

    P.S. check man exports to find some additional info to set IP ranges you want to allow to connect from.

    Good luck!

  • Ulf von Barth May 25, 2013 @ 11:00

    Dear Helper,

    There are two major flaws with the mount instructions above:
    1. The entry “NFS mounts” in the Disk Utility does NOT exist in MAC OS X 10.8!
    2. It is easy to NFS-mount disks read only in 10.8 but much harder to mount them
    read-write. As you can see above the parameter “-o rw” is missing in the
    examples above!

    Thanks anyway for the nice tutorial. Have a good day, vonbarth

    • 🐧 nixCraft Aug 4, 2013 @ 8:41

      Thanks for the heads up! The faq has been updated.

  • Steve Glasser May 29, 2013 @ 3:09

    Vivek — there is a problem accessing a “normal” nfs server from osx if the mount option “-o resvport” is used on the osx client. Most/normal nfs servers are firewalled; opening port 2049 for nfs connections. Osx is going to pick a random low-numbered port to connect on and this will be blocked on the nfs server.

    Is there some sort of solution for this? Cheers

  • Matheus Oct 1, 2013 @ 14:13

    I has no problem at all setting up a NFS client for my macOsx 10.8…. The only thing is that diskutil does not support it but terminal does!

  • Klas Wirholm Mar 1, 2014 @ 4:06

    The problem is the dynamic port the mac client try to access. For you who have a Linux nfs server, this is probably is off interests.

  • remd Sep 8, 2014 @ 8:55

    I’ve setup a freeipa server on centos mostly following theses guidelines:
    http://linsec.ca/Using_FreeIPA_for_User_Authentication#Mac_OS_X_10.7.2F10.8

    Everything seems to be working fine, except that the osx client can’t automount the /home share at startup.
    I can auth and/or mount the share manually in the command line, but at startup the logs show “server not responding”.
    This is the line I’ve added in auto_home (referred to in auto_master):
    * -fstype=nfs,rw,resvport,soft,intr,rsize=8192,wsize=8192,nosuid,tcp nfsserver:/home/&

    I have tried many options and variations of this command, but have been unsuccessful so far – does anyone have an idea how this can be done ?

  • remd Sep 9, 2014 @ 13:42

    It was a firewall issue – its working now

  • Jeron Dec 15, 2015 @ 11:37

    What about reverse situation? I want to share dir from my mac to linux machine.

    Mac has ip 192.168.0.26 and linux has 192.168.99.100

    In /etc/exports on mac I have this:
    /Users -mapall=my_user -alldirs -network 192.168.99.0 -mask 255.255.255.0

    Then on linux I do this:
    sudo mount 192.168.0.26:/Users /Users -o rw,async,noatime,rsize=32768,wsize=32768,p
    roto=tcp

    And it says:
    mount: 192.168.0.26:/Users failed, reason given by server: Permission denied
    mount: mounting 192.168.0.26:/Users on /Users failed: Bad file descriptor

    my_user belongs to admin group. Firewall is disabled at all. What the problem can be?

  • Francisco Jan 19, 2016 @ 19:34

    Thanks for your article
    how could you configure your export for mounting without option resvport?

    thanks

  • Benjamin May 29, 2017 @ 22:48

    Worked perfectly for me from an Ubuntu host to a macOS Sierra guest, thank you!

  • kitkat Dec 6, 2017 @ 21:52

    those running into ‘permission denied’ for writing into the mount- do not use sudo to mount on the mac side. If you use sudo – you will mount the dir as root and you will have to be ‘sudo’ to make changes. Just do mount, then you will mount as the user and not as root.

  • brad Jan 22, 2021 @ 0:12

    On Mac, running 11.1 OS, I got an error nfs can’t mount with remote locks … rpc.statd. On cmd line I ran this:
    sudo mount -o nolocks -t nfs …
    and it worked

Leave a Reply

Your email address will not be published. 

Use HTML <pre>…</pre> for code samples. Your comment will appear only after approval by the site admin.

mac提示Insecure world writable解决

问题起因是 给同事开了一下分享,但是目录实在 Users/xxx 下,给这个目录开了“客人”读写权限。因此提示 Insecure world writable dir /Users/xxx/yyy

解决办法 就是 把 群组和其他人对这个目录/文件的 读写权限去掉

chmod go-rw /Users/xxx/yyy

 

apisix路由地址重写

路径匹配改写

比如请求网关是 /test/order/all, 然后后端接收的路径应该是 /order/all, 中间的test只是充当服务名的标识。

路径 填  /test/*    匹配/test/ 这种请求, /test 是不满足的

路径改写选正则改写

匹配 /^test/(.*)   表示匹配/test/之后的部分,作为第一个匹配到的值,变量名为$1

转发路径模板 /$1    即取上一个匹配后的参数拼接转发

 

下一步 选择上游,选择已经建好的上游

docker-hub加速

方法一:

设置镜像地址

vim /etc/docker/daemon.json
{
        "registry-mirrors": [
                "https://registry.docker-cn.com",
                "https://hub-mirror.c.163.com",
                "https://dockerhub.azk8s.cn",
                "https://reg-mirror.qiniu.com"
        ]
}

重启服务

systemctl daemon-reload 

systemctl restart docker && systemctl enable docker

方法二:

步奏如下:

1.进入www.daocloud.io,注册一个免费账号。
2.登录完成,点击顶部的加速器。
3. 在你的docker配置中添加 加速器。https://www.daocloud.io/mirror
注:(该脚本可以将 –registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同。更多详情请访问文档。)

### Linux

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

4.手动使用方法

./xxx.sh http://mirror.xxx.com
./set_mirror.sh http://f1361db2.m.daocloud.io

Ubuntu 20.04 && Ubuntu 18.04 修改 apt 源

目录
查看linux系统发行版本信息
ubuntu 20.04
ubuntu 18.04
部分ubuntu系统LTS版本代号
修改sources.list文件
ubuntu 20.04
ubuntu 18.04
更新
查看linux系统发行版本信息
ubuntu 20.04
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
1
2
3
4
5
可以看到发行版本代号为 focal

ubuntu 18.04
$ lsb_release -c
Codename: bionic
1
2
可以看到发行版本代号为 bionic

部分ubuntu系统LTS版本代号
Ubuntu 16.04代号为:xenial

Ubuntu 17.04代号为:zesty

Ubuntu 18.04代号为:bionic

Ubuntu 19.04代号为:disco

Ubuntu 20.04代号为:focal

修改sources.list文件
$ sudo vim /etc/apt/sources.list
1
ubuntu 20.04
#阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
1
2
3
4
5
6
7
8
9
10
11
ubuntu 18.04
#阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
1
2
3
4
5
6
7
8
9
10
11
更新
$ sudo apt-get update
$ sudo apt-get upgrade

#1366 – Incorrect string value: ‘\xE6\x96\xB0\xE9\x97\xBB’ for column ‘cate_name’ at row 1

1.解释:

这是一个自定义的Mysq函数在运行时候所报的错误

2.Mysql的函数:

CREATE FUNCTION `getClassName`(classId INTEGER)
RETURNS varchar(50) CHARSET utf8
DETERMINISTIC
BEGIN
DECLARE cName VARCHAR(50)  DEFAULT ”;
SELECT `name` INTO cName from class where cid=classId;
RETURN cName;
END;

3.分析:

报错的含义就是此函数在第一行定义的cName这个字段被赋予了错误的字符串值:’\xE4\xB8\xAD\xE6\x96\x87′

实际上就函数里面的变量接收到的值跟它定义的不一致,但是一看还是varchar类型为什么会不一致呢?

再仔细检查它被赋予的值里面一定是有中文在里面的,所以问题就在于中文,要解决这个问题就需要让cName这个变量可以接收中文才行,于是把上面的cName声明修改如下:

CREATE FUNCTION `NewProc`(classId INTEGER)
RETURNS varchar(50) CHARSET utf8
DETERMINISTIC
BEGIN
DECLARE cName VARCHAR(50) CHARSET utf8  DEFAULT ”;
SELECT `name` INTO cName from class where cid=classId;
RETURN cName;
END;

就是在声明cName的后面给它指定了编码格式:CHARSET utf8

再次运行此函数,结果中有中文也不会报错了。

flutter 使用MD5加密

1、在pubspec.yaml中引入crucpto,更新依赖

crypto: ^2.1.5
2、引入头文件

import ‘dart:convert’;
import ‘dart:typed_data’;
import ‘package:crypto/crypto.dart’;
3、使用md5加密

///使用md5加密
String generateMD5(String data) {
Uint8List content = new Utf8Encoder().convert(data);
Digest digest = md5.convert(content);
return digest.toString();
}
————————————————
版权声明:本文为CSDN博主「SkyCloud5+2」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lqw200931116/article/details/123040516